Exemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <GZS.Model.Menu.SysRoleTab> DataTableToList(DataTable dt)
        {
            List <GZS.Model.Menu.SysRoleTab> modelList = new List <GZS.Model.Menu.SysRoleTab>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                GZS.Model.Menu.SysRoleTab model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new GZS.Model.Menu.SysRoleTab();
                    if (dt.Rows[n]["SRoleID"].ToString() != "")
                    {
                        model.SRoleID = int.Parse(dt.Rows[n]["SRoleID"].ToString());
                    }
                    model.SRName  = dt.Rows[n]["SRName"].ToString();
                    model.SRDoc   = dt.Rows[n]["SRDoc"].ToString();
                    model.SysCode = dt.Rows[n]["SysCode"].ToString();
                    if (dt.Rows[n]["SRDate"].ToString() != "")
                    {
                        model.SRDate = DateTime.Parse(dt.Rows[n]["SRDate"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(GZS.Model.Menu.SysRoleTab model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SysRoleTab set ");
            strSql.Append("SRName=@SRName,");
            strSql.Append("SRDoc=@SRDoc,");
            strSql.Append("SysCode=@SysCode,");
            strSql.Append("SRDate=@SRDate");
            strSql.Append(" where SRoleID=@SRoleID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SRoleID", SqlDbType.Int,       4),
                new SqlParameter("@SRName",  SqlDbType.VarChar, 100),
                new SqlParameter("@SRDoc",   SqlDbType.VarChar, 200),
                new SqlParameter("@SysCode", SqlDbType.VarChar, 100),
                new SqlParameter("@SRDate",  SqlDbType.DateTime)
            };
            parameters[0].Value = model.SRoleID;
            parameters[1].Value = model.SRName;
            parameters[2].Value = model.SRDoc;
            parameters[3].Value = model.SysCode;
            parameters[4].Value = model.SRDate;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(GZS.Model.Menu.SysRoleTab model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SysRoleTab(");
            strSql.Append("SRName,SRDoc,SysCode,SRDate)");
            strSql.Append(" values (");
            strSql.Append("@SRName,@SRDoc,@SysCode,@SRDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SRName",  SqlDbType.VarChar, 100),
                new SqlParameter("@SRDoc",   SqlDbType.VarChar, 200),
                new SqlParameter("@SysCode", SqlDbType.VarChar, 100),
                new SqlParameter("@SRDate",  SqlDbType.DateTime)
            };
            parameters[0].Value = model.SRName;
            parameters[1].Value = model.SRDoc;
            parameters[2].Value = model.SysCode;
            parameters[3].Value = model.SRDate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public GZS.Model.Menu.SysRoleTab GetModel(int SRoleID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 SRoleID,SRName,SRDoc,SysCode,SRDate from SysRoleTab ");
            strSql.Append(" where SRoleID=@SRoleID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SRoleID", SqlDbType.Int, 4)
            };
            parameters[0].Value = SRoleID;

            GZS.Model.Menu.SysRoleTab model = new GZS.Model.Menu.SysRoleTab();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SRoleID"].ToString() != "")
                {
                    model.SRoleID = int.Parse(ds.Tables[0].Rows[0]["SRoleID"].ToString());
                }
                model.SRName  = ds.Tables[0].Rows[0]["SRName"].ToString();
                model.SRDoc   = ds.Tables[0].Rows[0]["SRDoc"].ToString();
                model.SysCode = ds.Tables[0].Rows[0]["SysCode"].ToString();
                if (ds.Tables[0].Rows[0]["SRDate"].ToString() != "")
                {
                    model.SRDate = DateTime.Parse(ds.Tables[0].Rows[0]["SRDate"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(GZS.Model.Menu.SysRoleTab model)
 {
     dal.Update(model);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(GZS.Model.Menu.SysRoleTab model)
 {
     return(dal.Add(model));
 }