예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TSM.Model.pms_Dept_Info model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into pms_Dept_Info(");
            strSql.Append("DeptName)");
            strSql.Append(" values (");
            strSql.Append("@DeptName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DeptName", SqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.DeptName;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TSM.Model.pms_Dept_Info GetModel(int DeptInfoID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 DeptInfoID,DeptName from pms_Dept_Info ");
            strSql.Append(" where DeptInfoID=@DeptInfoID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DeptInfoID", SqlDbType.Int, 4)
            };
            parameters[0].Value = DeptInfoID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["DeptInfoID"].ToString() != "")
                {
                    model.DeptInfoID = int.Parse(ds.Tables[0].Rows[0]["DeptInfoID"].ToString());
                }
                model.DeptName = ds.Tables[0].Rows[0]["DeptName"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TSM.Model.pms_Dept_Info model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update pms_Dept_Info set ");
            strSql.Append("DeptName=@DeptName");
            strSql.Append(" where DeptInfoID=@DeptInfoID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DeptInfoID", SqlDbType.Int,     4),
                new SqlParameter("@DeptName",   SqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.DeptInfoID;
            parameters[1].Value = model.DeptName;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }