Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfoBll bll   = new MemberTypeInfoBll();
            MemberTypeInfo    model = new MemberTypeInfo()
            {
                MTitle    = txtTitle.Text,
                MDiscount = Convert.ToDecimal(txtDiscount.Text),
            };

            if (btnSave.Text == "添加")
            {
                if (!bll.Add(model))
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                model.MId = Convert.ToInt32(txtId.Text);
                if (!bll.Update(model))
                {
                    MessageBox.Show("修改失败");
                }
            }

            Reset();
            LoadList();
            resulted = DialogResult.OK;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfo mti = new MemberTypeInfo()
            {
                MTitle    = txtTitle.Text,
                MDiscount = Convert.ToDecimal(txtDiscount.Text)
            };

            if (txtId.Text.Equals("No ID"))
            {
                if (mtiBll.Add(mti))
                {
                    LoadList();
                }
            }
            else
            {
                mti.MId = int.Parse(txtId.Text);
                if (mtiBll.Edit(mti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("Failed.");
                }
            }
            txtId.Text       = "No ID";
            txtTitle.Text    = "";
            txtDiscount.Text = "";
            btnSave.Text     = "Add";

            result = DialogResult.OK;
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //判断输入有效性
            if (string.IsNullOrWhiteSpace(txtTitle.Text))
            {
                MessageBox.Show("请输入标题");
                txtTitle.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(txtDiscount.Text))
            {
                MessageBox.Show("请输入折扣");
                txtDiscount.Focus();
                return;
            }
            //接收用户输入的值,构造对象
            MemberTypeInfo mti = new MemberTypeInfo()
            {
                MTitle    = txtTitle.Text,
                MDiscount = decimal.Parse(txtDiscount.Text)
            };

            if (txtId.Text.Equals("添加时无编号"))
            {
                //添加操作
                if (mtiBll.Add(mti))    //调用添加方法
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍候重试");
                }
            }
            else
            {
                //修改操作
                mti.MId = int.Parse(txtId.Text);
                if (mtiBll.Edit(mti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍候重试");
                }
            }
            //将控件还原
            txtId.Text       = "添加时无编号";
            txtTitle.Text    = "";
            txtDiscount.Text = "";
            btnSave.Text     = "添加";

            result = DialogResult.OK;
        }
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //接收用户输入的值,构造对象
            MemberTypeInfo mti = new MemberTypeInfo()
            {
                MTitle    = txtTitle.Text,
                MDiscount = Convert.ToDecimal(txtDiscount.Text)
            };

            if (txtId.Text.Equals("添加时无编号"))
            {
                //添加

                //调用添加方法
                if (mtiBll.Add(mti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍候重试");
                }
            }
            else
            {
                //修改
                mti.MId = int.Parse(txtId.Text);
                //调用修改的方法
                if (mtiBll.Edit(mti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍候重试");
                }
            }
            //将控件还原
            txtId.Text       = "添加时无编号";
            txtTitle.Text    = "";
            txtDiscount.Text = "";
            btnSave.Text     = "添加";

            result = DialogResult.OK;
        }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfo mti = new MemberTypeInfo();

            if (txtId.Text == "添加时无编号")
            {
                //添加
                mti.MTitle    = txtTitle.Text;
                mti.MDiscount = Convert.ToDecimal(txtDiscount.Text);
                if (mtiBll.Add(mti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                //修改
                mti.MId       = Convert.ToInt32(txtId.Text);
                mti.MTitle    = txtTitle.Text;
                mti.MDiscount = Convert.ToDecimal(txtDiscount.Text);
                if (mtiBll.Edit(mti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            txtId.Text       = "添加时无编号";
            txtTitle.Text    = "";
            txtTitle.Text    = "";
            txtDiscount.Text = "";
            btnSave.Text     = "添加";
            result           = DialogResult.OK;
        }
Ejemplo n.º 6
0
        //确认或修该
        private void button1_Click(object sender, EventArgs e)
        {
            //根据输入,构造对象
            MemberTypeInfo mti = new MemberTypeInfo()
            {
                MTitle    = textBox1.Text,
                MDiscount = Convert.ToDecimal(textBox2.Text)
            };

            if (button1.Text.Equals("添加"))
            {
                //添加逻辑
                if (mtiBll.Add(mti))
                {
                    button2_Click(null, null);
                    LoadList();
                    UpdateTypeEvent();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试!!!");
                }
            }
            else
            {
                //修改逻辑
                mti.MId = Convert.ToInt32(textBox3.Text);
                if (mtiBll.Edit(mti))
                {
                    button2_Click(null, null);
                    LoadList();
                    UpdateTypeEvent();
                }
                else
                {
                    MessageBox.Show("修改失败,请重试!!!");
                }
            }
        }
Ejemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfo mti = new MemberTypeInfo();

            try
            {
                mti.MTitle    = txtTitle.Text;
                mti.MDiscount = Convert.ToDecimal(Convert.ToDouble(txtDiscount.Text) / 10.0);
            }
            catch
            {
                MessageBox.Show("输入格式有误!请核查后重新输入!");
            }
            if (btnSave.Text == "修改")
            {
                mti.MId = Convert.ToInt32(txtId.Text);
                if (mtiBll.Edit(mti))
                {
                    LoadMemberList();
                    UpdateTypeEvent();
                }
                else
                {
                    MessageBox.Show("修改失败!请稍后重试!");
                }
            }
            else
            {
                if (mtiBll.Add(mti))
                {
                    LoadMemberList();
                    UpdateTypeEvent();
                }
                else
                {
                    MessageBox.Show("添加失败!请稍后重试!");
                }
            }
        }
Ejemplo n.º 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfo memberTypeInfo = new MemberTypeInfo()
            {
                MTitle    = txtTitle.Text,
                MDiscount = Convert.ToDecimal(txtDiscount.Text)
            };

            if (txtId.Text.Equals("添加时无编号"))
            {
                if (bll.Add(memberTypeInfo))
                {
                    LoadDate();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                memberTypeInfo.MId = int.Parse(txtId.Text);
                if (bll.Edit(memberTypeInfo))
                {
                    LoadDate();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            txtId.Text       = "添加时无编号";
            txtTitle.Text    = "";
            txtDiscount.Text = "";
            btnSave.Text     = "添加";
            result           = DialogResult.OK;
        }
Ejemplo n.º 9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var mti = new MemberTypeInfo
            {
                MTitle    = txtTitle.Text,
                MDiscount = Convert.ToDecimal(txtDiscount.Text)
            };

            if (btnSave.Text.Equals("添加"))
            {
                if (mtiBll.Add(mti))
                {
                    btnCancel_Click(null, null);
                    Load_List();
                    UpdateTypeEvent?.Invoke();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else if (btnSave.Text.Equals("修改"))
            {
                mti.Mid = Convert.ToInt32(txtId.Text);
                if (mtiBll.Edit(mti))
                {
                    btnCancel_Click(null, null);
                    Load_List();
                    UpdateTypeEvent?.Invoke();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
        }
Ejemplo n.º 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MemberTypeInfo mti;

            if (txtId.Text.Equals("添加时无编号"))
            {
                //添加
                //接受用户输入的值,构造对象
                try
                {
                    mti = new MemberTypeInfo()
                    {
                        MTitle    = txtTitle.Text,
                        MDiscount = Convert.ToDecimal(txtDiscount.Text)
                    };
                }
                catch
                {
                    MessageBox.Show("赋值类型不正确.......");
                    Clean();
                    return;
                }
                //调用添加方法
                if (mtiBll.Add(mti))
                {
                    LoadList();
                    MessageBox.Show("添加成功.");
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试......");
                }
            }
            else
            {
                //修改
                try
                {
                    mti = new MemberTypeInfo()
                    {
                        MId       = Convert.ToInt32(txtId.Text),
                        MTitle    = txtTitle.Text,
                        MDiscount = Convert.ToDecimal(txtDiscount.Text)
                    };
                }
                catch
                {
                    MessageBox.Show("赋值类型不正确.......");
                    Clean();
                    return;
                }
                //调用添加方法
                if (mtiBll.Edit(mti))
                {
                    LoadList();
                    MessageBox.Show("修改成功.");
                }
                else
                {
                    MessageBox.Show("修改失败,请稍后重试......");
                }
            }
            Clean();
            resule = DialogResult.OK;
        }