private void btnInsertCategory_Click(object sender, EventArgs e) { try { ProductCategory_DTO category = new ProductCategory_DTO(); category.ProductCategoryID = txtCategoryID.Text; category.ProductCategoryName = txtCategoryName.Text; category.PercentRevenue = float.Parse(txtPercentRevenue.Text); if (txtCategoryID.Text == "" || txtCategoryName.Text == "" || txtPercentRevenue.Text == "") { XtraMessageBox.Show("You have to fullfill category information!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClearDisplay(); return; } if (ProductCategory_BUS.InsertProductCategory(category)) { XtraMessageBox.Show("Category Info has been inserted sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadCategoryList(); ClearDisplay(); return; } } catch { XtraMessageBox.Show("Insert Info Failed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void btnUpdateCategory_Click(object sender, EventArgs e) { try { ProductCategory_DTO category = new ProductCategory_DTO(); category.ProductCategoryID = dtgvCategoryInfoList.CurrentRow.Cells["ProductCategoryID"].Value.ToString(); category.ProductCategoryName = txtCategoryName.Text; category.PercentRevenue = float.Parse(txtPercentRevenue.Text); if (txtCategoryID.Text == "" || txtCategoryName.Text == "" || txtPercentRevenue.Text == "") { XtraMessageBox.Show("You have to choose at least one category to update!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClearDisplay(); return; } if (ProductCategory_BUS.UpdateProductCategory(category)) { XtraMessageBox.Show("Category Info has been updated sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadCategoryList(); ClearDisplay(); return; } } catch { XtraMessageBox.Show("Update Info Failed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void LoadProductCategory() { List <ProductCategory_DTO> loadCategory = ProductCategory_BUS.LoadProductCategory(); cmbCategory.DataSource = loadCategory; cmbCategory.ValueMember = "ProductCategoryID"; cmbCategory.DisplayMember = "ProductCategoryName"; }
public void LoadCategoryList() { List <ProductCategory_DTO> category = ProductCategory_BUS.LoadProductCategory(); dtgvCategoryInfoList.DataSource = category; }