public static bool UpdateProductCategory(ProductCategory_DTO category) { SqlConnection con = DataProvider.OpenConnection(); SqlCommand cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_updateProductCategory]", con); try { cmd.CommandType = CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@ProductCategoryID", category.ProductCategoryID); cmd.Parameters.Add(p); p = new SqlParameter("@ProductCategoryName", category.ProductCategoryName); cmd.Parameters.Add(p); p = new SqlParameter("@PercentRevenue", category.PercentRevenue); cmd.Parameters.Add(p); cmd.ExecuteNonQuery(); DataProvider.CloseConnection(con); return(true); } catch { DataProvider.CloseConnection(con); return(false); } }
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 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; } }
public static bool DeleteProductCategory(ProductCategory_DTO category) { SqlConnection con = DataProvider.OpenConnection(); SqlCommand cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_deleteProductCategory]", con); try { cmd.CommandType = CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@ProductCategoryID", category.ProductCategoryID); cmd.Parameters.Add(p); cmd.ExecuteNonQuery(); DataProvider.CloseConnection(con); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); DataProvider.CloseConnection(con); return(false); } }
public static List <ProductCategory_DTO> LoadProductCategory() { SqlConnection con = DataProvider.OpenConnection(); SqlCommand cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_getProductCategory]", con); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 0) { return(null); } List <ProductCategory_DTO> listCategory = new List <ProductCategory_DTO>(); for (int i = 0; i < dt.Rows.Count; i++) { ProductCategory_DTO category = new ProductCategory_DTO(); category.ProductCategoryID = dt.Rows[i]["ProductCategoryID"].ToString(); category.ProductCategoryName = dt.Rows[i]["ProductCategoryName"].ToString(); category.PercentRevenue = float.Parse(dt.Rows[i]["PercentRevenue"].ToString()); listCategory.Add(category); } DataProvider.CloseConnection(con); return(listCategory); }
public static bool DeleteProductCategory(ProductCategory_DTO category) { return(ProductCategory_DAL.DeleteProductCategory(category)); }
public static bool UpdateProductCategory(ProductCategory_DTO category) { return(ProductCategory_DAL.UpdateProductCategory(category)); }
public static bool InsertProductCategory(ProductCategory_DTO category) { return(ProductCategory_DAL.InsertProductCategory(category)); }