Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WalleProject.Model.t_commodity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_commodity set ");
            strSql.Append("com_name=@com_name,");
            strSql.Append("com_productDate=@com_productDate,");
            strSql.Append("com_number=@com_number,");
            strSql.Append("com_strageID=@com_strageID,");
            strSql.Append("com_alertNumber=@com_alertNumber,");
            strSql.Append("com_pic_ID=@com_pic_ID,");
            strSql.Append("com_date=@com_date,");
            strSql.Append("com_pri_ID=@com_pri_ID,");
            strSql.Append("com_conversionInt=@com_conversionInt,");
            strSql.Append("com_comc_ID=@com_comc_ID,");
            strSql.Append("com_valid=@com_valid");
            strSql.Append(" where com_ID=@com_ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@com_name",          MySqlDbType.VarChar, 20),
                new MySqlParameter("@com_productDate",   MySqlDbType.Date),
                new MySqlParameter("@com_number",        MySqlDbType.Int32,   10),
                new MySqlParameter("@com_strageID",      MySqlDbType.VarChar, 10),
                new MySqlParameter("@com_alertNumber",   MySqlDbType.Int32,   10),
                new MySqlParameter("@com_pic_ID",        MySqlDbType.Int32,   10),
                new MySqlParameter("@com_date",          MySqlDbType.Date),
                new MySqlParameter("@com_pri_ID",        MySqlDbType.Decimal, 10),
                new MySqlParameter("@com_conversionInt", MySqlDbType.Int32,   10),
                new MySqlParameter("@com_comc_ID",       MySqlDbType.Int32,   10),
                new MySqlParameter("@com_valid",         MySqlDbType.VarChar,  2),
                new MySqlParameter("@com_ID",            MySqlDbType.Int32, 10)
            };
            parameters[0].Value  = model.com_name;
            parameters[1].Value  = model.com_productDate;
            parameters[2].Value  = model.com_number;
            parameters[3].Value  = model.com_strageID;
            parameters[4].Value  = model.com_alertNumber;
            parameters[5].Value  = model.com_pic_ID;
            parameters[6].Value  = model.com_date;
            parameters[7].Value  = model.com_pri_ID;
            parameters[8].Value  = model.com_conversionInt;
            parameters[9].Value  = model.com_comc_ID;
            parameters[10].Value = model.com_valid;
            parameters[11].Value = model.com_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WalleProject.Model.t_commodity DataRowToModel(DataRow row)
 {
     WalleProject.Model.t_commodity model = new WalleProject.Model.t_commodity();
     if (row != null)
     {
         if (row["com_ID"] != null && row["com_ID"].ToString() != "")
         {
             model.com_ID = int.Parse(row["com_ID"].ToString());
         }
         if (row["com_name"] != null)
         {
             model.com_name = row["com_name"].ToString();
         }
         if (row["com_productDate"] != null && row["com_productDate"].ToString() != "")
         {
             model.com_productDate = DateTime.Parse(row["com_productDate"].ToString());
         }
         if (row["com_number"] != null && row["com_number"].ToString() != "")
         {
             model.com_number = int.Parse(row["com_number"].ToString());
         }
         if (row["com_strageID"] != null)
         {
             model.com_strageID = row["com_strageID"].ToString();
         }
         if (row["com_alertNumber"] != null && row["com_alertNumber"].ToString() != "")
         {
             model.com_alertNumber = int.Parse(row["com_alertNumber"].ToString());
         }
         if (row["com_pic_ID"] != null && row["com_pic_ID"].ToString() != "")
         {
             model.com_pic_ID = int.Parse(row["com_pic_ID"].ToString());
         }
         if (row["com_date"] != null && row["com_date"].ToString() != "")
         {
             model.com_date = DateTime.Parse(row["com_date"].ToString());
         }
         if (row["com_pri_ID"] != null && row["com_pri_ID"].ToString() != "")
         {
             model.com_pri_ID = Decimal.Parse(row["com_pri_ID"].ToString());
         }
         if (row["com_conversionInt"] != null && row["com_conversionInt"].ToString() != "")
         {
             model.com_conversionInt = int.Parse(row["com_conversionInt"].ToString());
         }
         if (row["com_comc_ID"] != null && row["com_comc_ID"].ToString() != "")
         {
             model.com_comc_ID = int.Parse(row["com_comc_ID"].ToString());
         }
         if (row["com_valid"] != null)
         {
             model.com_valid = row["com_valid"].ToString();
         }
     }
     return(model);
 }
 private void ShowInfo(int com_ID)
 {
     WalleProject.BLL.t_commodity   bll   = new WalleProject.BLL.t_commodity();
     WalleProject.Model.t_commodity model = bll.GetModel(com_ID);
     this.lblcom_id.Text            = model.com_ID.ToString();
     this.lblcom_name.Text          = model.com_name;
     this.lblcom_productDate.Text   = model.com_productDate.ToString();
     this.lblcom_number.Text        = model.com_number.ToString();
     this.lblcom_strageID.Text      = model.com_strageID;
     this.lblcom_pic_ID.Src         = new BLL.t_picture().GetModel(int.Parse(model.com_pic_ID.ToString())).pic_valid;
     this.lblcom_date.Text          = model.com_date.ToString();
     this.lblcom_pri_ID.Text        = model.com_pri_ID.ToString();
     this.lblcom_conversionInt.Text = Convert.ToString(double.Parse(model.com_pri_ID.ToString()) * 0.8);
     this.lblcom_comc_ID.Text       = new BLL.t_commoditycategory().GetModel(int.Parse(model.com_comc_ID.ToString())).comc_name;
     this.lblcom_valid.Text         = model.com_valid;
     this.lblcom_valid2.Text        = model.com_valid;
 }
Exemplo n.º 4
0
 private void ShowInfo(int com_ID)
 {
     WalleProject.BLL.t_commodity   bll   = new WalleProject.BLL.t_commodity();
     WalleProject.Model.t_commodity model = bll.GetModel(com_ID);
     this.lblcom_ID.Text            = model.com_ID.ToString();
     this.txtcom_name.Text          = model.com_name;
     this.txtcom_productDate.Text   = model.com_productDate.ToString();
     this.txtcom_number.Text        = model.com_number.ToString();
     this.txtcom_strageID.Text      = model.com_strageID;
     this.txtcom_alertNumber.Text   = model.com_alertNumber.ToString();
     this.txtcom_pic_ID.Text        = model.com_pic_ID.ToString();
     this.txtcom_date.Text          = model.com_date.ToString();
     this.txtcom_pri_ID.Text        = model.com_pri_ID.ToString();
     this.txtcom_conversionInt.Text = model.com_conversionInt.ToString();
     this.txtcom_comc_ID.Text       = model.com_comc_ID.ToString();
     this.txtcom_valid.Text         = model.com_valid;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WalleProject.Model.t_commodity GetModel(int com_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select com_ID,com_name,com_productDate,com_number,com_strageID,com_alertNumber,com_pic_ID,com_date,com_pri_ID,com_conversionInt,com_comc_ID,com_valid from t_commodity ");
            strSql.Append(" where com_ID=@com_ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@com_ID", MySqlDbType.Int32)
            };
            parameters[0].Value = com_ID;

            WalleProject.Model.t_commodity model = new WalleProject.Model.t_commodity();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

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

            if (this.txtcom_name.Text.Trim().Length == 0)
            {
                strErr += "商品名不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtcom_productDate.Text))
            {
                strErr += "生产日期格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtcom_number.Text))
            {
                strErr += "商品数量格式错误!\\n";
            }
            if (this.txtcom_strageID.Text.Trim().Length == 0)
            {
                strErr += "货架号不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtcom_alertNumber.Text))
            {
                strErr += "警戒值格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtcom_pic_ID.Text))
            {
                strErr += "图片格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtcom_pri_ID.Text))
            {
                strErr += "二级类别格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtcom_conversionInt.Text))
            {
                strErr += "积分格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtcom_comc_ID.Text))
            {
                strErr += "类别格式错误!\\n";
            }
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   com_name          = this.txtcom_name.Text;
            DateTime com_productDate   = DateTime.Parse(this.txtcom_productDate.Text);
            int      com_number        = int.Parse(this.txtcom_number.Text);
            string   com_strageID      = this.txtcom_strageID.Text;
            int      com_alertNumber   = int.Parse(this.txtcom_alertNumber.Text);
            int      com_pic_ID        = int.Parse(this.txtcom_pic_ID.Text);
            DateTime com_date          = DateTime.Parse(this.txtcom_date.Text);
            int      com_pri_ID        = int.Parse(this.txtcom_pri_ID.Text);
            int      com_conversionInt = int.Parse(this.txtcom_conversionInt.Text);
            int      com_comc_ID       = int.Parse(this.txtcom_comc_ID.Text);
            string   com_valid         = this.txtcom_valid.Text;

            WalleProject.Model.t_commodity model = new WalleProject.Model.t_commodity();
            model.com_name          = com_name;
            model.com_productDate   = com_productDate;
            model.com_number        = com_number;
            model.com_strageID      = com_strageID;
            model.com_alertNumber   = com_alertNumber;
            model.com_pic_ID        = com_pic_ID;
            model.com_date          = com_date;
            model.com_pri_ID        = com_pri_ID;
            model.com_conversionInt = com_conversionInt;
            model.com_comc_ID       = com_comc_ID;
            model.com_valid         = com_valid;

            WalleProject.BLL.t_commodity bll = new WalleProject.BLL.t_commodity();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Exemplo n.º 7
0
        /// <summary>
        /// 得到一个对象实体(两个表)
        /// </summary>
        public WalleProject.Model.t_commodity GetCommodityModel(int com_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from t_commodity inner join t_commoditycategory on t_commodity.com_comc_ID=t_commoditycategory.comc_ID ");
            strSql.Append(" where com_ID=@com_ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@com_ID", MySqlDbType.Int32)
            };
            parameters[0].Value = com_ID;

            WalleProject.Model.t_commodity model = new WalleProject.Model.t_commodity();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row != null)
                {
                    if (row["com_ID"] != null && row["com_ID"].ToString() != "")
                    {
                        model.com_ID = int.Parse(row["com_ID"].ToString());
                    }
                    if (row["com_name"] != null)
                    {
                        model.com_name = row["com_name"].ToString();
                    }
                    if (row["com_productDate"] != null && row["com_productDate"].ToString() != "")
                    {
                        model.com_productDate = DateTime.Parse(row["com_productDate"].ToString());
                    }
                    if (row["com_number"] != null && row["com_number"].ToString() != "")
                    {
                        model.com_number = int.Parse(row["com_number"].ToString());
                    }
                    if (row["com_strageID"] != null)
                    {
                        model.com_strageID = row["com_strageID"].ToString();
                    }
                    if (row["com_alertNumber"] != null && row["com_alertNumber"].ToString() != "")
                    {
                        model.com_alertNumber = int.Parse(row["com_alertNumber"].ToString());
                    }
                    if (row["com_pic_ID"] != null && row["com_pic_ID"].ToString() != "")
                    {
                        model.com_pic_ID = int.Parse(row["com_pic_ID"].ToString());
                    }
                    if (row["com_date"] != null && row["com_date"].ToString() != "")
                    {
                        model.com_date = DateTime.Parse(row["com_date"].ToString());
                    }
                    if (row["com_pri_ID"] != null && row["com_pri_ID"].ToString() != "")
                    {
                        model.com_pri_ID = Decimal.Parse(row["com_pri_ID"].ToString());
                    }
                    if (row["com_conversionInt"] != null && row["com_conversionInt"].ToString() != "")
                    {
                        model.com_conversionInt = int.Parse(row["com_conversionInt"].ToString());
                    }
                    if (row["com_comc_ID"] != null && row["com_comc_ID"].ToString() != "")
                    {
                        model.com_comc_ID = int.Parse(row["com_comc_ID"].ToString());
                    }
                    if (row["com_valid"] != null)
                    {
                        model.com_valid = row["com_valid"].ToString();
                    }
                    if (row["comc_name"] != null)
                    {
                        model.commoditycategory.comc_name = row["comc_name"].ToString();
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }