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

            strSql.Append("update DNSABC_ProductInfo set ");
            strSql.Append("ProductType=@ProductType,");
            strSql.Append("ProductName=@ProductName,");
            strSql.Append("ProductPic=@ProductPic,");
            strSql.Append("ProductDescription=@ProductDescription,");
            strSql.Append("ProductTableName=@ProductTableName,");
            strSql.Append("MONTH=@MONTH,");
            strSql.Append("State=@State,");
            strSql.Append("isOrder=@isOrder,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("CreateTime=@CreateTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductType",        SqlDbType.Int,          4),
                new SqlParameter("@ProductName",        SqlDbType.VarChar,    100),
                new SqlParameter("@ProductPic",         SqlDbType.VarChar,   4000),
                new SqlParameter("@ProductDescription", SqlDbType.VarChar,   8000),
                new SqlParameter("@ProductTableName",   SqlDbType.VarChar,    100),
                new SqlParameter("@MONTH",              SqlDbType.Int,          4),
                new SqlParameter("@State",              SqlDbType.Int,          4),
                new SqlParameter("@isOrder",            SqlDbType.Int,          4),
                new SqlParameter("@Remark",             SqlDbType.VarChar,    500),
                new SqlParameter("@UpdateTime",         SqlDbType.DateTime),
                new SqlParameter("@CreateTime",         SqlDbType.DateTime),
                new SqlParameter("@Id",                 SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.ProductType;
            parameters[1].Value  = model.ProductName;
            parameters[2].Value  = model.ProductPic;
            parameters[3].Value  = model.ProductDescription;
            parameters[4].Value  = model.ProductTableName;
            parameters[5].Value  = model.MONTH;
            parameters[6].Value  = model.State;
            parameters[7].Value  = model.isOrder;
            parameters[8].Value  = model.Remark;
            parameters[9].Value  = model.UpdateTime;
            parameters[10].Value = model.CreateTime;
            parameters[11].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DNSABC.Model.DNSABC_ProductInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into DNSABC_ProductInfo(");
            strSql.Append("ProductType,ProductName,ProductPic,ProductDescription,ProductTableName,MONTH,State,isOrder,Remark,UpdateTime,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@ProductType,@ProductName,@ProductPic,@ProductDescription,@ProductTableName,@MONTH,@State,@isOrder,@Remark,@UpdateTime,@CreateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductType",        SqlDbType.Int,          4),
                new SqlParameter("@ProductName",        SqlDbType.VarChar,    100),
                new SqlParameter("@ProductPic",         SqlDbType.VarChar,   4000),
                new SqlParameter("@ProductDescription", SqlDbType.VarChar,   8000),
                new SqlParameter("@ProductTableName",   SqlDbType.VarChar,    100),
                new SqlParameter("@MONTH",              SqlDbType.Int,          4),
                new SqlParameter("@State",              SqlDbType.Int,          4),
                new SqlParameter("@isOrder",            SqlDbType.Int,          4),
                new SqlParameter("@Remark",             SqlDbType.VarChar,    500),
                new SqlParameter("@UpdateTime",         SqlDbType.DateTime),
                new SqlParameter("@CreateTime",         SqlDbType.DateTime)
            };
            parameters[0].Value  = model.ProductType;
            parameters[1].Value  = model.ProductName;
            parameters[2].Value  = model.ProductPic;
            parameters[3].Value  = model.ProductDescription;
            parameters[4].Value  = model.ProductTableName;
            parameters[5].Value  = model.MONTH;
            parameters[6].Value  = model.State;
            parameters[7].Value  = model.isOrder;
            parameters[8].Value  = model.Remark;
            parameters[9].Value  = model.UpdateTime;
            parameters[10].Value = model.CreateTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #3
0
 private void ShowInfo(int Id)
 {
     DNSABC.BLL.DNSABC_ProductInfo   bll   = new DNSABC.BLL.DNSABC_ProductInfo();
     DNSABC.Model.DNSABC_ProductInfo model = bll.GetModel(Id);
     this.lblId.Text                 = model.Id.ToString();
     this.txtProductType.Text        = model.ProductType.ToString();
     this.txtProductName.Text        = model.ProductName;
     this.txtProductPic.Text         = model.ProductPic;
     this.txtProductDescription.Text = model.ProductDescription;
     this.txtProductTableName.Text   = model.ProductTableName;
     this.txtMONTH.Text              = model.MONTH.ToString();
     this.txtState.Text              = model.State.ToString();
     this.txtisOrder.Text            = model.isOrder.ToString();
     this.txtRemark.Text             = model.Remark;
     this.txtUpdateTime.Text         = model.UpdateTime.ToString();
     this.txtCreateTime.Text         = model.CreateTime.ToString();
 }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DNSABC.Model.DNSABC_ProductInfo GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,ProductType,ProductName,ProductPic,ProductDescription,ProductTableName,MONTH,State,isOrder,Remark,UpdateTime,CreateTime from DNSABC_ProductInfo ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductType"] != null && ds.Tables[0].Rows[0]["ProductType"].ToString() != "")
                {
                    model.ProductType = int.Parse(ds.Tables[0].Rows[0]["ProductType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductName"] != null && ds.Tables[0].Rows[0]["ProductName"].ToString() != "")
                {
                    model.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductPic"] != null && ds.Tables[0].Rows[0]["ProductPic"].ToString() != "")
                {
                    model.ProductPic = ds.Tables[0].Rows[0]["ProductPic"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductDescription"] != null && ds.Tables[0].Rows[0]["ProductDescription"].ToString() != "")
                {
                    model.ProductDescription = ds.Tables[0].Rows[0]["ProductDescription"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductTableName"] != null && ds.Tables[0].Rows[0]["ProductTableName"].ToString() != "")
                {
                    model.ProductTableName = ds.Tables[0].Rows[0]["ProductTableName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MONTH"] != null && ds.Tables[0].Rows[0]["MONTH"].ToString() != "")
                {
                    model.MONTH = int.Parse(ds.Tables[0].Rows[0]["MONTH"].ToString());
                }
                if (ds.Tables[0].Rows[0]["State"] != null && ds.Tables[0].Rows[0]["State"].ToString() != "")
                {
                    model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString());
                }
                if (ds.Tables[0].Rows[0]["isOrder"] != null && ds.Tables[0].Rows[0]["isOrder"].ToString() != "")
                {
                    model.isOrder = int.Parse(ds.Tables[0].Rows[0]["isOrder"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UpdateTime"] != null && ds.Tables[0].Rows[0]["UpdateTime"].ToString() != "")
                {
                    model.UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtProductType.Text))
            {
                strErr += "产品类型 1格式错误!\\n";
            }
            if (this.txtProductName.Text.Trim().Length == 0)
            {
                strErr += "名称不能为空!\\n";
            }
            if (this.txtProductPic.Text.Trim().Length == 0)
            {
                strErr += "产品图片不能为空!\\n";
            }
            if (this.txtProductDescription.Text.Trim().Length == 0)
            {
                strErr += "产品描述 编辑器区域不能为空!\\n";
            }
            if (this.txtProductTableName.Text.Trim().Length == 0)
            {
                strErr += "模型的表格名称 Product不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtMONTH.Text))
            {
                strErr += "月数 产品默认订购时限格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtState.Text))
            {
                strErr += "产品状态 0为停用格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtisOrder.Text))
            {
                strErr += "权重格式错误!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "备注不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtUpdateTime.Text))
            {
                strErr += "更新时间格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtCreateTime.Text))
            {
                strErr += "创建时间格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      Id                 = int.Parse(this.lblId.Text);
            int      ProductType        = int.Parse(this.txtProductType.Text);
            string   ProductName        = this.txtProductName.Text;
            string   ProductPic         = this.txtProductPic.Text;
            string   ProductDescription = this.txtProductDescription.Text;
            string   ProductTableName   = this.txtProductTableName.Text;
            int      MONTH              = int.Parse(this.txtMONTH.Text);
            int      State              = int.Parse(this.txtState.Text);
            int      isOrder            = int.Parse(this.txtisOrder.Text);
            string   Remark             = this.txtRemark.Text;
            DateTime UpdateTime         = DateTime.Parse(this.txtUpdateTime.Text);
            DateTime CreateTime         = DateTime.Parse(this.txtCreateTime.Text);


            DNSABC.Model.DNSABC_ProductInfo model = new DNSABC.Model.DNSABC_ProductInfo();
            model.Id                 = Id;
            model.ProductType        = ProductType;
            model.ProductName        = ProductName;
            model.ProductPic         = ProductPic;
            model.ProductDescription = ProductDescription;
            model.ProductTableName   = ProductTableName;
            model.MONTH              = MONTH;
            model.State              = State;
            model.isOrder            = isOrder;
            model.Remark             = Remark;
            model.UpdateTime         = UpdateTime;
            model.CreateTime         = CreateTime;

            DNSABC.BLL.DNSABC_ProductInfo bll = new DNSABC.BLL.DNSABC_ProductInfo();
            bll.Update(model);
            ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }