예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.GridViewColumnInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update GridViewColumnInfo set ");
            strSql.Append("ColumnID=@ColumnID,");
            strSql.Append("HeaderText=@HeaderText,");
            strSql.Append("DataFormat=@DataFormat,");
            strSql.Append("SortExpression=@SortExpression,");
            strSql.Append("IsEdit=@IsEdit,");
            strSql.Append("IsShow=@IsShow,");
            strSql.Append("OrderNum=@OrderNum,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ColumnID",       SqlDbType.Int,       4),
                new SqlParameter("@HeaderText",     SqlDbType.VarChar, 100),
                new SqlParameter("@DataFormat",     SqlDbType.VarChar, 100),
                new SqlParameter("@SortExpression", 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("@Id",             SqlDbType.Int,       4),
                new SqlParameter("@GridViewTypeID", SqlDbType.Int,       4),
                new SqlParameter("@DataField",      SqlDbType.VarChar, 100),
                new SqlParameter("@OperatorID",     SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.ColumnID;
            parameters[1].Value  = model.HeaderText;
            parameters[2].Value  = model.DataFormat;
            parameters[3].Value  = model.SortExpression;
            parameters[4].Value  = model.IsEdit;
            parameters[5].Value  = model.IsShow;
            parameters[6].Value  = model.OrderNum;
            parameters[7].Value  = model.Remark;
            parameters[8].Value  = model.Id;
            parameters[9].Value  = model.GridViewTypeID;
            parameters[10].Value = model.DataField;
            parameters[11].Value = model.OperatorID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 private void ShowInfo(int Id)
 {
     WebDemo.BLL.WebDemo.GridViewColumnInfo   bll   = new WebDemo.BLL.WebDemo.GridViewColumnInfo();
     WebDemo.Model.WebDemo.GridViewColumnInfo model = bll.GetModel(Id);
     this.lblId.Text             = model.Id.ToString();
     this.lblGridViewTypeID.Text = model.GridViewTypeID.ToString();
     this.lblColumnID.Text       = model.ColumnID.ToString();
     this.lblDataField.Text      = model.DataField;
     this.lblHeaderText.Text     = model.HeaderText;
     this.lblDataFormat.Text     = model.DataFormat;
     this.lblSortExpression.Text = model.SortExpression;
     this.lblIsEdit.Text         = model.IsEdit?"是":"否";
     this.lblIsShow.Text         = model.IsShow?"是":"否";
     this.lblOrderNum.Text       = model.OrderNum.ToString();
     this.lblOperatorID.Text     = model.OperatorID.ToString();
     this.lblRemark.Text         = model.Remark;
 }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebDemo.Model.WebDemo.GridViewColumnInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into GridViewColumnInfo(");
            strSql.Append("GridViewTypeID,ColumnID,DataField,HeaderText,DataFormat,SortExpression,IsEdit,IsShow,OrderNum,OperatorID,Remark)");
            strSql.Append(" values (");
            strSql.Append("@GridViewTypeID,@ColumnID,@DataField,@HeaderText,@DataFormat,@SortExpression,@IsEdit,@IsShow,@OrderNum,@OperatorID,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GridViewTypeID", SqlDbType.Int,       4),
                new SqlParameter("@ColumnID",       SqlDbType.Int,       4),
                new SqlParameter("@DataField",      SqlDbType.VarChar, 100),
                new SqlParameter("@HeaderText",     SqlDbType.VarChar, 100),
                new SqlParameter("@DataFormat",     SqlDbType.VarChar, 100),
                new SqlParameter("@SortExpression", SqlDbType.VarChar, 100),
                new SqlParameter("@IsEdit",         SqlDbType.Bit,       1),
                new SqlParameter("@IsShow",         SqlDbType.Bit,       1),
                new SqlParameter("@OrderNum",       SqlDbType.Int,       4),
                new SqlParameter("@OperatorID",     SqlDbType.Int,       4),
                new SqlParameter("@Remark",         SqlDbType.VarChar, 200)
            };
            parameters[0].Value  = model.GridViewTypeID;
            parameters[1].Value  = model.ColumnID;
            parameters[2].Value  = model.DataField;
            parameters[3].Value  = model.HeaderText;
            parameters[4].Value  = model.DataFormat;
            parameters[5].Value  = model.SortExpression;
            parameters[6].Value  = model.IsEdit;
            parameters[7].Value  = model.IsShow;
            parameters[8].Value  = model.OrderNum;
            parameters[9].Value  = model.OperatorID;
            parameters[10].Value = model.Remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
 private void ShowInfo(int Id)
 {
     WebDemo.BLL.WebDemo.GridViewColumnInfo   bll   = new WebDemo.BLL.WebDemo.GridViewColumnInfo();
     WebDemo.Model.WebDemo.GridViewColumnInfo model = bll.GetModel(Id);
     this.lblId.Text             = model.Id.ToString();
     this.lblGridViewTypeID.Text = model.GridViewTypeID.ToString();
     this.txtColumnID.Text       = model.ColumnID.ToString();
     this.lblDataField.Text      = model.DataField;
     this.txtHeaderText.Text     = model.HeaderText;
     this.txtDataFormat.Text     = model.DataFormat;
     this.txtSortExpression.Text = model.SortExpression;
     this.chkIsEdit.Checked      = model.IsEdit;
     this.chkIsShow.Checked      = model.IsShow;
     this.txtOrderNum.Text       = model.OrderNum.ToString();
     this.lblOperatorID.Text     = model.OperatorID.ToString();
     this.txtRemark.Text         = model.Remark;
 }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.GridViewColumnInfo GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,GridViewTypeID,ColumnID,DataField,HeaderText,DataFormat,SortExpression,IsEdit,IsShow,OrderNum,OperatorID,Remark from GridViewColumnInfo ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtGridViewTypeID.Text))
            {
                strErr += "GridViewTypeID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtColumnID.Text))
            {
                strErr += "ColumnID格式错误!\\n";
            }
            if (this.txtDataField.Text.Trim().Length == 0)
            {
                strErr += "DataField不能为空!\\n";
            }
            if (this.txtHeaderText.Text.Trim().Length == 0)
            {
                strErr += "HeaderText不能为空!\\n";
            }
            if (this.txtDataFormat.Text.Trim().Length == 0)
            {
                strErr += "DataFormat不能为空!\\n";
            }
            if (this.txtSortExpression.Text.Trim().Length == 0)
            {
                strErr += "SortExpression不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtOrderNum.Text))
            {
                strErr += "OrderNum格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtOperatorID.Text))
            {
                strErr += "OperatorID格式错误!\\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);
            int    ColumnID       = int.Parse(this.txtColumnID.Text);
            string DataField      = this.txtDataField.Text;
            string HeaderText     = this.txtHeaderText.Text;
            string DataFormat     = this.txtDataFormat.Text;
            string SortExpression = this.txtSortExpression.Text;
            bool   IsEdit         = this.chkIsEdit.Checked;
            bool   IsShow         = this.chkIsShow.Checked;
            int    OrderNum       = int.Parse(this.txtOrderNum.Text);
            int    OperatorID     = int.Parse(this.txtOperatorID.Text);
            string Remark         = this.txtRemark.Text;

            WebDemo.Model.WebDemo.GridViewColumnInfo model = new WebDemo.Model.WebDemo.GridViewColumnInfo();
            model.GridViewTypeID = GridViewTypeID;
            model.ColumnID       = ColumnID;
            model.DataField      = DataField;
            model.HeaderText     = HeaderText;
            model.DataFormat     = DataFormat;
            model.SortExpression = SortExpression;
            model.IsEdit         = IsEdit;
            model.IsShow         = IsShow;
            model.OrderNum       = OrderNum;
            model.OperatorID     = OperatorID;
            model.Remark         = Remark;

            WebDemo.BLL.WebDemo.GridViewColumnInfo bll = new WebDemo.BLL.WebDemo.GridViewColumnInfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
예제 #7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.GridViewColumnInfo DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.GridViewColumnInfo model = new WebDemo.Model.WebDemo.GridViewColumnInfo();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["GridViewTypeID"] != null && row["GridViewTypeID"].ToString() != "")
         {
             model.GridViewTypeID = int.Parse(row["GridViewTypeID"].ToString());
         }
         if (row["ColumnID"] != null && row["ColumnID"].ToString() != "")
         {
             model.ColumnID = int.Parse(row["ColumnID"].ToString());
         }
         if (row["DataField"] != null)
         {
             model.DataField = row["DataField"].ToString();
         }
         if (row["HeaderText"] != null)
         {
             model.HeaderText = row["HeaderText"].ToString();
         }
         if (row["DataFormat"] != null)
         {
             model.DataFormat = row["DataFormat"].ToString();
         }
         if (row["SortExpression"] != null)
         {
             model.SortExpression = row["SortExpression"].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["OperatorID"] != null && row["OperatorID"].ToString() != "")
         {
             model.OperatorID = int.Parse(row["OperatorID"].ToString());
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }