后台文件 ZSql.cs TreeViewClass.cs

时间:2012/12/26 1:25:58  作者:Mho  来源:原创  查看:4462  评论:0
内容摘要:    前段时间,下载了一个管理系统的源码,可是,因为被编译过了,异或许是开发者想往商业方向发展,所以有几个文件被刻意藏到了.dll文件中。有位新手说得好,那些隐藏的代码,其实没什么大不了的,可是,对于新手,却难比登天。我也是新手,找了好多人,才弄到...
    前段时间,下载了一个管理系统的源码,可是,因为被编译过了,异或许是开发者想往商业方向发展,所以有几个文件被刻意藏到了.dll文件中。有位新手说得好,那些隐藏的代码,其实没什么大不了的,可是,对于新手,却难比登天。我也是新手,找了好多人,才弄到了代码,好多新手最想要的两个文件是ZSql.cs,TreeViewClass.cs,不过,其实还有蛮多文件被隐藏的,而且还是有点不完美,还是有点错误。既然是学习之用,只当做是参考资料吧,希望能对急需的人提供些许帮助。

ZSql.cs 文件代码:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

/// <summary>
///MoSQL 的摘要说明
/// </summary>
public class ZSql
{
    // Fields
    private SqlCommandBuilder m_cb;
    private SqlCommand m_cmd;
    public SqlConnection m_conn;
    private SqlDataAdapter m_da;
    public SqlDataReader m_dr;
    public DataSet m_ds;
    private string m_idname;
    private int m_rowindex;
    public DataTable m_table;

    // Methods
    public ZSql()
    {
        this.m_conn = new SqlConnection();
        //this.m_conn.ConnectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
        this.m_conn.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["conn"];
        this.init();
    }

    public ZSql(IDbConnection conn)
    {
        this.m_conn = (SqlConnection)conn;
        this.init();
    }

    public ZSql(string connstr)
    {
        this.m_conn = new SqlConnection();
        this.m_conn.ConnectionString = connstr;
        this.init();
    }

    public void Close()
    {
        if (this.m_dr != null)
        {
            this.m_dr.Close();
        }
        this.m_conn.Close();
    }

    public void config(string sqlstr, DataTable dt)
    {
        this.m_cmd.CommandText = sqlstr;
        this.m_table = dt;
    }

    public void Delete()
    {
        if (this.rowindex >= 0)
        {
            this.m_table.Rows[this.rowindex].Delete();
        }
    }

    public DataSet DSet(string sqlstr)
    {
        this.m_cmd.CommandText = sqlstr;
        this.m_da.Fill(this.m_ds);
        return this.m_ds;
    }

    public bool Find(string sname, object val)
    {
        this.rowindex = -1;
        while (this.NextRow())
        {
            if (this[sname].Equals(val))
            {
                break;
            }
        }
        if (this.rowindex == -1)
        {
            return false;
        }
        return true;
    }

    public object GetScalar(string sqlstr)
    {
        ConnectionState state = this.m_conn.State;
        if (this.m_conn.State == ConnectionState.Closed)
        {
            this.m_conn.Open();
        }
        object obj2 = new SqlCommand(sqlstr, this.m_conn).ExecuteScalar();
        if (state == ConnectionState.Closed)
        {
            this.m_conn.Close();
        }
        return obj2;
    }

    public SqlDataReader GetSqlDataReader(string sqlstr)
    {
        this.m_cmd.CommandText = sqlstr;
        this.m_dr = this.m_cmd.ExecuteReader();
        return this.m_dr;
    }

    private void init()
    {
        this.m_cmd = new SqlCommand();
        this.m_da = new SqlDataAdapter();
        this.m_cb = new SqlCommandBuilder(this.m_da);
        this.m_cmd.Connection=this.m_conn;
        this.m_da.SelectCommand=this.m_cmd;
        this.m_cmd.CommandType = CommandType.Text;
        this.m_table = new DataTable();
        this.m_ds = new DataSet();
        this.m_idname = "";
        this.m_dr = null;
    }

    public DataRow NewRow()
    {
        DataRow row = this.m_table.NewRow();
        this.m_table.Rows.Add(row);
        this.rowindex = this.m_table.Rows.Count - 1;
        return row;
    }

    public bool NextRow()
    {
        this.rowindex++;
        return (this.rowindex >= 0);
    }

    public int Open(string sqlstr)
    {
        this.m_cmd.CommandText = sqlstr;
        this.m_da = new SqlDataAdapter();
        this.m_cb = new SqlCommandBuilder(this.m_da);
        this.m_da.SelectCommand=this.m_cmd;
        this.m_table.Reset();
        this.m_da.Fill(this.m_table);
        this.rowindex = -1;
        return this.rowcount;
    }

    public int Open(string sqlstr, DataTable dt)
    {
        this.m_cmd.CommandText = sqlstr;
        this.m_table.Reset();
        this.m_da.Fill(dt);
        this.m_table = dt;
        this.rowindex = -1;
        return this.rowcount;
    }

    public IDataReader Open_dr(string sqlstr)
    {
        if (this.m_conn.State == ConnectionState.Closed)
        {
            this.m_conn.Open();
        }
        if ((this.m_dr != null) && !this.m_dr.IsClosed)
        {
            this.m_dr.Close();
        }
        this.m_cmd.CommandText = sqlstr;
        this.m_dr = this.m_cmd.ExecuteReader();
        return this.m_dr;
    }

    public void RemoveAt(int i)
    {
        if ((i >= 0) && (i < this.m_table.Rows.Count))
        {
            this.m_table.Rows.RemoveAt(i);
            this.rowindex = -1;
        }
    }

    public int Update()
    {
        this.m_idname = "";
        return this.m_da.Update(this.m_table);
    }

    public int Update(string idname)
    {
        this.m_idname = idname;
        int num = this.m_da.Update(this.m_table);
        this.m_table.AcceptChanges();
        return num;
    }

    // Properties
    public object this[string sname]
    {
        get
        {
            return this.m_table.Rows[this.rowindex][sname];
        }
        set
        {
            this.m_table.Rows[this.rowindex][sname] = value;
            object obj2 = new object();
        }
    }

    public int rowcount
    {
        get
        {
            return this.m_table.Rows.Count;
        }
    }

    public int rowindex
    {
        get
        {
            return this.m_rowindex;
        }
        set
        {
            if ((value < this.m_table.Rows.Count) && (value >= 0))
            {
                this.m_rowindex = value;
            }
            else
            {
                this.m_rowindex = -1;
            }
        }
    }

    public DataRowCollection Rows
    {
        get
        {
            return this.m_table.Rows;
        }
    }

 


}





上一篇:ASPnet:自动生成流水订单号/序号/编号
下一篇:没有了
相关评论

图库精选