Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebDemo.Model.WebDemo.GridViewType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into GridViewType(");
            strSql.Append("GridViewTypeID,GridViewTypeName,IsEdit,IsShow,OrderNum,Remark)");
            strSql.Append(" values (");
            strSql.Append("@GridViewTypeID,@GridViewTypeName,@IsEdit,@IsShow,@OrderNum,@Remark)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GridViewTypeID",   SqlDbType.Int,       4),
                new SqlParameter("@GridViewTypeName", SqlDbType.VarChar, 100),
                new SqlParameter("@IsEdit",           SqlDbType.Bit,       1),
                new SqlParameter("@IsShow",           SqlDbType.Bit,       1),
                new SqlParameter("@OrderNum",         SqlDbType.Int,       4),
                new SqlParameter("@Remark",           SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.GridViewTypeID;
            parameters[1].Value = model.GridViewTypeName;
            parameters[2].Value = model.IsEdit;
            parameters[3].Value = model.IsShow;
            parameters[4].Value = model.OrderNum;
            parameters[5].Value = model.Remark;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 private void ShowInfo(int GridViewTypeID)
 {
     WebDemo.BLL.WebDemo.GridViewType   bll   = new WebDemo.BLL.WebDemo.GridViewType();
     WebDemo.Model.WebDemo.GridViewType model = bll.GetModel(GridViewTypeID);
     this.lblGridViewTypeID.Text   = model.GridViewTypeID.ToString();
     this.lblGridViewTypeName.Text = model.GridViewTypeName;
     this.lblIsEdit.Text           = model.IsEdit?"是":"否";
     this.lblIsShow.Text           = model.IsShow?"是":"否";
     this.lblOrderNum.Text         = model.OrderNum.ToString();
     this.lblRemark.Text           = model.Remark;
 }
Esempio n. 3
0
 private void ShowInfo(int GridViewTypeID)
 {
     WebDemo.BLL.WebDemo.GridViewType   bll   = new WebDemo.BLL.WebDemo.GridViewType();
     WebDemo.Model.WebDemo.GridViewType model = bll.GetModel(GridViewTypeID);
     this.lblGridViewTypeID.Text   = model.GridViewTypeID.ToString();
     this.txtGridViewTypeName.Text = model.GridViewTypeName;
     this.chkIsEdit.Checked        = model.IsEdit;
     this.chkIsShow.Checked        = model.IsShow;
     this.txtOrderNum.Text         = model.OrderNum.ToString();
     this.txtRemark.Text           = model.Remark;
 }
Esempio n. 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.GridViewType DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.GridViewType model = new WebDemo.Model.WebDemo.GridViewType();
     if (row != null)
     {
         if (row["GridViewTypeID"] != null && row["GridViewTypeID"].ToString() != "")
         {
             model.GridViewTypeID = int.Parse(row["GridViewTypeID"].ToString());
         }
         if (row["GridViewTypeName"] != null)
         {
             model.GridViewTypeName = row["GridViewTypeName"].ToString();
         }
         if (row["IsEdit"] != null && row["IsEdit"].ToString() != "")
         {
             if ((row["IsEdit"].ToString() == "1") || (row["IsEdit"].ToString().ToLower() == "true"))
             {
                 model.IsEdit = true;
             }
             else
             {
                 model.IsEdit = false;
             }
         }
         if (row["IsShow"] != null && row["IsShow"].ToString() != "")
         {
             if ((row["IsShow"].ToString() == "1") || (row["IsShow"].ToString().ToLower() == "true"))
             {
                 model.IsShow = true;
             }
             else
             {
                 model.IsShow = false;
             }
         }
         if (row["OrderNum"] != null && row["OrderNum"].ToString() != "")
         {
             model.OrderNum = int.Parse(row["OrderNum"].ToString());
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }
Esempio n. 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtGridViewTypeID.Text))
            {
                strErr += "GridViewTypeID格式错误!\\n";
            }
            if (this.txtGridViewTypeName.Text.Trim().Length == 0)
            {
                strErr += "GridViewTypeName不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtOrderNum.Text))
            {
                strErr += "OrderNum格式错误!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "Remark不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    GridViewTypeID   = int.Parse(this.txtGridViewTypeID.Text);
            string GridViewTypeName = this.txtGridViewTypeName.Text;
            bool   IsEdit           = this.chkIsEdit.Checked;
            bool   IsShow           = this.chkIsShow.Checked;
            int    OrderNum         = int.Parse(this.txtOrderNum.Text);
            string Remark           = this.txtRemark.Text;

            WebDemo.Model.WebDemo.GridViewType model = new WebDemo.Model.WebDemo.GridViewType();
            model.GridViewTypeID   = GridViewTypeID;
            model.GridViewTypeName = GridViewTypeName;
            model.IsEdit           = IsEdit;
            model.IsShow           = IsShow;
            model.OrderNum         = OrderNum;
            model.Remark           = Remark;

            WebDemo.BLL.WebDemo.GridViewType bll = new WebDemo.BLL.WebDemo.GridViewType();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Esempio n. 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.GridViewType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update GridViewType set ");
            strSql.Append("GridViewTypeName=@GridViewTypeName,");
            strSql.Append("IsEdit=@IsEdit,");
            strSql.Append("IsShow=@IsShow,");
            strSql.Append("OrderNum=@OrderNum,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where GridViewTypeID=@GridViewTypeID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GridViewTypeName", SqlDbType.VarChar, 100),
                new SqlParameter("@IsEdit",           SqlDbType.Bit,       1),
                new SqlParameter("@IsShow",           SqlDbType.Bit,       1),
                new SqlParameter("@OrderNum",         SqlDbType.Int,       4),
                new SqlParameter("@Remark",           SqlDbType.VarChar, 200),
                new SqlParameter("@GridViewTypeID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.GridViewTypeName;
            parameters[1].Value = model.IsEdit;
            parameters[2].Value = model.IsShow;
            parameters[3].Value = model.OrderNum;
            parameters[4].Value = model.Remark;
            parameters[5].Value = model.GridViewTypeID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.GridViewType GetModel(int GridViewTypeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 GridViewTypeID,GridViewTypeName,IsEdit,IsShow,OrderNum,Remark from GridViewType ");
            strSql.Append(" where GridViewTypeID=@GridViewTypeID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GridViewTypeID", SqlDbType.Int, 4)
            };
            parameters[0].Value = GridViewTypeID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }