public static long PostTransaction(string catalog, long transactionMasterId, DateTime valueDate, int officeId, int userId, long loginId, int storeId, string partyCode, int priceTypeId, string referenceNumber, string statementReference, Collection <StockDetail> details, Collection <Attachment> attachments) { string detail = StockMasterDetailHelper.CreateStockMasterDetailParameter(details); string attachment = AttachmentHelper.CreateAttachmentModelParameter(attachments); string sql = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM transactions.post_sales_return(@TransactionMasterId::bigint, @OfficeId::integer, @UserId::integer, @LoginId::bigint, @ValueDate::date, @StoreId::integer, @PartyCode::national character varying(12), @PriceTypeId::integer, @ReferenceNumber::national character varying(24), @StatementReference::text, ARRAY[{0}], ARRAY[{1}]);", detail, attachment); using (NpgsqlCommand command = new NpgsqlCommand(sql)) { command.Parameters.AddWithValue("@TransactionMasterId", transactionMasterId); command.Parameters.AddWithValue("@OfficeId", officeId); command.Parameters.AddWithValue("@UserId", userId); command.Parameters.AddWithValue("@LoginId", loginId); command.Parameters.AddWithValue("@ValueDate", valueDate); command.Parameters.AddWithValue("@StoreId", storeId); command.Parameters.AddWithValue("@PartyCode", partyCode); command.Parameters.AddWithValue("@PriceTypeId", priceTypeId); command.Parameters.AddWithValue("@ReferenceNumber", referenceNumber); command.Parameters.AddWithValue("@StatementReference", statementReference); command.Parameters.AddRange(StockMasterDetailHelper.AddStockMasterDetailParameter(details).ToArray()); command.Parameters.AddRange(AttachmentHelper.AddAttachmentParameter(attachments).ToArray()); long tranId = Conversion.TryCastLong(DbOperation.GetScalarValue(catalog, command)); return(tranId); } }
public static long Add(string bookName, DateTime valueDate, int officeId, int userId, long loginId, int costCenterId, string referenceNumber, string statementReference, StockMaster stockMaster, Collection <StockDetail> details, Collection <Attachment> attachments, bool nonTaxable) { if (stockMaster == null) { return(0); } if (details == null) { return(0); } if (details.Count.Equals(0)) { return(0); } string detail = StockMasterDetailHelper.CreateStockMasterDetailParameter(details); string attachment = AttachmentHelper.CreateAttachmentModelParameter(attachments); string sql = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM transactions.post_sales(@BookName, @OfficeId, @UserId, @LoginId, @ValueDate, @CostCenterId, @ReferenceNumber, @StatementReference, @IsCredit, @PaymentTermId, @PartyCode, @PriceTypeId, @SalespersonId, @ShipperId, @ShippingAddressCode, @StoreId, @NonTaxable, ARRAY[{0}], ARRAY[{1}])", detail, attachment); using (NpgsqlCommand command = new NpgsqlCommand(sql)) { command.Parameters.AddWithValue("@BookName", bookName); command.Parameters.AddWithValue("@OfficeId", officeId); command.Parameters.AddWithValue("@UserId", userId); command.Parameters.AddWithValue("@LoginId", loginId); command.Parameters.AddWithValue("@ValueDate", valueDate); command.Parameters.AddWithValue("@CostCenterId", costCenterId); command.Parameters.AddWithValue("@ReferenceNumber", referenceNumber); command.Parameters.AddWithValue("@StatementReference", statementReference); command.Parameters.AddWithValue("@IsCredit", stockMaster.IsCredit); if (stockMaster.PaymentTermId.Equals(0)) { command.Parameters.AddWithValue("@PaymentTermId", DBNull.Value); } else { command.Parameters.AddWithValue("@PaymentTermId", stockMaster.PaymentTermId); } command.Parameters.AddWithValue("@PartyCode", stockMaster.PartyCode); command.Parameters.AddWithValue("@PriceTypeId", stockMaster.PriceTypeId); command.Parameters.AddWithValue("@SalespersonId", stockMaster.SalespersonId); command.Parameters.AddWithValue("@ShipperId", stockMaster.ShipperId); command.Parameters.AddWithValue("@ShippingAddressCode", stockMaster.ShippingAddressCode); command.Parameters.AddWithValue("@StoreId", stockMaster.StoreId); command.Parameters.AddWithValue("@NonTaxable", nonTaxable); command.Parameters.AddRange(StockMasterDetailHelper.AddStockMasterDetailParameter(details).ToArray()); command.Parameters.AddRange(AttachmentHelper.AddAttachmentParameter(attachments).ToArray()); long tranId = Conversion.TryCastLong(DbOperation.GetScalarValue(command)); return(tranId); } }
internal static long Add(string catalog, string book, DateTime valueDate, int officeId, int userId, long loginId, string referenceNumber, string statementReference, StockMaster stockMaster, Collection <StockDetail> details, Collection <long> transactionIdCollection, Collection <Attachment> attachments, bool nonTaxable) { if (stockMaster == null) { return(0); } if (details == null) { return(0); } if (details.Count.Equals(0)) { return(0); } string tranIds = ParameterHelper.CreateBigintArrayParameter(transactionIdCollection, "bigint", "@TranId"); string detail = StockMasterDetailHelper.CreateStockMasterDetailParameter(details); string attachment = AttachmentHelper.CreateAttachmentModelParameter(attachments); string sql = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM transactions.post_non_gl_transaction(@Book::national character varying(48), @OfficeId::integer, @UserId::integer, @LoginId::bigint, @ValueDate::date, @ReferenceNumber::national character varying(24), @StatementReference::text, @PartyCode::national character varying(12), @PriceTypeId::integer, @NonTaxable::boolean,@SalesPersonId::integer, @ShipperId::integer, @ShippingAddressCode::national character varying(12), @StoreId::integer, ARRAY[{0}]::bigint[], ARRAY[{1}], ARRAY[{2}]);", tranIds, detail, attachment); using (NpgsqlCommand command = new NpgsqlCommand(sql)) { command.Parameters.AddWithValue("@Book", book); command.Parameters.AddWithValue("@OfficeId", officeId); command.Parameters.AddWithValue("@UserId", userId); command.Parameters.AddWithValue("@LoginId", loginId); command.Parameters.AddWithValue("@ValueDate", valueDate); command.Parameters.AddWithValue("@ReferenceNumber", referenceNumber); command.Parameters.AddWithValue("@StatementReference", statementReference); command.Parameters.AddWithValue("@PartyCode", stockMaster.PartyCode); if (stockMaster.PriceTypeId.Equals(0)) { command.Parameters.AddWithValue("@PriceTypeId", DBNull.Value); } else { command.Parameters.AddWithValue("@PriceTypeId", stockMaster.PriceTypeId); } command.Parameters.AddWithValue("@NonTaxable", nonTaxable); command.Parameters.AddWithValue("@SalesPersonId", stockMaster.SalespersonId); command.Parameters.AddWithValue("@ShipperId", stockMaster.ShipperId); command.Parameters.AddWithValue("@ShippingAddressCode", stockMaster.ShippingAddressCode); command.Parameters.AddWithValue("@StoreId", stockMaster.StoreId); command.Parameters.AddRange(ParameterHelper.AddBigintArrayParameter(transactionIdCollection, "@TranId").ToArray()); command.Parameters.AddRange(StockMasterDetailHelper.AddStockMasterDetailParameter(details).ToArray()); command.Parameters.AddRange(AttachmentHelper.AddAttachmentParameter(attachments).ToArray()); long tranId = Conversion.TryCastLong(DbOperation.GetScalarValue(catalog, command)); return(tranId); } }