Exemple #1
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(CateName.Text))
            {
                MessageBox.Show("价格种类名称不能为空。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (UsePrice1.Checked && (string.IsNullOrEmpty(Price1Name.Text) || string.IsNullOrEmpty(Price1Val.Text)))
            {
                MessageBox.Show("价格1已经启用,价格名称与值必须填写。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (UsePrice2.Checked && (string.IsNullOrEmpty(Price2Name.Text) || string.IsNullOrEmpty(Price2Val.Text)))
            {
                MessageBox.Show("价格2已经启用,价格名称与值必须填写。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (UsePrice3.Checked && (string.IsNullOrEmpty(Price3Name.Text) || string.IsNullOrEmpty(Price3Val.Text)))
            {
                MessageBox.Show("价格3已经启用,价格名称与值必须填写。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (UsePrice4.Checked && (string.IsNullOrEmpty(Price4Name.Text) || string.IsNullOrEmpty(Price4Val.Text)))
            {
                MessageBox.Show("价格4已经启用,价格名称与值必须填写。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (UsePrice5.Checked && (string.IsNullOrEmpty(Price5Name.Text) || string.IsNullOrEmpty(Price5Val.Text)))
            {
                MessageBox.Show("价格5已经启用,价格名称与值必须填写。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (this.Tag == null)
            {
                UpdatePriceCate = new PriceCate();
            }
            UpdatePriceCate.CateName = this.CateName.Text;
            UpdatePriceCate.UsePrice1 = this.UsePrice1.Checked;
            UpdatePriceCate.Price1Name = this.Price1Name.Text;
            UpdatePriceCate.Price1Val = Convert.ToDouble(this.Price1Val.Text);

            UpdatePriceCate.UsePrice2 = this.UsePrice2.Checked;
            UpdatePriceCate.Price2Name = this.Price2Name.Text;
            UpdatePriceCate.Price2Val = Convert.ToDouble(this.Price2Val.Text);

            UpdatePriceCate.UsePrice3 = this.UsePrice3.Checked;
            UpdatePriceCate.Price3Name = this.Price3Name.Text;
            UpdatePriceCate.Price3Val = Convert.ToDouble(this.Price3Val.Text);

            UpdatePriceCate.UsePrice4 = this.UsePrice4.Checked;
            UpdatePriceCate.Price4Name = this.Price4Name.Text;
            UpdatePriceCate.Price4Val = Convert.ToDouble(this.Price4Val.Text);

            UpdatePriceCate.UsePrice5 = this.UsePrice5.Checked;
            UpdatePriceCate.Price5Name = this.Price5Name.Text;
            UpdatePriceCate.Price5Val = Convert.ToDouble(this.Price5Val.Text);
            UpdatePriceCate.Status = "A";
            manager.InsertOrUpdatePriceCate(UpdatePriceCate);
            this.Close();
        }
Exemple #2
0
 private void LoadUpdatePriceCate(PriceCate obj)
 {
     if (obj == null) return;
     this.Tag = obj;
     this.CateName.Text = obj.CateName;
     this.UsePrice1.Checked = obj.UsePrice1;
     this.Price1Name.Text = obj.Price1Name;
     if (obj.Price1Val > 0)
     {
         this.Price1Val.Text = obj.Price1Val.ToString("#,##0.00");
     }
     this.UsePrice2.Checked = obj.UsePrice2;
     this.Price2Name.Text = obj.Price2Name;
     if (obj.Price2Val > 0)
     {
         this.Price2Val.Text = obj.Price2Val.ToString("#,##0.00");
     }
     this.UsePrice3.Checked = obj.UsePrice3;
     this.Price3Name.Text = obj.Price3Name;
     if (obj.Price3Val > 0)
     {
         this.Price3Val.Text = obj.Price3Val.ToString("#,##0.00");
     }
     this.UsePrice4.Checked = obj.UsePrice4;
     this.Price4Name.Text = obj.Price4Name;
     if (obj.Price4Val > 0)
     {
         this.Price4Val.Text = obj.Price4Val.ToString("#,##0.00");
     }
     this.UsePrice5.Checked = obj.UsePrice5;
     this.Price5Name.Text = obj.Price5Name;
     if (obj.Price5Val > 0)
     {
         this.Price5Val.Text = obj.Price5Val.ToString("#,##0.00");
     }
 }
Exemple #3
0
        private List<PriceCate> DataTableToPriceCateList(DataTable dt)
        {
            List<PriceCate> list = new List<PriceCate>();
            foreach (DataRow row in dt.Rows)
            {
                PriceCate kw = new PriceCate();
                kw.Id = Convert.ToInt32(row["Id"]);
                kw.CateName = (string)row["CateName"];
                kw.UsePrice1 = Convert.ToBoolean(row["UsePrice1"]);
                kw.Price1Name = (string)row["Price1Name"];
                kw.Price1Val = Convert.ToDouble(row["Price1Val"]);

                kw.UsePrice2 = Convert.ToBoolean(row["UsePrice2"]);
                kw.Price2Name = (string)row["Price2Name"];
                kw.Price2Val = Convert.ToDouble(row["Price2Val"]);

                kw.UsePrice3 = Convert.ToBoolean(row["UsePrice3"]);
                kw.Price3Name = (string)row["Price3Name"];
                kw.Price3Val = Convert.ToDouble(row["Price3Val"]);

                kw.UsePrice4 = Convert.ToBoolean(row["UsePrice4"]);
                kw.Price4Name = (string)row["Price4Name"];
                kw.Price4Val = Convert.ToDouble(row["Price4Val"]);

                kw.UsePrice5 = Convert.ToBoolean(row["UsePrice5"]);
                kw.Price5Name = (string)row["Price5Name"];
                kw.Price5Val = Convert.ToDouble(row["Price5Val"]);
                kw.Status = (string)row["Status"];
                list.Add(kw);
            }
            return list;
        }
Exemple #4
0
 public void InsertOrUpdatePriceCate(PriceCate item)
 {
     productDao.InsertOrUpdatePriceCate(item);
     FireEditPriceCateEvent(item);
 }
Exemple #5
0
 public void InsertOrUpdatePriceCate(PriceCate item)
 {
     string InsSql = @"INSERT INTO PriceCate( CateName,UsePrice1, Price1Name, Price1Val, UsePrice2, Price2Name, Price2Val, UsePrice3, Price3Name, Price3Val,"
                   + "UsePrice4, Price4Name, Price4Val, UsePrice5, Price5Name, Price5Val, Status)"
                   + "values(@CateName, @UsePrice1, @Price1Name,@Price1Val, @UsePrice2, @Price2Name, @Price2Val, @UsePrice3, @Price3Name, @Price3Val,"
                   + "@UsePrice4, @Price4Name, @Price4Val, @UsePrice5, @Price5Name, @Price5Val, @Status)";
     string UpdSql = @"Update PriceCate SET CateName=@CateName,UsePrice1=@UsePrice1, Price1Name=@Price1Name, Price1Val=@Price1Val, "
                     + "UsePrice2=@UsePrice2, Price2Name=@Price2Name, Price2Val=@Price2Val, UsePrice3=@UsePrice3, Price3Name=@Price3Name,"
                     + "Price3Val=@Price3Val, UsePrice4=@UsePrice4, Price4Name=@Price4Name, Price4Val=@Price4Val, UsePrice5=@UsePrice5,  "
                     + "Price5Name=@Price5Name,Price5Val=@Price5Val, Status=@Status WHERE Id = @Id";
     MySqlParameter[] parameter = new MySqlParameter[]
     {
         new MySqlParameter("@Id",item.Id),
         new MySqlParameter("@CateName",item.CateName),
         new MySqlParameter("@UsePrice1",item.UsePrice1),
         new MySqlParameter("@Price1Name",item.Price1Name),
         new MySqlParameter("@Price1Val",item.Price1Val),
         new MySqlParameter("@UsePrice2",item.UsePrice2),
         new MySqlParameter("@Price2Name",item.Price2Name),
         new MySqlParameter("@Price2Val",item.Price2Val),
         new MySqlParameter("@UsePrice3",item.UsePrice3),
         new MySqlParameter("@Price3Name",item.Price3Name),
         new MySqlParameter("@Price3Val",item.Price3Val),
         new MySqlParameter("@UsePrice4",item.UsePrice4),
         new MySqlParameter("@Price4Name",item.Price4Name),
         new MySqlParameter("@Price4Val",item.Price4Val),
         new MySqlParameter("@UsePrice5",item.UsePrice5),
         new MySqlParameter("@Price5Name",item.Price5Name),
         new MySqlParameter("@Price5Val",item.Price5Val),
         new MySqlParameter("@Status",item.Status)
     };
     if (item.Id == 0)
     {
         dbHelper.ExecuteNonQuery(InsSql, parameter);
     }
     else
     {
         dbHelper.ExecuteNonQuery(UpdSql, parameter);
     }
 }