public void UpdateRecord(Objects.Purchase obj) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SP_PurchaseUpdate"; cmd.Parameters.AddWithValue("@PurchaseID", obj.PurchaseID); cmd.Parameters.AddWithValue("@PurchaseDate", obj.PurchaseDate); cmd.Parameters.AddWithValue("@OfficeID", obj.OfficeID); cmd.Parameters.AddWithValue("@VendorID", obj.VendorID); cmd.Parameters.AddWithValue("@BillNo", obj.BillNo); cmd.Parameters.AddWithValue("@BillDate", obj.BillDate); cmd.Parameters.AddWithValue("@IsUploaded", obj.IsUploaded); cmd.Parameters.AddWithValue("@PaidAmount", obj.PaidAmount); cmd.Parameters.AddWithValue("@Narration", obj.Narration); cmd.Parameters.AddWithValue("@SpecialDiscount", obj.SpecialDiscount); cmd.Parameters.AddWithValue("@CustomerId", obj.CustomerId); cmd.Parameters.AddWithValue("@GSTax", obj.GSTax); cmd.Parameters.AddWithValue("@PurOrderID", obj.PurOrderID); cmd.Parameters.AddWithValue("@InvOfferFTax", obj.InvOfferFTax); cmd.Parameters.AddWithValue("@OfferID", obj.OfferID); cmd.Parameters.AddWithValue("@Freight2", obj.Freight2); cmd.Parameters.AddWithValue("@Unloading2", obj.Unloading2); cmd.Parameters.AddWithValue("@ITax2", obj.ITax2); cmd.Parameters.AddWithValue("@BiltyNo", obj.BiltyNo); cmd.Parameters.AddWithValue("@PreviousBal", obj.PreviousBal); cmd.Parameters.AddWithValue("@FinalBalance", obj.FinalBalance); new Database(connectionstring).ExecuteNonQueryOnly(cmd); } catch (Exception exc) { throw exc; } }
public void UpdateRecord(Objects.Purchase obj) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SP_PurchaseUpdate"; cmd.Parameters.AddWithValue("@PurchaseID", obj.PurchaseID); cmd.Parameters.AddWithValue("@EntryDate", obj.EntryDate); cmd.Parameters.AddWithValue("@VendorID", obj.VendorID); cmd.Parameters.AddWithValue("@GrossValue", obj.GrossValue); cmd.Parameters.AddWithValue("@Narration", obj.Narration); cmd.Parameters.AddWithValue("@UserID", obj.UserID); cmd.Parameters.AddWithValue("@CashPaid", obj.CashPaid); new Database(connectionstring).ExecuteNonQueryOnly(cmd); } catch (Exception exc) { throw exc; } }
public void InsertRecord(Objects.Purchase obj) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SP_PurchaseInsert"; /**/ cmd.Parameters.AddWithValue("@PurchaseID", obj.PurchaseID); cmd.Parameters.AddWithValue("@PurchaseDate", obj.PurchaseDate); cmd.Parameters.AddWithValue("@OfficeID", obj.OfficeID); cmd.Parameters.AddWithValue("@VendorID", obj.VendorID); cmd.Parameters.AddWithValue("@BillNo", obj.BillNo); cmd.Parameters.AddWithValue("@BillDate", obj.BillDate); cmd.Parameters.AddWithValue("@IsUploaded", obj.IsUploaded); cmd.Parameters.AddWithValue("@PaidAmount", obj.PaidAmount); cmd.Parameters.AddWithValue("@Narration", obj.Narration); cmd.Parameters.AddWithValue("@SpecialDiscount", obj.SpecialDiscount); cmd.Parameters.AddWithValue("@CustomerId", obj.CustomerId); cmd.Parameters.AddWithValue("@GSTax", obj.GSTax); cmd.Parameters.AddWithValue("@PurOrderID", obj.PurOrderID); cmd.Parameters.AddWithValue("@InvOfferFTax", obj.InvOfferFTax); cmd.Parameters.AddWithValue("@OfferID", obj.OfferID); cmd.Parameters.AddWithValue("@Freight2", obj.Freight2); cmd.Parameters.AddWithValue("@Unloading2", obj.Unloading2); cmd.Parameters.AddWithValue("@ITax2", obj.ITax2); cmd.Parameters.AddWithValue("@BiltyNo", obj.BiltyNo); cmd.Parameters.AddWithValue("@PreviousBal", obj.PreviousBal); cmd.Parameters.AddWithValue("@FinalBalance", obj.FinalBalance); new Database(connectionstring).ExecuteNonQueryOnly(cmd); } catch (Exception exc) { throw exc; } } public void InsertRecordBody(Objects.PurchasesBody obj) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SP_PurchasesBodyInsert"; /**/ cmd.Parameters.AddWithValue("@PurchaseId", obj.PurchaseId); cmd.Parameters.AddWithValue("@ProductId", obj.ProductId); cmd.Parameters.AddWithValue("@PackingId", obj.PackingId); cmd.Parameters.AddWithValue("@Multiplier", obj.Multiplier); cmd.Parameters.AddWithValue("@QtyPack", obj.QtyPack); cmd.Parameters.AddWithValue("@QtyLose", obj.QtyLose); cmd.Parameters.AddWithValue("@BnsLose", obj.BnsLose); cmd.Parameters.AddWithValue("@PricePack", obj.PricePack); cmd.Parameters.AddWithValue("@DiscRatio", obj.DiscRatio); cmd.Parameters.AddWithValue("@DiscValPack", obj.DiscValPack); cmd.Parameters.AddWithValue("@DiscValLose", obj.DiscValLose); cmd.Parameters.AddWithValue("@OfferDiscount", obj.OfferDiscount); cmd.Parameters.AddWithValue("@STaxRatio", obj.STaxRatio); cmd.Parameters.AddWithValue("@STaxValPack", obj.STaxValPack); cmd.Parameters.AddWithValue("@IsValueB4Ratio", obj.IsValueB4Ratio); cmd.Parameters.AddWithValue("@IsSTaxOnBns", obj.IsSTaxOnBns); cmd.Parameters.AddWithValue("@IsFTaxExempted", obj.IsFTaxExempted); cmd.Parameters.AddWithValue("@TTLValue", obj.TTLValue); cmd.Parameters.AddWithValue("@TTLSTax", obj.TTLSTax); cmd.Parameters.AddWithValue("@TTLFTax", obj.TTLFTax); cmd.Parameters.AddWithValue("@ExtraSTaxBns", obj.ExtraSTaxBns); cmd.Parameters.AddWithValue("@ExtraFTaxBns", obj.ExtraFTaxBns); cmd.Parameters.AddWithValue("@PerUnitCostLose", obj.PerUnitCostLose); cmd.Parameters.AddWithValue("@IsFreeProduct", obj.IsFreeProduct); cmd.Parameters.AddWithValue("@IsDeleted", obj.IsDeleted); cmd.Parameters.AddWithValue("@CustomerId", obj.CustomerId); cmd.Parameters.AddWithValue("@OfferID", obj.OfferID); cmd.Parameters.AddWithValue("@IsOffered", obj.IsOffered); cmd.Parameters.AddWithValue("@Damage", obj.Damage); cmd.Parameters.AddWithValue("@BarCode", obj.BarCode); new Database(connectionstring).ExecuteNonQueryOnly(cmd); } catch (Exception exc) { throw exc; } }
private void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtVendorID.Text.Trim())) { MessageBox.Show("Please Insert/Select Vendor", "Information Missing"); txtVendorID.Focus(); return; } if (Grid.Rows.Count == 0) { MessageBox.Show("Please Insert Products Information", "Detail Missing"); txt_ProductID.Focus(); return; } decimal vCashPaid = 0; decimal.TryParse(txtCashPaid.Text, out vCashPaid); Objects.Purchase BAL = new Objects.Purchase(); BAL.PurchaseID = Int64.Parse(txt_InvNo.Text); BAL.EntryDate = dt_Entry.Value; BAL.VendorID = Int64.Parse(txtVendorID.Text); BAL.GrossValue = decimal.Parse(txt_Gross.Text, System.Globalization.NumberStyles.AllowDecimalPoint); BAL.CashPaid = vCashPaid; BAL.Narration = txt_Narration.Text; BAL.UserID = vUserID; if (vOpenMode) { objDAL.UpdateRecord(BAL); objDAL.DeleteRecordBody(Int64.Parse(txt_InvNo.Text)); } else { BAL.PurchaseID = objDAL.getNextNo(); objDAL.InsertRecord(BAL); } //Save Detail foreach (DataGridViewRow dr in Grid.Rows) { if (dr.Cells[0].Value != null) { Objects.PurchaseBody objBody = new Objects.PurchaseBody(); objBody.PurchaseID = Int64.Parse(txt_InvNo.Text); objBody.ProductID = Int64.Parse(dr.Cells["ProductID"].Value.ToString()); objBody.Qty = decimal.Parse(dr.Cells["Qty"].Value.ToString()); objBody.Price = decimal.Parse(dr.Cells["Price"].Value.ToString()); objBody.Discount = decimal.Parse(dr.Cells["Disc"].Value.ToString()); objBody.TotalValue = decimal.Parse(dr.Cells["TotalValue"].Value.ToString()); objDAL.InsertRecordBody(objBody); } } MessageBox.Show("Record Saved Successfully.", "Task Completed"); SetMode(false); } catch (Exception exc) { MessageBox.Show(exc.Message.ToString(), "Error"); } }