Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(IPSP.Model.T_Department model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Department(");
            strSql.Append("s_Name,s_Description,s_DataRight,s_DempCode)");
            strSql.Append(" values (");
            strSql.Append("@s_Name,@s_Description,@s_DataRight,@s_DempCode)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_Name",        SqlDbType.NVarChar,  50),
                new SqlParameter("@s_Description", SqlDbType.NVarChar, 500),
                new SqlParameter("@s_DataRight",   SqlDbType.NVarChar, 100),
                new SqlParameter("@s_DempCode",    SqlDbType.NVarChar, 4)
            };
            parameters[0].Value = model.s_Name;
            parameters[1].Value = model.s_Description;
            parameters[2].Value = model.s_DataRight;
            parameters[3].Value = model.s_DempCode;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public IPSP.Model.T_Department DataRowToModel(DataRow row)
 {
     IPSP.Model.T_Department model = new IPSP.Model.T_Department();
     if (row != null)
     {
         if (row["n_ID"] != null && row["n_ID"].ToString() != "")
         {
             model.n_ID = int.Parse(row["n_ID"].ToString());
         }
         if (row["s_Name"] != null)
         {
             model.s_Name = row["s_Name"].ToString();
         }
         if (row["s_Description"] != null)
         {
             model.s_Description = row["s_Description"].ToString();
         }
         if (row["s_DataRight"] != null)
         {
             model.s_DataRight = row["s_DataRight"].ToString();
         }
         if (row["s_DempCode"] != null)
         {
             model.s_DempCode = row["s_DempCode"].ToString();
         }
     }
     return(model);
 }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(IPSP.Model.T_Department model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Department set ");
            strSql.Append("s_Name=@s_Name,");
            strSql.Append("s_Description=@s_Description,");
            strSql.Append("s_DataRight=@s_DataRight,");
            strSql.Append("s_DempCode=@s_DempCode");
            strSql.Append(" where n_ID=@n_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_Name",        SqlDbType.NVarChar,  50),
                new SqlParameter("@s_Description", SqlDbType.NVarChar, 500),
                new SqlParameter("@s_DataRight",   SqlDbType.NVarChar, 100),
                new SqlParameter("@s_DempCode",    SqlDbType.NVarChar,   4),
                new SqlParameter("@n_ID",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.s_Name;
            parameters[1].Value = model.s_Description;
            parameters[2].Value = model.s_DataRight;
            parameters[3].Value = model.s_DempCode;
            parameters[4].Value = model.n_ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public IPSP.Model.T_Department GetModel(int n_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 n_ID,s_Name,s_Description,s_DataRight,s_DempCode from T_Department ");
            strSql.Append(" where n_ID=@n_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@n_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = n_ID;

            IPSP.Model.T_Department model = new IPSP.Model.T_Department();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(IPSP.Model.T_Department model)
 {
     return(dal.Update(model));
 }
Beispiel #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(IPSP.Model.T_Department model)
 {
     return(dal.Add(model));
 }