コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WSS.Model.Department model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Department set ");
            strSql.Append("F_ParentID=@F_ParentID,");
            strSql.Append("F_DepartName=@F_DepartName");
            strSql.Append(" where F_DepartID=@F_DepartID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_ParentID",   SqlDbType.Int,    4),
                new SqlParameter("@F_DepartName", SqlDbType.NChar, 10),
                new SqlParameter("@F_DepartID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.F_ParentID;
            parameters[1].Value = model.F_DepartName;
            parameters[2].Value = model.F_DepartID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WSS.Model.Department model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Department(");
            strSql.Append("F_ParentID,F_DepartName)");
            strSql.Append(" values (");
            strSql.Append("@F_ParentID,@F_DepartName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_ParentID",   SqlDbType.Int,   4),
                new SqlParameter("@F_DepartName", SqlDbType.NChar, 10)
            };
            parameters[0].Value = model.F_ParentID;
            parameters[1].Value = model.F_DepartName;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtF_ParentID.Text))
            {
                strErr += "父编号格式错误!\\n";
            }
            if (this.txtF_DepartName.Text.Trim().Length == 0)
            {
                strErr += "部门名不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    F_DepartID   = int.Parse(this.lblF_DepartID.Text);
            int    F_ParentID   = int.Parse(this.txtF_ParentID.Text);
            string F_DepartName = this.txtF_DepartName.Text;


            WSS.Model.Department model = new WSS.Model.Department();
            model.F_DepartID   = F_DepartID;
            model.F_ParentID   = F_ParentID;
            model.F_DepartName = F_DepartName;

            WSS.BLL.Department bll = new WSS.BLL.Department();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
コード例 #4
0
 private void ShowInfo(int F_DepartID)
 {
     WSS.BLL.Department   bll   = new WSS.BLL.Department();
     WSS.Model.Department model = bll.GetModel(F_DepartID);
     this.lblF_DepartID.Text   = model.F_DepartID.ToString();
     this.lblF_ParentID.Text   = model.F_ParentID.ToString();
     this.lblF_DepartName.Text = model.F_DepartName;
 }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WSS.Model.Department GetModel(int F_DepartID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 F_DepartID,F_ParentID,F_DepartName from T_Department ");
            strSql.Append(" where F_DepartID=@F_DepartID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_DepartID", SqlDbType.Int, 4)
            };
            parameters[0].Value = F_DepartID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["F_DepartID"].ToString() != "")
                {
                    model.F_DepartID = int.Parse(ds.Tables[0].Rows[0]["F_DepartID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_ParentID"].ToString() != "")
                {
                    model.F_ParentID = int.Parse(ds.Tables[0].Rows[0]["F_ParentID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_DepartName"] != null)
                {
                    model.F_DepartName = ds.Tables[0].Rows[0]["F_DepartName"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }