private void LoadCategoryCbo() { liquorcategory = new LiquorCategory(); CboCategory.DisplayMember = "CategoryName"; CboCategory.ValueMember = "CategoryId"; CboCategory.DataSource = liquorcategory.ViewCategory().Tables["LiquorCategory"]; }
private void BtnSave_Click(object sender, EventArgs e) { try { if (!Global.ComboNull(CboCategory)) { throw new Exception("Select liquor category"); } if (!Global.InputHandle(TxtCategory)) { throw new Exception("Enter liquor category"); } liquorcategory = new LiquorCategory(); liquorcategory.CategoryId = Convert.ToInt32(CboCategory.SelectedValue); liquorcategory.CategoryName = TxtCategory.Text; bool flag = liquorcategory.UpdateCategory(); if (flag == true) { MessageBox.Show("Selected liquor category is updated"); LoadCategoryCbo(); TxtCategory.Text = ""; } else { MessageBox.Show("Category already exist"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ViewCategory_Load(object sender, EventArgs e) { liquorcategory = new LiquorCategory(); DgvCategory.DataMember = "LiquorCategory"; DgvCategory.DataSource = liquorcategory.ViewCategory().Tables["LiquorCategory"]; DgvCategory.Columns[0].Visible = false; }
private void BtnDelete_Click(object sender, EventArgs e) { try { if (!Global.ComboNull(CboCategory)) { throw new Exception("Select liquor category"); } liquorcategory = new LiquorCategory(); liquorcategory.CategoryName = CboCategory.Text; liquorcategory.CategoryId = Convert.ToInt32(CboCategory.SelectedValue); bool flag = liquorcategory.DeleteCategory(); if (flag == true) { LoadCategoryCbo(); MessageBox.Show("Selected liquor category is deleted"); TxtCategory.Text = ""; } else { MessageBox.Show("Liquor category does not exist"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BtnAddcat_Click(object sender, EventArgs e) { try { if (!Global.InputHandle(TxtCategory)) { throw new Exception("Please enter liquor category"); } liquorcategory = new LiquorCategory(); liquorcategory.CategoryName = TxtCategory.Text; bool flag = liquorcategory.AddCategory(); if (flag == true) { MessageBox.Show("Category added"); TxtCategory.Text = ""; } else { MessageBox.Show("Category already exist"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }