Пример #1
0
        private void DgvMenuItems_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 0)
                {
                    MenuItemsIdforUpdate = Convert.ToInt32(DgvMenuItems.Rows[e.RowIndex].Cells[2].Value);
                    TxtItemName.Text     = DgvMenuItems.Rows[e.RowIndex].Cells[5].Value.ToString();
                    TxtRate.Text         = (DgvMenuItems.Rows[e.RowIndex].Cells[7].Value.ToString());
                    TxtDiscount.Text     = (DgvMenuItems.Rows[e.RowIndex].Cells[8].Value.ToString());
                    TxtBarCode.Text      = (DgvMenuItems.Rows[e.RowIndex].Cells[11].Value.ToString());
                    if (Convert.ToInt32(DgvMenuItems.Rows[e.RowIndex].Cells[9].Value) == 1)
                    {
                        CheckBoxStatus.Checked = true;
                    }
                    else
                    {
                        CheckBoxStatus.Checked = false;
                    }

                    List <menuCategory> L1 = new List <menuCategory>();
                    L1 = objMenuItemsService.Get_CategoryName(Convert.ToInt32(DgvMenuItems.Rows[e.RowIndex].Cells[3].Value));
                    ComboBoxCategory.SelectedIndex = ComboBoxCategory.FindString(L1[0].name);

                    List <section> L2 = new List <section>();
                    L2 = objMenuItemsService.Get_SectionyName(Convert.ToInt32(DgvMenuItems.Rows[e.RowIndex].Cells[6].Value));
                    ComboBoxSection.SelectedIndex = ComboBoxSection.FindString(L2[0].sectionname);

                    TxtColorPickerMenuItem.BackColor = System.Drawing.ColorTranslator.FromHtml(DgvMenuItems.Rows[e.RowIndex].Cells[4].Value.ToString());
                    colorHexValMenuItem = HexConverter(ColorDialogMenuItem.Color);
                    BtnSaveLbl.Text     = "Update";
                    brcode.Text         = DgvMenuItems.Rows[e.RowIndex].Cells[11].Value.ToString();
                    bc = DgvMenuItems.Rows[e.RowIndex].Cells[11].Value.ToString();
                }
                else if (e.ColumnIndex == 1)
                {
                    DeleteDialogBox obj = new DeleteDialogBox();
                    obj.ShowDialog();
                    if (DeleteDialogBox.delete == 1)
                    {
                        if (objMenuItemsService.Delete_MenuItems_tables(Convert.ToInt32(DgvMenuItems.Rows[e.RowIndex].Cells[2].Value)))
                        {
                            MessageBox.Show("Deleted Successfully.!");
                            LoadAllTables();
                            ClearAll();
                        }
                        else
                        {
                            MessageBox.Show("Deleted failed");
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Exception Error");
            }
        }
Пример #2
0
 private void DGVtable_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == 0)
         {
             if (Convert.ToInt32(DGVtable.Rows[e.RowIndex].Cells[6].Value) != 0)
             {
                 MessageBox.Show("Table Currently in Use!");
             }
             else
             {
                 tableIdforUpdate      = Convert.ToInt32(DGVtable.Rows[e.RowIndex].Cells[2].Value);
                 txttableNumber.Text   = DGVtable.Rows[e.RowIndex].Cells[3].Value.ToString();
                 txttableCapacity.Text = DGVtable.Rows[e.RowIndex].Cells[4].Value.ToString();
                 if (DGVtable.Rows[e.RowIndex].Cells[5].Value.ToString() == "True")
                 {
                     chbxTableStatus.Checked = true;
                 }
                 else
                 {
                     chbxTableStatus.Checked = false;
                 }
                 btnSavelbl.Text = "Update";
             }
         }
         else if (e.ColumnIndex == 1)
         {
             if (Convert.ToInt32(DGVtable.Rows[e.RowIndex].Cells[6].Value) != 0)
             {
                 MessageBox.Show("Table Currently in Use!");
             }
             else
             {
                 DeleteDialogBox obj = new DeleteDialogBox();
                 obj.ShowDialog();
                 if (DeleteDialogBox.delete == 1)
                 {
                     if (objTblServicel.Delete_R_tables(Convert.ToInt32(DGVtable.Rows[e.RowIndex].Cells[2].Value)))
                     {
                         MessageBox.Show("Deleted Successfully.!");
                         LoadAllTables();
                         ClearAll();
                     }
                     else
                     {
                         MessageBox.Show("Deleted failed");
                     }
                 }
             }
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message, "Exception Error");
     }
 }
 private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == 0)
         {
             MenuCatogeryIdforUpdate = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[2].Value);
             txtCategory.Text        = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
             colorHexVal             = HexConverter(colorDialog1.Color);
             txtColor.BackColor      = System.Drawing.ColorTranslator.FromHtml(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString());
             btnLblSave.Text         = "Update";
         }
         else if (e.ColumnIndex == 1)
         {
             List <menuItem> p     = new List <menuItem>();
             int             count = objMenuCatogeryServicel.CheckEmptyItem(Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[2].Value)).Count;
             if (count == 0)
             {
                 DeleteDialogBox obj = new DeleteDialogBox();
                 obj.ShowDialog();
                 if (DeleteDialogBox.delete == 1)
                 {
                     if (objMenuCatogeryServicel.Delete_MenuCatogery_tables(Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[2].Value)))
                     {
                         MessageBox.Show("Deleted Successfully.!");
                         LoadAllTables();
                         ClearAll();
                     }
                     else
                     {
                         MessageBox.Show("Deleted failed");
                     }
                 }
             }
             else
             {
                 MessageBox.Show("This Catogery contain items which must be deleted first to perform this action.");
             }
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message, "Exception Error");
     }
 }
        private void dataGridView2_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 0)
                {
                    IdforUpdate = Convert.ToInt32(dataGridView2.Rows[e.RowIndex].Cells[2].Value);

                    comboBoxCategory.SelectedIndex  = comboBoxCategory.FindString(dataGridView2.Rows[e.RowIndex].Cells[3].Value.ToString());
                    comboBoxMenuItems.SelectedIndex = comboBoxMenuItems.FindString(dataGridView2.Rows[e.RowIndex].Cells[4].Value.ToString());
                    dateTimePickerStock.Value       = DateTime.Parse(dataGridView2.Rows[e.RowIndex].Cells[5].Value.ToString());
                    textBoxAvailableStock.Text      = dataGridView2.Rows[e.RowIndex].Cells[6].Value.ToString();

                    buttonSave.Text = "Update";
                }
                else if (e.ColumnIndex == 1)
                {
                    DeleteDialogBox obj = new DeleteDialogBox();
                    obj.ShowDialog();
                    if (DeleteDialogBox.delete == 1)
                    {
                        using (RMSDBEntities db = new RMSDBEntities())
                        {
                            IdforUpdate = Convert.ToInt32(dataGridView2.Rows[e.RowIndex].Cells[2].Value.ToString());
                            Stock_Tbl RowinDb = db.Stock_Tbl.Where(d => d.Id == IdforUpdate).SingleOrDefault();
                            if (RowinDb != null)
                            {
                                db.Stock_Tbl.Remove(RowinDb);
                                db.SaveChanges();
                                MessageBox.Show("Deleted Successfully!");
                                LoadAllTables();
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Exception Error");
            }
        }
Пример #5
0
        private void DGVCounter_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 0)
                {
                    counterIdforUpdate = Convert.ToInt32(DGVCounter.Rows[e.RowIndex].Cells[2].Value);
                    txtSection.Text    = DGVCounter.Rows[e.RowIndex].Cells[3].Value.ToString();


                    btnSavelbl.Text = "Update";
                }
                else if (e.ColumnIndex == 1)
                {
                    DeleteDialogBox obj = new DeleteDialogBox();
                    obj.ShowDialog();
                    if (DeleteDialogBox.delete == 1)
                    {
                        if (objCounterServicel.DeleteCounter(Convert.ToInt32(DGVCounter.Rows[e.RowIndex].Cells[2].Value)))
                        {
                            MessageBox.Show("Deleted Successfully.!");
                            LoadAllCounter();
                            ClearAll();
                        }
                        else
                        {
                            MessageBox.Show("Deleted failed");
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Exception Error");
            }
        }