コード例 #1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(MobileSoft.Model.Sys.Tb_Sys_Department model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@DepCode",   SqlDbType.NVarChar,   20),
                new SqlParameter("@DepName",   SqlDbType.NVarChar,   50),
                new SqlParameter("@Principal", SqlDbType.NVarChar,   20),
                new SqlParameter("@Memo",      SqlDbType.NVarChar, 1000),
                new SqlParameter("@CommID",    SqlDbType.Int,         4),
                new SqlParameter("@IsDelete",  SqlDbType.SmallInt,    2),
                new SqlParameter("@Sort",      SqlDbType.Int,         4),
                new SqlParameter("@IsHide",    SqlDbType.SmallInt, 2)
            };
            parameters[0].Value = model.DepCode;
            parameters[1].Value = model.DepName;
            parameters[2].Value = model.Principal;
            parameters[3].Value = model.Memo;
            parameters[4].Value = model.CommID;
            parameters[5].Value = model.IsDelete;
            parameters[6].Value = model.Sort;
            parameters[7].Value = model.IsHide;

            DbHelperSQL.RunProcedure("Proc_Tb_Sys_Department_Update", parameters, out rowsAffected);
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MobileSoft.Model.Sys.Tb_Sys_Department GetModel(string DepCode)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@DepCode", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = DepCode;

            MobileSoft.Model.Sys.Tb_Sys_Department model = new MobileSoft.Model.Sys.Tb_Sys_Department();
            DataSet ds = DbHelperSQL.RunProcedure("Proc_Tb_Sys_Department_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.DepCode   = ds.Tables[0].Rows[0]["DepCode"].ToString();
                model.DepName   = ds.Tables[0].Rows[0]["DepName"].ToString();
                model.Principal = ds.Tables[0].Rows[0]["Principal"].ToString();
                model.Memo      = ds.Tables[0].Rows[0]["Memo"].ToString();
                if (ds.Tables[0].Rows[0]["CommID"].ToString() != "")
                {
                    model.CommID = int.Parse(ds.Tables[0].Rows[0]["CommID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsDelete"].ToString() != "")
                {
                    model.IsDelete = int.Parse(ds.Tables[0].Rows[0]["IsDelete"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                {
                    model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsHide"].ToString() != "")
                {
                    model.IsHide = int.Parse(ds.Tables[0].Rows[0]["IsHide"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }