示例#1
0
        private void ToolBar1_ButtonClick(System.Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (ToolBar1.Buttons.IndexOf(e.Button))
            {
            case 0:                     //添加数据
                frmEditFood EditFood_1 = new frmEditFood();
                EditFood_1.GetFoodTypeList();

                EditFood_1.frmMode = 1;                         //添加记录
                EditFood_1.Text    = "添加菜品信息";

                EditFood_1.ShowDialog();
                if (EditFood_1.DialogResult == DialogResult.OK)
                {
                    LoadFoodList();
                }
                break;

            case 1:                     //修改数据
                if (!(dgFoodList.CurrentRowIndex < 0))
                {
                    EditFoodInfo();
                }
                break;

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

            case 4:                     //查询数据
                frmEditFood EditFood = new frmEditFood();
                EditFood.GetFoodTypeList();

                EditFood.frmMode = 3;                         //查询数据
                EditFood.Text    = "查询菜品信息";

                EditFood.ShowDialog();
                if (EditFood.DialogResult == DialogResult.OK)
                {
                    SearchFood(EditFood.TextBox1.Text, EditFood.ComboBox1.Text, EditFood.TextBox2.Text, EditFood.TextBox3.Text, EditFood.CheckBox3.Checked, EditFood.CheckBox4.Checked, EditFood.CheckBox1.Checked, EditFood.CheckBox2.Checked);
                }
                break;

            case 6:                     //做法
                if (!(dgFoodList.CurrentRowIndex < 0))
                {
                    frmEditFoodOperandi frmfoodop = new frmEditFoodOperandi();
                    frmfoodop.frmMode     = 2;                         //2=编辑当前菜品做法
                    frmfoodop.foodcode    = dgFoodList[dgFoodList.CurrentRowIndex, 0].ToString();
                    frmfoodop.Label4.Text = "菜品名称:" + "\r\n" + dgFoodList[dgFoodList.CurrentRowIndex, 1].ToString();
                    frmfoodop.ShowDialog();
                }
                break;

            case 7:                     //口味
                if (!(dgFoodList.CurrentRowIndex < 0))
                {
                    frmEditFoodTaste frmfoodtst = new frmEditFoodTaste();
                    frmfoodtst.frmMode     = 2;                         //2=编辑当前菜品口味
                    frmfoodtst.foodcode    = dgFoodList[dgFoodList.CurrentRowIndex, 0].ToString();
                    frmfoodtst.Label4.Text = "菜品名称:" + "\r\n" + dgFoodList[dgFoodList.CurrentRowIndex, 1].ToString();
                    frmfoodtst.ShowDialog();
                }
                break;

            case 9:                     //成本卡
                if (!(dgFoodList.CurrentRowIndex < 0))
                {
                    frmFoodCost frmfoodcst = new frmFoodCost();
                    frmfoodcst.foodcode    = dgFoodList[dgFoodList.CurrentRowIndex, 0].ToString();
                    frmfoodcst.Label1.Text = "菜品名称:" + dgFoodList[dgFoodList.CurrentRowIndex, 1].ToString();
                    frmfoodcst.ShowDialog();
                }
                break;

            case 11:                     //调价
                if (!(dgFoodList.CurrentRowIndex < 0))
                {
                    frmAdjustFoodPrice frmadjfoodprice = new frmAdjustFoodPrice();
                    frmadjfoodprice.ShowDialog();
                    if (frmadjfoodprice.DialogResult == DialogResult.OK)
                    {
                        if (frmadjfoodprice.RadioButton1.Checked)                                 //上调
                        {
                            if (UpdateFoodsPrice("+", (double)frmadjfoodprice.NumericUpDown1.Value))
                            {
                                LoadFoodList();
                            }
                        }
                        else
                        {
                            if (UpdateFoodsPrice("-", (double)frmadjfoodprice.NumericUpDown1.Value))
                            {
                                LoadFoodList();
                            }
                        }
                    }
                }
                break;

            case 13:                     //打印
                if (MessageBox.Show("确定要进行打印操作吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    if (!PrintReport(CurrentFoodLstSqlCode))
                    {
                        MessageBox.Show("打印失败!如果问题依然存在请联系系统管理员。");
                    }
                }
                break;

            case 15:                     //关闭
                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: //添加数据
                    frmEditFood EditFood_1 = new frmEditFood();
                    EditFood_1.GetFoodTypeList();

                    EditFood_1.frmMode = 1; //添加记录
                    EditFood_1.Text = "添加菜品信息";

                    EditFood_1.ShowDialog();
                    if (EditFood_1.DialogResult == DialogResult.OK)
                    {
                        LoadFoodList();
                    }
                    break;
                case 1: //修改数据
                    if (! (dgFoodList.CurrentRowIndex < 0))
                    {
                        EditFoodInfo();
                    }
                    break;
                case 2: //删除当前数据
                    if (! (dgFoodList.CurrentRowIndex < 0))
                    {
                        if (MessageBox.Show("确定要删除当前选中的编号为 " + dgFoodList[dgFoodList.CurrentRowIndex, 0].ToString().Trim() + " 的菜品吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            //'删除操作
                            if (DelFood(dgFoodList[dgFoodList.CurrentRowIndex, 0].ToString()))
                            {
                                LoadFoodList();
                            }
                        }
                    }
                    break;
                case 4: //查询数据
                    frmEditFood EditFood = new frmEditFood();
                    EditFood.GetFoodTypeList();

                    EditFood.frmMode = 3; //查询数据
                    EditFood.Text = "查询菜品信息";

                    EditFood.ShowDialog();
                    if (EditFood.DialogResult == DialogResult.OK)
                    {
                        SearchFood(EditFood.TextBox1.Text, EditFood.ComboBox1.Text, EditFood.TextBox2.Text, EditFood.TextBox3.Text, EditFood.CheckBox3.Checked, EditFood.CheckBox4.Checked, EditFood.CheckBox1.Checked, EditFood.CheckBox2.Checked);
                    }
                    break;
                case 6: //做法
                    if (! (dgFoodList.CurrentRowIndex < 0))
                    {
                        frmEditFoodOperandi frmfoodop = new frmEditFoodOperandi();
                        frmfoodop.frmMode = 2; //2=编辑当前菜品做法
                        frmfoodop.foodcode = dgFoodList[dgFoodList.CurrentRowIndex, 0].ToString();
                        frmfoodop.Label4.Text = "菜品名称:" + "\r\n" + dgFoodList[dgFoodList.CurrentRowIndex, 1].ToString();
                        frmfoodop.ShowDialog();
                    }
                    break;
                case 7: //口味
                    if (! (dgFoodList.CurrentRowIndex < 0))
                    {
                        frmEditFoodTaste frmfoodtst = new frmEditFoodTaste();
                        frmfoodtst.frmMode = 2; //2=编辑当前菜品口味
                        frmfoodtst.foodcode = dgFoodList[dgFoodList.CurrentRowIndex, 0].ToString();
                        frmfoodtst.Label4.Text = "菜品名称:" + "\r\n" + dgFoodList[dgFoodList.CurrentRowIndex, 1].ToString();
                        frmfoodtst.ShowDialog();
                    }
                    break;
                case 9: //成本卡
                    if (! (dgFoodList.CurrentRowIndex < 0))
                    {
                        frmFoodCost frmfoodcst = new frmFoodCost();
                        frmfoodcst.foodcode = dgFoodList[dgFoodList.CurrentRowIndex, 0].ToString();
                        frmfoodcst.Label1.Text = "菜品名称:" + dgFoodList[dgFoodList.CurrentRowIndex, 1].ToString();
                        frmfoodcst.ShowDialog();
                    }
                    break;
                case 11: //调价
                    if (! (dgFoodList.CurrentRowIndex < 0))
                    {
                        frmAdjustFoodPrice frmadjfoodprice = new frmAdjustFoodPrice();
                        frmadjfoodprice.ShowDialog();
                        if (frmadjfoodprice.DialogResult == DialogResult.OK)
                        {
                            if (frmadjfoodprice.RadioButton1.Checked) //上调
                            {
                                if (UpdateFoodsPrice("+", (double) frmadjfoodprice.NumericUpDown1.Value))
                                {
                                    LoadFoodList();
                                }
                            }
                            else
                            {
                                if (UpdateFoodsPrice("-", (double) frmadjfoodprice.NumericUpDown1.Value))
                                {
                                    LoadFoodList();
                                }
                            }
                        }
                    }
                    break;
                case 13: //打印
                    if (MessageBox.Show("确定要进行打印操作吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        if (! PrintReport(CurrentFoodLstSqlCode))
                        {
                            MessageBox.Show("打印失败!如果问题依然存在请联系系统管理员。");
                        }
                    }
                    break;
                case 15: //关闭
                    this.Close();
                    break;
            }
        }