コード例 #1
0
ファイル: Form1.cs プロジェクト: thalukanyomulaudzi/Techno
        void myMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            deleteForm deleteF = new deleteForm();

            if (e.ClickedItem.Name.ToString() == "Deleted")
            {
                //deleteF.ShowDialog();
                if (MessageBox.Show("Are you sure you want to delete?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    //deleteEmployee(index);
                    //  MessageBox.Show("");
                }
            }



            //Stock Management Click Event Handlers
            //
            //-----------------------------------------------------------------------------------------------------//
            if (e.ClickedItem.Name.ToString() == "Maintain")
            {
                Maintain_Stock_Item myform = new Maintain_Stock_Item();
                myform.ShowDialog();
            }

            else if (e.ClickedItem.Name.ToString() == "Check In")
            {
                Check_In_Stock_Item myform = new Check_In_Stock_Item();
                myform.ShowDialog();
            }

            else if (e.ClickedItem.Name.ToString() == "Check Out")
            {
                Check_Out_Stock_Item myform = new Check_Out_Stock_Item();
                myform.ShowDialog();
            }

            else if (e.ClickedItem.Name.ToString() == "Take")
            {
                Take_Stock_Item myform = new Take_Stock_Item();
                myform.ShowDialog();
            }
            else if (e.ClickedItem.Name.ToString() == "Write Off")
            {
                Write_Off_stock_Item myform = new Write_Off_stock_Item();
                myform.ShowDialog();
            }
        }
コード例 #2
0
        void myMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (navButton == btnMenu)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.MenuCombopassing;

                        Menu_Item deieteItem = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);

                        if (deieteItem != null)
                        {
                            db.Menu_Item.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Menu_Item_Name + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int       id   = Globals.MenuCombopassing;
                    Menu_Item item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);
                    if (item != null)
                    {
                        frmMaintainMenuItem form = new frmMaintainMenuItem();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }



            //Suppliers Right Cick Event handlers

            if (navButton == btnEmployees)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.Employeepassing;

                        Employee deieteItem = db.Employees.FirstOrDefault(c => c.Employee_ID == id);

                        if (deieteItem != null)
                        {
                            db.Employees.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Employee_Name + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int      id   = Globals.Employeepassing;
                    Employee item = db.Employees.FirstOrDefault(c => c.Employee_ID == id);
                    if (item != null)
                    {
                        Maintain_Employee form = new Maintain_Employee();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }


            //Suppliers Right click Handlers

            if (navButton == btnSuppliers11)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.Supplierpassing;

                        Supplier deieteItem = db.Suppliers.FirstOrDefault(c => c.Supllier_ID == id);

                        if (deieteItem != null)
                        {
                            db.Suppliers.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Supplier_Name + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int      id   = Globals.Supplierpassing;
                    Supplier item = db.Suppliers.FirstOrDefault(c => c.Supllier_ID == id);
                    if (item != null)
                    {
                        SupplierForm form = new SupplierForm();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }

            if (navButton == btnCombo)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.Combopassing;

                        Combo deieteItem = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);

                        if (deieteItem != null)
                        {
                            db.Comboes.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Combo_Description + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int   id   = Globals.Combopassing;
                    Combo item = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);
                    if (item != null)
                    {
                        frmMaintainCombo form = new frmMaintainCombo();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }

            if (navButton == btnCombo)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.Combopassing;

                        Combo deieteItem = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);

                        if (deieteItem != null)
                        {
                            db.Comboes.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Combo_Description + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int   id   = Globals.Combopassing;
                    Combo item = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);
                    if (item != null)
                    {
                        frmMaintainCombo form = new frmMaintainCombo();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }

            //Stock Management Click Event Handlers
            //
            //-----------------------------------------------------------------------------------------------------//
            if (e.ClickedItem.Name.ToString() == "View")
            {
                Globals.menu.Hide();

                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited != null)
                {
                    Maintain_Stock_Item myform = new Maintain_Stock_Item();
                    myform.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                }
            }

            else if (e.ClickedItem.Name.ToString() == "Check In")
            {
                Globals.menu.Hide();
                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited.Stock_Type_ID == 1)
                {
                    if (itemEdited != null)
                    {
                        Check_In_Stock_Item myform = new Check_In_Stock_Item();
                        myform.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
                else
                {
                    MessageBox.Show("Action not allowed in such stock item");
                }
            }

            else if (e.ClickedItem.Name.ToString() == "Check Out")
            {
                Globals.menu.Hide();
                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited.Stock_Type_ID == 1)
                {
                    if (itemEdited != null)
                    {
                        Check_Out_Stock_Item myform = new Check_Out_Stock_Item();
                        myform.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
                else
                {
                    MessageBox.Show("Action not allowed in such stock item");
                }
            }

            else if (e.ClickedItem.Name.ToString() == "Take")
            {
                Globals.menu.Hide();
                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited != null)
                {
                    Take_Stock_Item myform = new Take_Stock_Item();
                    myform.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                }
            }
            else if (e.ClickedItem.Name.ToString() == "Write Off")
            {
                Globals.menu.Hide();
                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited != null)
                {
                    Write_Off_stock_Item myform = new Write_Off_stock_Item();
                    myform.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                }
            }
        }