public int UnAssignCourse() { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.CommandText = "UPDATE t_CourseAssignToTeacher SET IsActive=0"; CommandObj.Transaction = sqlTransaction; CommandObj.ExecuteNonQuery(); teacherGateway.UpdateTeacherInformation(); int a = ResetStudentResult(); int i = UnAssignStudentCourse(); sqlTransaction.Commit(); return(i); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Failed to Unassign course", exception); } finally { CommandObj.Dispose(); ConnectionObj.Close(); } }
public int Update(EnrollStudentInCourse enrollStudentInCourse) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UPDATE t_StudentEnrollInCourse SET IsStudentActive=1 WHERE StudentId='" + enrollStudentInCourse.StudentId + "' AND CourseId='" + enrollStudentInCourse.CourseId + "'"; int updateResult = CommandObj.ExecuteNonQuery(); // int updateResult = UpdateStudentEnrolledCourses(enrollStudentInCourse); sqlTransaction.Commit(); return(updateResult); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Could not save", exception); } finally { CommandObj.Dispose(); ConnectionObj.Close(); } }
public int Insert(CourseAssignToTeacher courseAssign) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "INSERT INTO t_CourseAssignToTeacher VALUES(@deptId,@teacherId,@courseId,@status)"; CommandObj.Parameters.Clear(); CommandObj.Parameters.AddWithValue("@deptId", courseAssign.DepartmentId); CommandObj.Parameters.AddWithValue("@teacherId", courseAssign.TeacherId); CommandObj.Parameters.AddWithValue("@courseId", courseAssign.CourseId); CommandObj.Parameters.AddWithValue("@status", 1); int rowAffected = CommandObj.ExecuteNonQuery(); int updateResult = UpdateTeacher(courseAssign); sqlTransaction.Commit(); return(rowAffected); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Could not save", exception); } finally { CommandObj.Dispose(); ConnectionObj.Close(); } }
public int Update(CourseAssignToTeacher courseAssign) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UPDATE t_CourseAssignToTeacher SET IsActive=1 WHERE TeacherId='" + courseAssign.TeacherId + "' AND CourseId='" + courseAssign.CourseId + "'"; CommandObj.ExecuteNonQuery(); int updateResult = UpdateTeacher(courseAssign); sqlTransaction.Commit(); return(updateResult); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Could not save", exception); } finally { CommandObj.Dispose(); ConnectionObj.Close(); } }
public int UnAllocateClassRoom() { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.CommandText = "UPDATE t_AllocateClassRoom SET AllocationStatus=0"; CommandObj.Transaction = sqlTransaction; int i = CommandObj.ExecuteNonQuery(); sqlTransaction.Commit(); return(i); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Failed to UnAllocate Class Room", exception); } finally { CommandObj.Dispose(); ConnectionObj.Close(); } }
public int SaveDispatchInformation(DispatchModel dispatchModel) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Parameters.Clear(); CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UDSP_SaveDispatchInformation"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@DispatchDate", dispatchModel.DispatchDate); CommandObj.Parameters.AddWithValue("@TripId", dispatchModel.TripModel.TripId); CommandObj.Parameters.AddWithValue("@TripStatus", dispatchModel.TripModel.Status); //CommandObj.Parameters.AddWithValue("@RequisitionId", dispatchModel.TripModel.RequisitionId); //CommandObj.Parameters.AddWithValue("@ToBranchId", dispatchModel.TripModel.ToBranchId); //CommandObj.Parameters.AddWithValue("@ProductId", dispatchModel.TripModel.ProuctId); CommandObj.Parameters.AddWithValue("@TransactionRef", dispatchModel.TripModel.TripRef); CommandObj.Parameters.AddWithValue("@Quantity", dispatchModel.ScannedProducts.ToList().Count); CommandObj.Parameters.AddWithValue("@DispatchRef", dispatchModel.DispatchRef); CommandObj.Parameters.AddWithValue("@CompanyId", dispatchModel.CompanyId); CommandObj.Parameters.AddWithValue("@DispatchByUserId", dispatchModel.DispatchByUserId); CommandObj.Parameters.Add("@DispatchId", SqlDbType.BigInt); CommandObj.Parameters["@DispatchId"].Direction = ParameterDirection.Output; CommandObj.Parameters.Add("@InventoryMasterId", SqlDbType.BigInt); CommandObj.Parameters["@InventoryMasterId"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); long dispatchId = Convert.ToInt64(CommandObj.Parameters["@DispatchId"].Value); long inventoryMasterId = Convert.ToInt64(CommandObj.Parameters["@InventoryMasterId"].Value); int rowAffected = SaveDispatchInformationDetails(dispatchModel, dispatchId, inventoryMasterId); if (rowAffected > 0) { sqlTransaction.Commit(); } else { sqlTransaction.Rollback(); } return(rowAffected); } catch (Exception exception) { Log.WriteErrorLog(exception); sqlTransaction.Rollback(); throw new Exception("Could not Save dispatch Info", exception); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }
public int Save(IEnumerable <OrderItem> orderItems, Invoice anInvoice) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "spSaveInvoicedOrder"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@InvoiceDateTime", anInvoice.InvoiceDateTime); CommandObj.Parameters.AddWithValue("@InvoiceRef", anInvoice.InvoiceRef); CommandObj.Parameters.AddWithValue("@TransactionRef", anInvoice.TransactionRef); CommandObj.Parameters.AddWithValue("@InvoiceNo", anInvoice.InvoiceNo); CommandObj.Parameters.AddWithValue("@TotalQuantity", orderItems.Sum(n => n.Quantity)); CommandObj.Parameters.AddWithValue("@ClientId", anInvoice.ClientId); CommandObj.Parameters.AddWithValue("@InvoiceByUserId", anInvoice.InvoiceByUserId); CommandObj.Parameters.AddWithValue("@BranchId", anInvoice.BranchId); CommandObj.Parameters.AddWithValue("@CompanyId", anInvoice.CompanyId); CommandObj.Parameters.AddWithValue("@VoucherNo", anInvoice.VoucherNo); CommandObj.Parameters.Add("@InvoiceId", SqlDbType.Int); CommandObj.Parameters["@InvoiceId"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); var invoiceId = Convert.ToInt32(CommandObj.Parameters["@InvoiceId"].Value); var rowAffected = SaveInvoiceDetails(orderItems, invoiceId); if (rowAffected > 0) { sqlTransaction.Commit(); } return(rowAffected); } catch (SqlException sqlException) { sqlTransaction.Rollback(); Log.WriteErrorLog(sqlException); throw new Exception("Could not Save Invoiced order info due to sql exception", sqlException); } catch (Exception exception) { sqlTransaction.Rollback(); Log.WriteErrorLog(exception); throw new Exception("Could not Save Invoiced order info", exception); } finally { CommandObj.Parameters.Clear(); CommandObj.Dispose(); ConnectionObj.Close(); } }
public int SaveReplacementInfo(ReplaceModel model) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UDSP_SaveReplacementInfo"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@ClientId", model.ClientId); CommandObj.Parameters.AddWithValue("@ReplaceRef", model.ReplaceRef); CommandObj.Parameters.AddWithValue("@ReplaceNo", model.ReplaceNo); CommandObj.Parameters.AddWithValue("@TransactionRef", model.ReplaceRef); CommandObj.Parameters.AddWithValue("@BranchId", model.BranchId); CommandObj.Parameters.AddWithValue("@DistributionPointId", model.DistributionPointId); CommandObj.Parameters.AddWithValue("@Remarks", model.Remarks); CommandObj.Parameters.AddWithValue("@CompanyId", model.CompanyId); CommandObj.Parameters.AddWithValue("@UserId", model.UserId); CommandObj.Parameters.Add("@ReplaceMasterId", SqlDbType.BigInt); CommandObj.Parameters["@ReplaceMasterId"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); var masterId = Convert.ToInt64(CommandObj.Parameters["@ReplaceMasterId"].Value); var rowAffected = SaveReplacementDetails(model, masterId); if (rowAffected > 0) { sqlTransaction.Commit(); } return(rowAffected); } catch (Exception exception) { Log.WriteErrorLog(exception); sqlTransaction.Rollback(); throw new Exception("Could not save Replace Info", exception); } finally { CommandObj.Dispose(); ConnectionObj.Close(); CommandObj.Parameters.Clear(); } }
public int SaveBarCodes(ViewCreateBarCodeModel model) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UDSP_AddBarCodeMaster"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@ProductId", model.ProductId); CommandObj.Parameters.AddWithValue("@ProductionDate", model.ProductionDate); CommandObj.Parameters.AddWithValue("@LineNumber", model.ProductionLineId.ToString("D2")); CommandObj.Parameters.AddWithValue("@Quantity", model.BarCodes.Count); CommandObj.Parameters.AddWithValue("@GenerateByUserId", model.GenerateByUserId); CommandObj.Parameters.Add("@BarCodeMasterId", SqlDbType.BigInt); CommandObj.Parameters["@BarCodeMasterId"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); var barCodeMasterId = Convert.ToInt64(CommandObj.Parameters["@BarCodeMasterId"].Value); int result = AddBarCode(model, barCodeMasterId); if (result > 0) { sqlTransaction.Commit(); } return(result); } catch (SqlException sqlException) { sqlTransaction.Rollback(); throw new Exception("Could not Save Order due to sql exception", sqlException); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Could not Save Order", exception); } finally { CommandObj.Parameters.Clear(); CommandObj.Dispose(); ConnectionObj.Close(); } }
public int UnAssignDistrictFromRegion(ViewRegion regionDetails, string reason, ViewUser user) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Parameters.Clear(); CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UDSP_UnAssignDistrictFromRegion"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@RegionDetailsId", regionDetails.RegionDetailsId); CommandObj.Parameters.AddWithValue("@Reason", reason); CommandObj.Parameters.AddWithValue("@UnAssignedByUserId", user.UserId); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; // var parameters = CommandObj.Parameters; CommandObj.ExecuteNonQuery(); var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); int result = UnAssignUpazilla(regionDetails); if (result > 0) { sqlTransaction.Commit(); } return(rowAffected); } catch (SqlException sqlException) { sqlTransaction.Rollback(); throw new Exception("Could not UnAssign district due to Sql Exception", sqlException); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Could not UnAssign district", exception); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }
public int SaveScrap(ScrapModel model) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Parameters.Clear(); CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UDSP_SaveScrapProduct"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@UserId", model.UserId); CommandObj.Parameters.AddWithValue("@BranchId", model.BranchId); CommandObj.Parameters.AddWithValue("@CompanyId", model.CompanyId); CommandObj.Parameters.AddWithValue("@TransactionRef", model.TransactionRef); CommandObj.Parameters.AddWithValue("@TransactionType", model.TransactionType); CommandObj.Parameters.AddWithValue("@TransactionDate", model.TransactionDate); CommandObj.Parameters.Add("@MasterId", SqlDbType.BigInt); CommandObj.Parameters["@MasterId"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); long masterId = Convert.ToInt32(CommandObj.Parameters["@MasterId"].Value); var rowAffected = SaveScrapProductToScrapInventory(model, masterId); if (rowAffected > 0) { sqlTransaction.Commit(); } return(rowAffected); } catch (Exception exception) { sqlTransaction.Rollback(); Log.WriteErrorLog(exception); throw new Exception("Could not save Scrap product Info", exception); } finally { CommandObj.Dispose(); ConnectionObj.Close(); CommandObj.Parameters.Clear(); } }
public int AssignRegionToBranch(Branch branch, ViewUser user) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { int rowAffected = 0; foreach (var item in branch.RegionList) { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "spAssignNewRegionToBranch"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@BranchId", branch.BranchId); CommandObj.Parameters.AddWithValue("@RegionId", item.RegionId); CommandObj.Parameters.AddWithValue("@UserId", user.UserId); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); rowAffected += Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); CommandObj.Parameters.Clear(); } sqlTransaction.Commit(); return(rowAffected); } catch (Exception e) { sqlTransaction.Rollback(); throw new Exception("Could not assign division or dristict to regions", e); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }
public int AssignUpazillaToTerritory(Territory aTerritory) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { int rowAffected = 0; foreach (var item in aTerritory.UpazillaList) { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "spAddNewUpazillaToTerritory"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@UpazillaId", item.UpazillaId); CommandObj.Parameters.AddWithValue("@TerritoryId", aTerritory.TerritoryId); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); rowAffected += Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); CommandObj.Parameters.Clear(); } sqlTransaction.Commit(); return(rowAffected); } catch (Exception e) { sqlTransaction.Rollback(); throw new Exception("Could not assign dristict or upazila to territory", e); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }
public int AssignDristrictToRegion(Region aRegion) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { int rowAffected = 0; foreach (var item in aRegion.Districts) { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "spAddNewDistrictToRegion"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@DistrictId", item.DistrictId); CommandObj.Parameters.AddWithValue("@RegionId", aRegion.RegionId); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); rowAffected += Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); CommandObj.Parameters.Clear(); } sqlTransaction.Commit(); return(rowAffected); } catch (Exception e) { sqlTransaction.Rollback(); throw new Exception("Could not assign division or dristict to regions", e); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }
public int Save(IEnumerable <OrderItem> orderItems, Invoice anInvoice) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { int accountAffected = 0; CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "spSaveInvoicedOrder"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@InvoiceDateTime", anInvoice.InvoiceDateTime); CommandObj.Parameters.AddWithValue("@InvoiceRef", anInvoice.InvoiceRef); CommandObj.Parameters.AddWithValue("@TransactionRef", anInvoice.TransactionRef); CommandObj.Parameters.AddWithValue("@InvoiceNo", anInvoice.InvoiceNo); CommandObj.Parameters.AddWithValue("@TotalQuantity", orderItems.Sum(n => n.Quantity)); CommandObj.Parameters.AddWithValue("@ClientId", anInvoice.ClientId); CommandObj.Parameters.AddWithValue("@InvoiceByUserId", anInvoice.InvoiceByUserId); CommandObj.Parameters.AddWithValue("@BranchId", anInvoice.BranchId); CommandObj.Parameters.AddWithValue("@CompanyId", anInvoice.CompanyId); CommandObj.Parameters.AddWithValue("@VoucherNo", anInvoice.VoucherNo); CommandObj.Parameters.Add("@InvoiceId", SqlDbType.Int); CommandObj.Parameters["@InvoiceId"].Direction = ParameterDirection.Output; CommandObj.Parameters.Add("@AccountMasterId", SqlDbType.Int); CommandObj.Parameters["@AccountMasterId"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); int invoiceId = Convert.ToInt32(CommandObj.Parameters["@InvoiceId"].Value); int accountMasterId = Convert.ToInt32(CommandObj.Parameters["@AccountMasterId"].Value); int rowAffected = SaveInvoiceDetails(orderItems, invoiceId); if (rowAffected > 0) { for (int i = 1; i <= 2; i++) { if (i == 1) { anInvoice.TransactionType = "Dr"; anInvoice.SubSubSubAccountCode = anInvoice.ClientAccountCode; } else { anInvoice.TransactionType = "Cr"; anInvoice.Amounts = anInvoice.Amounts * (-1); anInvoice.SubSubSubAccountCode = "1001021"; } accountAffected += SaveInvoiceDetailsToAccountsDetails(anInvoice, accountMasterId); } if (anInvoice.SpecialDiscount != 0) { for (int i = 1; i <= 2; i++) { if (i == 1) { anInvoice.TransactionType = "Dr"; anInvoice.Amounts = anInvoice.SpecialDiscount; anInvoice.SubSubSubAccountCode = anInvoice.DiscountAccountCode; } else { anInvoice.TransactionType = "Cr"; anInvoice.Amounts = anInvoice.SpecialDiscount * (-1); anInvoice.SubSubSubAccountCode = anInvoice.ClientAccountCode; } accountAffected += SaveInvoiceDetailsToAccountsDetails(anInvoice, accountMasterId); } } //if (anInvoice.Discount != 0) //{ // for (int i = 1; i <= 2; i++) // { // if (i == 1) // { // anInvoice.TransactionType = "Dr"; // anInvoice.Amounts = anInvoice.Discount; // anInvoice.SubSubSubAccountCode = "2601041"; // } // else // { // anInvoice.TransactionType = "Cr"; // anInvoice.Amounts = anInvoice.Discount * (-1); // anInvoice.SubSubSubAccountCode = anInvoice.ClientAccountCode; // } // accountAffected += SaveInvoiceDetailsToAccountsDetails(anInvoice, accountMasterId); // } //} } if (accountAffected > 0) { sqlTransaction.Commit(); } return(accountAffected); } catch (SqlException sqlException) { sqlTransaction.Rollback(); throw new Exception("Could not Save Invoiced order info due to sql exception", sqlException); } catch (Exception exception) { sqlTransaction.Rollback(); throw new Exception("Could not Save Invoiced order info", exception); } finally { CommandObj.Parameters.Clear(); CommandObj.Dispose(); ConnectionObj.Close(); } }
//-------------Save General Requisition From Factory-------------------------------- public int SaveDeliveredGeneralRequisition(List <ScannedProduct> scannedProducts, Delivery aDelivery) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Parameters.Clear(); CommandObj.Transaction = sqlTransaction; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.CommandText = "UDSP_SaveDeliveredRequisitionFromFactory"; CommandObj.Parameters.AddWithValue("@TransactionDate", aDelivery.DeliveryDate); CommandObj.Parameters.AddWithValue("@TransactionRef", aDelivery.TransactionRef); CommandObj.Parameters.AddWithValue("@DeliveryRef", aDelivery.DeliveryRef); CommandObj.Parameters.AddWithValue("@IsOwnTransporatoion", aDelivery.IsOwnTransport); CommandObj.Parameters.AddWithValue("@Transportation", aDelivery.Transportation ?? "N/A"); CommandObj.Parameters.AddWithValue("@DriverName", aDelivery.DriverName ?? "N/A"); CommandObj.Parameters.AddWithValue("@DriverPhone", aDelivery.DriverPhone ?? "N/A"); CommandObj.Parameters.AddWithValue("@TransportationCost", aDelivery.TransportationCost); CommandObj.Parameters.AddWithValue("@VehicleNo", aDelivery.VehicleNo ?? "N/A"); CommandObj.Parameters.AddWithValue("@ToBranchId", aDelivery.ToBranchId); CommandObj.Parameters.AddWithValue("@CompanyId", aDelivery.CompanyId); CommandObj.Parameters.AddWithValue("@UserId", aDelivery.DeliveredByUserId); CommandObj.Parameters.AddWithValue("@Quantity", scannedProducts.Count); CommandObj.Parameters.Add("@AccountMasterId", SqlDbType.BigInt); CommandObj.Parameters.Add("@InventoryMasterId", SqlDbType.BigInt); CommandObj.Parameters["@AccountMasterId"].Direction = ParameterDirection.Output; CommandObj.Parameters["@InventoryMasterId"].Direction = ParameterDirection.Output; CommandObj.Parameters.Add("@DeliveryId", SqlDbType.Int); CommandObj.Parameters["@DeliveryId"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); int deliveryId = Convert.ToInt32(CommandObj.Parameters["@DeliveryId"].Value); var accountMasterId = Convert.ToInt32(CommandObj.Parameters["@AccountMasterId"].Value); var inventoryMasterId = Convert.ToInt32(CommandObj.Parameters["@InventoryMasterId"].Value); int rowAffected = SaveDeliveredRequisitionDetails(scannedProducts, aDelivery, inventoryMasterId, deliveryId); int accountAffected = 0; if (rowAffected > 0) { var financial = aDelivery.FinancialTransactionModel; for (int i = 1; i <= 2; i++) { if (i == 1) { accountAffected += SaveFinancialTransactionToAccountsDetails("Dr", financial.ExpenceCode, financial.ExpenceAmount, accountMasterId, "Expence code Debit.."); } else if (i == 2) { accountAffected += SaveFinancialTransactionToAccountsDetails("Cr", financial.InventoryCode, financial.InventoryAmount * (-1), accountMasterId, "Inventory code Credit.."); } } } if (accountAffected > 0) { sqlTransaction.Commit(); } else { sqlTransaction.Rollback(); } return(rowAffected); } catch (Exception exception) { Log.WriteErrorLog(exception); throw new Exception("Could not save delivered General Requisition", exception); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }