예제 #1
0
        private void ToolBar1_ButtonClick(System.Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (ToolBar1.Buttons.IndexOf(e.Button))
            {
                case 0: //添加数据
                    Button2_Click(sender, e);
                    if (! Panel1.Visible)
                    {
                        Label3.Text = "添加记录";
                        TextBox1.Text = "";
                        TextBox2.Text = "";
                        NumericUpDown1.Value = 0;
                        CheckBox1.Checked = false;
                        dgFoodDiscount.Height = dgFoodDiscount.Height - Panel1.Height - 5;
                        Panel1.Visible = true;
                        this.AcceptButton = Button1;
                        this.CancelButton = Button2;
                        TextBox1.Focus();
                    }
                    break;

                case 1: //修改数据
                    if (! (dgFoodDiscount.CurrentRowIndex < 0))
                    {
                        Button2_Click(sender, e);
                        if (! Panel1.Visible)
                        {
                            Label3.Text = "修改记录";
                            TextBox1.Text = dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 0].ToString();
                            oldcode = TextBox1.Text;
                            TextBox2.Text = dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 1].ToString();
                            NumericUpDown1.Value = System.Convert.ToDecimal(dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 2]);
                            CheckBox1.Checked = dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 3].ToString() == "1" ? true : false;
                            dgFoodDiscount.Height = dgFoodDiscount.Height - Panel1.Height - 5;
                            Panel1.Visible = true;
                            this.AcceptButton = Button1;
                            this.CancelButton = Button2;
                            TextBox1.Focus();
                        }
                    }
                    break;
                case 2: //删除当前数据
                    if (! (dgFoodDiscount.CurrentRowIndex < 0))
                    {
                        if (MessageBox.Show("确定要删除当前选中的编号为 " + dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 0].ToString().Trim() + " 的菜品优惠吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            //删除操作
                            if (DelDiscount(dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 0].ToString()))
                            {
                                LoadFoodDiscountList();
                            }
                        }
                    }
                    break;
                case 4: //应用部门
                    if (! (dgFoodDiscount.CurrentRowIndex < 0))
                    {
                        frmApplyDiscountDept frmapplydisdept = new frmApplyDiscountDept();
                        frmapplydisdept.DiscountCode = dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 0].ToString();
                        frmapplydisdept.Label1.Text = "请选择将名为 " + dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 1] + " 的优惠应用到的部门";
                        frmapplydisdept.ShowDialog();
                    }
                    break;
                case 6:
                    this.Close();
                    break;
            }
        }
예제 #2
0
        private void ToolBar1_ButtonClick(System.Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (ToolBar1.Buttons.IndexOf(e.Button))
            {
            case 0:                     //添加数据
                Button2_Click(sender, e);
                if (!Panel1.Visible)
                {
                    Label3.Text           = "添加记录";
                    TextBox1.Text         = "";
                    TextBox2.Text         = "";
                    NumericUpDown1.Value  = 0;
                    CheckBox1.Checked     = false;
                    dgFoodDiscount.Height = dgFoodDiscount.Height - Panel1.Height - 5;
                    Panel1.Visible        = true;
                    this.AcceptButton     = Button1;
                    this.CancelButton     = Button2;
                    TextBox1.Focus();
                }
                break;

            case 1:                     //修改数据
                if (!(dgFoodDiscount.CurrentRowIndex < 0))
                {
                    Button2_Click(sender, e);
                    if (!Panel1.Visible)
                    {
                        Label3.Text           = "修改记录";
                        TextBox1.Text         = dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 0].ToString();
                        oldcode               = TextBox1.Text;
                        TextBox2.Text         = dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 1].ToString();
                        NumericUpDown1.Value  = System.Convert.ToDecimal(dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 2]);
                        CheckBox1.Checked     = dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 3].ToString() == "1" ? true : false;
                        dgFoodDiscount.Height = dgFoodDiscount.Height - Panel1.Height - 5;
                        Panel1.Visible        = true;
                        this.AcceptButton     = Button1;
                        this.CancelButton     = Button2;
                        TextBox1.Focus();
                    }
                }
                break;

            case 2:                     //删除当前数据
                if (!(dgFoodDiscount.CurrentRowIndex < 0))
                {
                    if (MessageBox.Show("确定要删除当前选中的编号为 " + dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 0].ToString().Trim() + " 的菜品优惠吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        //删除操作
                        if (DelDiscount(dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 0].ToString()))
                        {
                            LoadFoodDiscountList();
                        }
                    }
                }
                break;

            case 4:                     //应用部门
                if (!(dgFoodDiscount.CurrentRowIndex < 0))
                {
                    frmApplyDiscountDept frmapplydisdept = new frmApplyDiscountDept();
                    frmapplydisdept.DiscountCode = dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 0].ToString();
                    frmapplydisdept.Label1.Text  = "请选择将名为 " + dgFoodDiscount[dgFoodDiscount.CurrentRowIndex, 1] + " 的优惠应用到的部门";
                    frmapplydisdept.ShowDialog();
                }
                break;

            case 6:
                this.Close();
                break;
            }
        }