public int InsertData(DEProduct product) { DALProduct obj_DALProduct = new DALProduct(); int int_Result; if (product.Product_Id == 0) { int_Result = obj_DALProduct.InsertData(product); } else { int_Result = obj_DALProduct.UpdateData(product); } obj_DALProduct = null; return(int_Result); }
public int InsertData(DECustomerReturn customerReturn) { int int_Result = 0; DALProductInStore obj_DALProductInStore = new DALProductInStore(); DALProduct obj_DALProduct = new DALProduct(); DEProductInStore productInStore = new DEProductInStore(); productInStore.Product_Id = customerReturn.Product_Id; DEProduct product = new DEProduct(); product.Product_Id = customerReturn.Product_Id; obj_DALProduct.LoadProductRow(product); SqlConnection SqlCon = new SqlConnection(SqlConjunction.DataConn); try { if (SqlCon.State != ConnectionState.Open) { SqlCon.Open(); } } catch (SqlException ex) { Console.WriteLine(ex); } SqlTransaction tn = SqlCon.BeginTransaction(); { try { this.InsertData(customerReturn, SqlCon, tn); int int_NoOfUnitsSale = 0; if (customerReturn.isCarton == true) { int_NoOfUnitsSale = (customerReturn.Qty * product.NoOfUnitsPerCarton); } else { int_NoOfUnitsSale = customerReturn.Qty; } DataTable dt_ProductInStoreTemp = obj_DALProductInStore.LoadProductInStoreTableByProductId(productInStore, SqlCon, tn); if (dt_ProductInStoreTemp.Rows.Count > 0) { int int_NoOfUnitsInStore = Convert.ToInt32(dt_ProductInStoreTemp.Rows[0][0].ToString()); productInStore.NoOfUnits = (int_NoOfUnitsInStore + int_NoOfUnitsSale); obj_DALProductInStore.UpdateData(productInStore, SqlCon, tn); } else { productInStore.NoOfUnits = (int_NoOfUnitsSale * (-1)); obj_DALProductInStore.InsertData(productInStore, SqlCon, tn); } tn.Commit(); int_Result = 1; } catch (Exception ex) { tn.Rollback(); int_Result = 0; throw (ex); } finally { obj_DALProductInStore = null; SqlCon.Close(); tn.Dispose(); } return(int_Result); } }
public int CancelDetailInvoice(DEInvoiceDetail invoiceDetail) { int int_Result = 0; DALProductInStore obj_DALProductInStore = new DALProductInStore(); DALProduct obj_DALProduct = new DALProduct(); DEProductInStore productInStore = new DEProductInStore(); productInStore.Product_Id = invoiceDetail.Product_Id; DEProduct product = new DEProduct(); product.Product_Id = invoiceDetail.Product_Id; obj_DALProduct.LoadProductRow(product); SqlConnection SqlCon = new SqlConnection(SqlConjunction.DataConn); try { if (SqlCon.State != ConnectionState.Open) { SqlCon.Open(); } } catch (SqlException ex) { Console.WriteLine(ex); } SqlTransaction tn = SqlCon.BeginTransaction(); { try { int int_NoOfUnitsSale = 0; if (invoiceDetail.isCarton) { int_NoOfUnitsSale = invoiceDetail.Qty * product.NoOfUnitsPerCarton; } else { int_NoOfUnitsSale = invoiceDetail.Qty; } DataTable dt_ProductInStoreTemp = obj_DALProductInStore.LoadProductInStoreTableByProductId(productInStore, SqlCon, tn); if (dt_ProductInStoreTemp.Rows.Count > 0) { int int_NoOfUnitsInStore = Convert.ToInt32(dt_ProductInStoreTemp.Rows[0][0].ToString()); productInStore.NoOfUnits = (int_NoOfUnitsInStore + int_NoOfUnitsSale); obj_DALProductInStore.UpdateData(productInStore, SqlCon, tn); } else { } this.updateActiveData(invoiceDetail, SqlCon, tn); tn.Commit(); int_Result = 1; } catch (Exception ex) { tn.Rollback(); int_Result = 0; throw (ex); } finally { obj_DALProductInStore = null; SqlCon.Close(); tn.Dispose(); } return(int_Result); } }