public static void AddColumns(GridView grid, SubTranBook book) { grid.Columns.Clear(); AddTemplateFields(grid); GridViewHelper.AddDataBoundControl(grid, "Id", Titles.Id); GridViewHelper.AddDataBoundControl(grid, "ValueDate", Titles.ValueDate, "{0:d}"); GridViewHelper.AddDataBoundControl(grid, "Office", Titles.Office); GridViewHelper.AddDataBoundControl(grid, "ReferenceNumber", Titles.ReferenceNumber); GridViewHelper.AddDataBoundControl(grid, "Party", Titles.Party); if (book != SubTranBook.Receipt) { GridViewHelper.AddDataBoundControl(grid, "PriceType", Titles.PriceType); } GridViewHelper.AddDataBoundControl(grid, "Amount", Titles.Amount); GridViewHelper.AddDataBoundControl(grid, "TransactionTs", Titles.TransactionTimestamp, "{0:d}"); GridViewHelper.AddDataBoundControl(grid, "User", Titles.User); GridViewHelper.AddDataBoundControl(grid, "StatementReference", Titles.StatementReference); if (book != SubTranBook.Receipt) { GridViewHelper.AddDataBoundControl(grid, "book", Titles.Book); } GridViewHelper.AddDataBoundControl(grid, "FlagBackgroundColor", Titles.FlagBackgroundColor); GridViewHelper.AddDataBoundControl(grid, "FlagForegroundColor", Titles.FlagForegroundColor); }
public static void AddColumns(GridView grid, SubTranBook book) { grid.Columns.Clear(); AddTemplateFields(grid); AddDataBoundControl(grid, "id", Titles.Id, ""); AddDataBoundControl(grid, "value_date", Titles.ValueDate, "{0:d}"); AddDataBoundControl(grid, "office", Titles.Office, ""); AddDataBoundControl(grid, "reference_number", Titles.ReferenceNumber, ""); AddDataBoundControl(grid, "party", Titles.Party, ""); if (book != SubTranBook.Receipt) { AddDataBoundControl(grid, "price_type", Titles.PriceType, ""); } AddDataBoundControl(grid, "amount", Titles.Amount, ""); AddDataBoundControl(grid, "transaction_ts", Titles.TransactionTimestamp, "{0:d}"); AddDataBoundControl(grid, "user", Titles.User, ""); AddDataBoundControl(grid, "statement_reference", Titles.StatementReference, ""); if (book != SubTranBook.Receipt) { AddDataBoundControl(grid, "book", Titles.Book, ""); } AddDataBoundControl(grid, "flag_background_color", Titles.FlagBackgroundColor, ""); AddDataBoundControl(grid, "flag_foreground_color", Titles.FlagForegroundColor, ""); }
private static NpgsqlCommand GetViewCommand(TranBook tranBook, SubTranBook subTranBook, Collection <int> ids) { if (tranBook == TranBook.Sales) { switch (subTranBook) { case SubTranBook.Delivery: break; case SubTranBook.Direct: break; case SubTranBook.Invoice: break; case SubTranBook.Order: return(SalesOrder.GetSalesOrderViewCommand(ids)); case SubTranBook.Payment: throw new InvalidOperationException(Common.Helpers.LocalizationHelper.GetResourceString("Errors", "InvalidSubTranBookSalesPayment")); case SubTranBook.Quotation: return(SalesQuotation.GetSalesQuotationViewCommand(ids)); case SubTranBook.Receipt: break; case SubTranBook.Return: break; } } switch (subTranBook) { case SubTranBook.Delivery: throw new InvalidOperationException(Common.Helpers.LocalizationHelper.GetResourceString("Errors", "InvalidSubTranBookPurchaseDelivery")); case SubTranBook.Direct: break; case SubTranBook.Invoice: break; case SubTranBook.Order: break; case SubTranBook.Payment: break; case SubTranBook.Quotation: throw new InvalidOperationException(Common.Helpers.LocalizationHelper.GetResourceString("Errors", "InvalidSubTranBookPurchaseQuotation")); case SubTranBook.Receipt: throw new InvalidOperationException(Common.Helpers.LocalizationHelper.GetResourceString("Errors", "InvalidSubTranBookPurchaseReceipt")); } return(null); }
private static NpgsqlCommand GetViewCommand(TranBook tranBook, SubTranBook subTranBook, Collection <long> ids) { if (tranBook == TranBook.Sales) { switch (subTranBook) { case SubTranBook.Delivery: break; case SubTranBook.Direct: break; case SubTranBook.Invoice: break; case SubTranBook.Order: return(SalesOrder.GetSalesOrderViewCommand(ids)); case SubTranBook.Payment: throw new InvalidOperationException(Errors.InvalidSubTranBookSalesPayment); case SubTranBook.Quotation: return(SalesQuotation.GetSalesQuotationViewCommand(ids)); case SubTranBook.Receipt: break; case SubTranBook.Return: break; } } switch (subTranBook) { case SubTranBook.Delivery: throw new InvalidOperationException(Errors.InvalidSubTranBookPurchaseDelivery); case SubTranBook.Direct: break; case SubTranBook.Invoice: break; case SubTranBook.Order: return(PurchaseOrder.GetPurchaseOrderViewCommand(ids)); case SubTranBook.Payment: break; case SubTranBook.Quotation: throw new InvalidOperationException(Errors.InvalidSubTranBookPurchaseQuotation); case SubTranBook.Receipt: throw new InvalidOperationException(Errors.InvalidSubTranBookPurchaseReceipt); } return(null); }
public static string GetEmailAddress(string catalog, TranBook tranBook, SubTranBook subTranBook, long tranId) { string sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.non_gl_stock_master WHERE non_gl_stock_master_id=@TranId;"; if (subTranBook == SubTranBook.Direct || subTranBook == SubTranBook.Receipt || subTranBook == SubTranBook.Invoice || subTranBook == SubTranBook.Return) { sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.stock_master WHERE transaction_master_id=@TranId;"; } using (NpgsqlCommand command = new NpgsqlCommand(sql)) { command.Parameters.AddWithValue("@TranId", tranId); return Conversion.TryCastString(DbOperation.GetScalarValue(catalog, command)); } }
public static string GetEmailAddress(TranBook tranBook, SubTranBook subTranBook, long tranId) { string sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.non_gl_stock_master WHERE non_gl_stock_master_id=@TranId;"; if (subTranBook == SubTranBook.Direct || subTranBook == SubTranBook.Receipt || subTranBook == SubTranBook.Invoice || subTranBook == SubTranBook.Return) { sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.stock_master WHERE transaction_master_id=@TranId;"; } using (NpgsqlCommand command = new NpgsqlCommand(sql)) { command.Parameters.AddWithValue("@TranId", tranId); return(Conversion.TryCastString(DbOperations.GetScalarValue(command))); } }
public static string GetEmailAddress(string catalog, TranBook tranBook, SubTranBook subTranBook, long tranId) { string sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.non_gl_stock_master WHERE non_gl_stock_master_id=@0::bigint;"; if (subTranBook == SubTranBook.Delivery || subTranBook == SubTranBook.Direct || subTranBook == SubTranBook.Invoice || subTranBook == SubTranBook.Return) { sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.stock_master WHERE transaction_master_id=@0::bigint;"; } if (subTranBook == SubTranBook.Receipt) { sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.customer_receipts WHERE transaction_master_id=@0::bigint;"; } return(Factory.Scalar <string>(catalog, sql, tranId)); }
public static string GetEmailAddress(string catalog, TranBook tranBook, SubTranBook subTranBook, long tranId) { string sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.non_gl_stock_master WHERE non_gl_stock_master_id=@0::bigint;"; if (subTranBook == SubTranBook.Delivery || subTranBook == SubTranBook.Direct || subTranBook == SubTranBook.Invoice || subTranBook == SubTranBook.Return) { sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.stock_master WHERE transaction_master_id=@0::bigint;"; } if (subTranBook == SubTranBook.Receipt) { sql = "SELECT core.get_email_address_by_party_id(party_id) FROM transactions.customer_receipts WHERE transaction_master_id=@0::bigint;"; } return Factory.Scalar<string>(catalog, sql, tranId); }
public static MergeModel GetMergeModel(string catalog, Collection<long> ids, TranBook tranBook, SubTranBook subTranBook) { int rowIndex = 0; if (ids == null) { return new MergeModel(); } if (ids.Count.Equals(0)) { return new MergeModel(); } MergeModel model = new MergeModel(); foreach (long tranId in ids) { model.AddTransactionIdToCollection(tranId); } model.Book = tranBook; model.SubBook = subTranBook; using (NpgsqlConnection connection = new NpgsqlConnection(DbConnection.GetConnectionString(catalog))) { using (NpgsqlCommand command = GetViewCommand(tranBook, subTranBook, ids)) { command.Connection = connection; command.Connection.Open(); NpgsqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); if (!reader.HasRows) { return new MergeModel(); } while (reader.Read()) { if (rowIndex.Equals(0)) { model.ValueDate = Conversion.TryCastDate(Reader(reader,"value_date")); model.PartyCode = Conversion.TryCastString(Reader(reader,"party_code")); model.PriceTypeId = Conversion.TryCastInteger(Reader(reader,"price_type_id")); model.ReferenceNumber = Conversion.TryCastString(Reader(reader,"reference_number")); model.NonTaxableSales = Conversion.TryCastBoolean(Reader(reader, "non_taxable")); model.ShippingCompanyId = Conversion.TryCastInteger(Reader(reader,"shipper_id")); model.SalesPersonId = Conversion.TryCastInteger(Reader(reader,"salesperson_id")); model.StoreId = Conversion.TryCastInteger(Reader(reader,"store_id")); model.ShippingAddressCode = Conversion.TryCastString(Reader(reader,"shipping_address_code")); model.StatementReference = Conversion.TryCastString(Reader(reader,"statement_reference")); } ProductDetail product = new ProductDetail(); product.ItemCode = Conversion.TryCastString(Reader(reader,"item_code")); product.ItemName = Conversion.TryCastString(Reader(reader,"item_name")); product.Unit = Conversion.TryCastString(Reader(reader,"unit_name")); product.Quantity = Conversion.TryCastInteger(Reader(reader,"quantity")); product.Price = Conversion.TryCastDecimal(Reader(reader,"price")); product.Amount = product.Quantity * product.Price; product.Discount = Conversion.TryCastDecimal(Reader(reader,"discount")); product.ShippingCharge = Conversion.TryCastDecimal(Reader(reader,"shipping_charge")); product.Subtotal = product.Amount - product.Discount - product.ShippingCharge; product.TaxCode = Conversion.TryCastString(Reader(reader,"tax_code")); product.Tax = Conversion.TryCastDecimal(Reader(reader,"tax")); product.Total = product.Subtotal + product.Tax; model.AddViewToCollection(product); rowIndex++; } } } if (ids.Count > 0) { if (!string.IsNullOrWhiteSpace(model.StatementReference)) { model.StatementReference += Environment.NewLine; } model.StatementReference += "(" + Entities.Helpers.TransactionBookHelper.GetBookAcronym(tranBook, subTranBook) + "# " + string.Join(",", ids) + ")"; } return model; }
public static string GetInvariantTransactionBookName(TranBook book, SubTranBook subBook) { string bookName = string.Empty; if (book == TranBook.Sales) { switch (subBook) { case SubTranBook.Delivery: bookName = "Sales.Delivery"; break; case SubTranBook.Direct: bookName = "Sales.Direct"; break; case SubTranBook.Invoice: bookName = "Sales.Invoice"; break; case SubTranBook.Order: bookName = "Sales.Order"; break; case SubTranBook.Payment: throw new MixERPException(Warnings.InvalidSubTranBookSalesPayment); case SubTranBook.Quotation: bookName = "Sales.Quotation"; break; case SubTranBook.Receipt: bookName = "Sales.Receipt"; break; case SubTranBook.Return: bookName = "Sales.Return"; break; case SubTranBook.Transfer: throw new MixERPException(Warnings.InvalidSubTranBookSalesTransfer); case SubTranBook.Suspense: throw new MixERPException(Warnings.InvalidSubTranBookSalesSuspense); } } if (book == TranBook.Purchase) { switch (subBook) { case SubTranBook.Delivery: throw new MixERPException(Warnings.InvalidSubTranBookPurchaseDelivery); case SubTranBook.Direct: bookName = "Purchase.Direct"; break; case SubTranBook.Invoice: bookName = "Purchase.Invoice"; break; case SubTranBook.Order: bookName = "Purchase.Order"; break; case SubTranBook.Payment: bookName = "Purchase.Payment"; break; case SubTranBook.Quotation: throw new MixERPException(Warnings.InvalidSubTranBookPurchaseQuotation); case SubTranBook.Receipt: bookName = "Purchase.Receipt"; //Also known as GRN break; case SubTranBook.Return: bookName = "Purchase.Return"; break; case SubTranBook.Transfer: throw new MixERPException(Warnings.InvalidSubTranBookPurchaseTransfer); case SubTranBook.Suspense: throw new MixERPException(Warnings.InvalidSubTranBookPurchaseSuspense); } } if (book == TranBook.Inventory) { switch (subBook) { case SubTranBook.Delivery: throw new MixERPException(Warnings.InvalidSubTranBookInventoryDelivery); case SubTranBook.Direct: throw new MixERPException(Warnings.InvalidSubTranBookInventoryDirect); case SubTranBook.Invoice: throw new MixERPException(Warnings.InvalidSubTranBookInventoryInvoice); case SubTranBook.Order: throw new MixERPException(Warnings.InvalidSubTranBookInventoryOrder); case SubTranBook.Payment: throw new MixERPException(Warnings.InvalidSubTranBookInventoryPayment); case SubTranBook.Quotation: throw new MixERPException(Warnings.InvalidSubTranBookInventoryQuotation); case SubTranBook.Receipt: throw new MixERPException(Warnings.InvalidSubTranBookInventoryReceipt); case SubTranBook.Return: throw new MixERPException(Warnings.InvalidSubTranBookInventoryReturn); case SubTranBook.Transfer: bookName = "Inventory.Transfer"; break; case SubTranBook.Suspense: bookName = "Inventory.Suspense"; break; } } return(bookName); }
public static MergeModel GetMergeModel(string catalog, Collection <long> ids, TranBook tranBook, SubTranBook subTranBook) { int rowIndex = 0; if (ids == null) { return(new MergeModel()); } if (ids.Count.Equals(0)) { return(new MergeModel()); } MergeModel model = new MergeModel(); foreach (long tranId in ids) { model.AddTransactionIdToCollection(tranId); } model.Book = tranBook; model.SubBook = subTranBook; using (NpgsqlConnection connection = new NpgsqlConnection(DbConnection.GetConnectionString(catalog))) { using (NpgsqlCommand command = GetViewCommand(tranBook, subTranBook, ids)) { command.Connection = connection; command.Connection.Open(); NpgsqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); if (!reader.HasRows) { return(new MergeModel()); } while (reader.Read()) { if (rowIndex.Equals(0)) { model.ValueDate = Conversion.TryCastDate(reader["value_date"]); model.PartyCode = Conversion.TryCastString(reader["party_code"]); model.PriceTypeId = Conversion.TryCastInteger(reader["price_type_id"]); model.ReferenceNumber = Conversion.TryCastString(reader["reference_number"]); model.NonTaxableSales = Conversion.TryCastBoolean(reader["non_taxable"]); model.ShippingCompanyId = Conversion.TryCastInteger(reader["shipper_id"]); model.SalesPersonId = Conversion.TryCastInteger(reader["salesperson_id"]); model.StoreId = Conversion.TryCastInteger(reader["store_id"]); model.ShippingAddressCode = Conversion.TryCastString(reader["shipping_address_code"]); model.StatementReference = Conversion.TryCastString(reader["statement_reference"]); } ProductDetail product = new ProductDetail(); product.ItemCode = Conversion.TryCastString(reader["item_code"]); product.ItemName = Conversion.TryCastString(reader["item_name"]); product.Unit = Conversion.TryCastString(reader["unit_name"]); product.Quantity = Conversion.TryCastInteger(reader["quantity"]); product.Price = Conversion.TryCastDecimal(reader["price"]); product.Amount = product.Quantity * product.Price; product.Discount = Conversion.TryCastDecimal(reader["discount"]); product.ShippingCharge = Conversion.TryCastDecimal(reader["shipping_charge"]); product.Subtotal = product.Amount - product.Discount - product.ShippingCharge; product.TaxCode = Conversion.TryCastString(reader["tax_code"]); product.Tax = Conversion.TryCastDecimal(reader["tax"]); product.Total = product.Subtotal + product.Tax; model.AddViewToCollection(product); rowIndex++; } } } if (ids.Count > 0) { if (!string.IsNullOrWhiteSpace(model.StatementReference)) { model.StatementReference += Environment.NewLine; } model.StatementReference += "(" + Entities.Helpers.TransactionBookHelper.GetBookAcronym(tranBook, subTranBook) + "# " + string.Join(",", ids) + ")"; } return(model); }
private static NpgsqlCommand GetViewCommand(TranBook tranBook, SubTranBook subTranBook, Collection<long> ids) { if (tranBook == TranBook.Sales) { switch (subTranBook) { case SubTranBook.Delivery: break; case SubTranBook.Direct: break; case SubTranBook.Invoice: break; case SubTranBook.Order: return SalesOrder.GetSalesOrderViewCommand(ids); case SubTranBook.Payment: throw new InvalidOperationException(Errors.InvalidSubTranBookSalesPayment); case SubTranBook.Quotation: return SalesQuotation.GetSalesQuotationViewCommand(ids); case SubTranBook.Receipt: break; case SubTranBook.Return: break; } } switch (subTranBook) { case SubTranBook.Delivery: throw new InvalidOperationException(Errors.InvalidSubTranBookPurchaseDelivery); case SubTranBook.Direct: break; case SubTranBook.Invoice: break; case SubTranBook.Order: return PurchaseOrder.GetPurchaseOrderViewCommand(ids); case SubTranBook.Payment: break; case SubTranBook.Quotation: throw new InvalidOperationException(Errors.InvalidSubTranBookPurchaseQuotation); case SubTranBook.Receipt: throw new InvalidOperationException(Errors.InvalidSubTranBookPurchaseReceipt); } return null; }
private static NpgsqlCommand GetViewCommand(TranBook tranBook, SubTranBook subTranBook, Collection<int> ids) { if (tranBook == TranBook.Sales) { switch (subTranBook) { case SubTranBook.Delivery: break; case SubTranBook.Direct: break; case SubTranBook.Invoice: break; case SubTranBook.Order: return SalesOrder.GetSalesOrderViewCommand(ids); case SubTranBook.Payment: throw new InvalidOperationException(Common.Helpers.LocalizationHelper.GetResourceString("Errors", "InvalidSubTranBookSalesPayment")); case SubTranBook.Quotation: return SalesQuotation.GetSalesQuotationViewCommand(ids); case SubTranBook.Receipt: break; case SubTranBook.Return: break; } } switch (subTranBook) { case SubTranBook.Delivery: throw new InvalidOperationException(Common.Helpers.LocalizationHelper.GetResourceString("Errors", "InvalidSubTranBookPurchaseDelivery")); case SubTranBook.Direct: break; case SubTranBook.Invoice: break; case SubTranBook.Order: break; case SubTranBook.Payment: break; case SubTranBook.Quotation: throw new InvalidOperationException(Common.Helpers.LocalizationHelper.GetResourceString("Errors", "InvalidSubTranBookPurchaseQuotation")); case SubTranBook.Receipt: throw new InvalidOperationException(Common.Helpers.LocalizationHelper.GetResourceString("Errors", "InvalidSubTranBookPurchaseReceipt")); } return null; }
public static string GetTransactionBookName(TranBook book, SubTranBook subBook) { string bookName = string.Empty; if (book == TranBook.Sales) { switch (subBook) { case SubTranBook.Delivery: bookName = "Sales.Delivery"; break; case SubTranBook.Direct: bookName = "Sales.Direct"; break; case SubTranBook.Invoice: bookName = "Sales.Invoice"; break; case SubTranBook.Order: bookName = "Sales.Order"; break; case SubTranBook.Payment: throw new InvalidOperationException(Warnings.InvalidSubTranBookSalesPayment); case SubTranBook.Quotation: bookName = "Sales.Quotation"; break; case SubTranBook.Receipt: bookName = "Sales.Receipt"; break; case SubTranBook.Return: bookName = "Sales.Return"; break; } } if (book == TranBook.Purchase) { switch (subBook) { case SubTranBook.Delivery: throw new InvalidOperationException(Warnings.InvalidSubTranBookPurchaseDelivery); case SubTranBook.Direct: bookName = "Purchase.Direct"; break; case SubTranBook.Invoice: bookName = "Purchase.Invoice"; break; case SubTranBook.Order: bookName = "Purchase.Order"; break; case SubTranBook.Payment: bookName = "Purchase.Payment"; break; case SubTranBook.Quotation: throw new InvalidOperationException(Warnings.InvalidSubTranBookPurchaseQuotation); case SubTranBook.Receipt: bookName = "Purchase.Receipt"; //Also known as GRN break; case SubTranBook.Return: bookName = "Purchase.Return"; break; } } return(bookName); }
public static string GetBookAcronym(TranBook book, SubTranBook subBook) { if (book == TranBook.Sales) { if (subBook == SubTranBook.Delivery) { return ConfigurationHelper.GetParameter("SalesDeliveryAcronym"); } if (subBook == SubTranBook.Direct) { return ConfigurationHelper.GetParameter("SalesDirectAcronym"); } if (subBook == SubTranBook.Invoice) { return ConfigurationHelper.GetParameter("SalesInvoiceAcronym"); } if (subBook == SubTranBook.Order) { return ConfigurationHelper.GetParameter("SalesOrderAcronym"); } if (subBook == SubTranBook.Quotation) { return ConfigurationHelper.GetParameter("SalesQuotationAcronym"); } if (subBook == SubTranBook.Receipt) { return ConfigurationHelper.GetParameter("SalesReceiptAcronym"); } if (subBook == SubTranBook.Return) { return ConfigurationHelper.GetParameter("SaleReturnAcronym"); } } if (book == TranBook.Purchase) { if (subBook == SubTranBook.Direct) { return ConfigurationHelper.GetParameter("PurchaseDirectAcronym"); } if (subBook == SubTranBook.Order) { return ConfigurationHelper.GetParameter("PurchaseOrderAcronym"); } if (subBook == SubTranBook.Payment) { return ConfigurationHelper.GetParameter("PurchasePaymentAcronym"); } if (subBook == SubTranBook.Receipt) { return ConfigurationHelper.GetParameter("PurchaseGRNAcronym"); } if (subBook == SubTranBook.Return) { return ConfigurationHelper.GetParameter("PurchaseReturnAcronym"); } } return string.Empty; }
public static MergeModel GetMergeModel(Collection<int> ids, TranBook book, SubTranBook subBook) { int rowIndex = 0; if (ids == null) { return new MergeModel(); } if (ids.Count.Equals(0)) { return new MergeModel(); } MergeModel model = new MergeModel(); foreach (int tranId in ids) { model.AddTransactionIdToCollection(tranId); } model.Book = book; model.SubBook = subBook; using (NpgsqlConnection connection = new NpgsqlConnection(DbConnection.ConnectionString())) { using (NpgsqlCommand command = SalesQuotation.GetSalesQuotationViewCommand(ids)) { command.Connection = connection; command.Connection.Open(); NpgsqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); if (!reader.HasRows) { return new MergeModel(); } while (reader.Read()) { if (rowIndex.Equals(0)) { model.ValueDate = Conversion.TryCastDate(reader["value_date"]); model.PartyCode = Conversion.TryCastString(reader["party_code"]); model.PriceTypeId = Conversion.TryCastInteger(reader["price_type_id"]); model.ReferenceNumber = Conversion.TryCastString(reader["reference_number"]); model.StatementReference = Conversion.TryCastString(reader["statement_reference"]); } ProductDetailsModel product = new ProductDetailsModel(); product.ItemCode = Conversion.TryCastString(reader["item_code"]); product.ItemName = Conversion.TryCastString(reader["item_name"]); product.Unit = Conversion.TryCastString(reader["unit_name"]); product.Quantity = Conversion.TryCastInteger(reader["quantity"]); product.Price = Conversion.TryCastDecimal(reader["price"]); product.Amount = product.Quantity * product.Price; product.Discount = Conversion.TryCastDecimal(reader["discount"]); product.Subtotal = product.Amount - product.Discount; product.Rate = Conversion.TryCastDecimal(reader["tax_rate"]); product.Tax = Conversion.TryCastDecimal(reader["tax"]); product.Total = product.Subtotal + product.Tax; model.AddViewToCollection(product); rowIndex++; } } } if (ids.Count > 0) { if (!string.IsNullOrWhiteSpace(model.StatementReference)) { model.StatementReference += Environment.NewLine; } model.StatementReference += "(" + Conversion.GetBookAcronym(book, subBook) + "# " + string.Join(",", ids) + ")"; } return model; }
public static string GetBookAcronym(TranBook book, SubTranBook subBook) { if (book == TranBook.Sales) { if (subBook == SubTranBook.Delivery) { return(ConfigurationHelper.GetParameter("SalesDeliveryAcronym")); } if (subBook == SubTranBook.Direct) { return(ConfigurationHelper.GetParameter("SalesDirectAcronym")); } if (subBook == SubTranBook.Invoice) { return(ConfigurationHelper.GetParameter("SalesInvoiceAcronym")); } if (subBook == SubTranBook.Order) { return(ConfigurationHelper.GetParameter("SalesOrderAcronym")); } if (subBook == SubTranBook.Quotation) { return(ConfigurationHelper.GetParameter("SalesQuotationAcronym")); } if (subBook == SubTranBook.Receipt) { return(ConfigurationHelper.GetParameter("SalesReceiptAcronym")); } if (subBook == SubTranBook.Return) { return(ConfigurationHelper.GetParameter("SaleReturnAcronym")); } } if (book == TranBook.Purchase) { if (subBook == SubTranBook.Direct) { return(ConfigurationHelper.GetParameter("PurchaseDirectAcronym")); } if (subBook == SubTranBook.Order) { return(ConfigurationHelper.GetParameter("PurchaseOrderAcronym")); } if (subBook == SubTranBook.Payment) { return(ConfigurationHelper.GetParameter("PurchasePaymentAcronym")); } if (subBook == SubTranBook.Receipt) { return(ConfigurationHelper.GetParameter("PurchaseGRNAcronym")); } if (subBook == SubTranBook.Return) { return(ConfigurationHelper.GetParameter("PurchaseReturnAcronym")); } } return(string.Empty); }
public static string GetInvariantTransactionBookName(TranBook book, SubTranBook subBook) { string bookName = string.Empty; if (book == TranBook.Sales) { switch (subBook) { case SubTranBook.Delivery: bookName = "Sales.Delivery"; break; case SubTranBook.Direct: bookName = "Sales.Direct"; break; case SubTranBook.Invoice: bookName = "Sales.Invoice"; break; case SubTranBook.Order: bookName = "Sales.Order"; break; case SubTranBook.Payment: throw new MixERPException(Warnings.InvalidSubTranBookSalesPayment); case SubTranBook.Quotation: bookName = "Sales.Quotation"; break; case SubTranBook.Receipt: bookName = "Sales.Receipt"; break; case SubTranBook.Return: bookName = "Sales.Return"; break; case SubTranBook.Transfer: throw new MixERPException(Warnings.InvalidSubTranBookSalesTransfer); case SubTranBook.Suspense: throw new MixERPException(Warnings.InvalidSubTranBookSalesSuspense); } } if (book == TranBook.Purchase) { switch (subBook) { case SubTranBook.Delivery: throw new MixERPException(Warnings.InvalidSubTranBookPurchaseDelivery); case SubTranBook.Direct: bookName = "Purchase.Direct"; break; case SubTranBook.Invoice: bookName = "Purchase.Invoice"; break; case SubTranBook.Order: bookName = "Purchase.Order"; break; case SubTranBook.Payment: bookName = "Purchase.Payment"; break; case SubTranBook.Quotation: throw new MixERPException(Warnings.InvalidSubTranBookPurchaseQuotation); case SubTranBook.Receipt: bookName = "Purchase.Receipt"; //Also known as GRN break; case SubTranBook.Return: bookName = "Purchase.Return"; break; case SubTranBook.Transfer: throw new MixERPException(Warnings.InvalidSubTranBookPurchaseTransfer); case SubTranBook.Suspense: throw new MixERPException(Warnings.InvalidSubTranBookPurchaseSuspense); } } if (book == TranBook.Inventory) { switch (subBook) { case SubTranBook.Delivery: throw new MixERPException(Warnings.InvalidSubTranBookInventoryDelivery); case SubTranBook.Direct: throw new MixERPException(Warnings.InvalidSubTranBookInventoryDirect); case SubTranBook.Invoice: throw new MixERPException(Warnings.InvalidSubTranBookInventoryInvoice); case SubTranBook.Order: throw new MixERPException(Warnings.InvalidSubTranBookInventoryOrder); case SubTranBook.Payment: throw new MixERPException(Warnings.InvalidSubTranBookInventoryPayment); case SubTranBook.Quotation: throw new MixERPException(Warnings.InvalidSubTranBookInventoryQuotation); case SubTranBook.Receipt: throw new MixERPException(Warnings.InvalidSubTranBookInventoryReceipt); case SubTranBook.Return: throw new MixERPException(Warnings.InvalidSubTranBookInventoryReturn); case SubTranBook.Transfer: bookName = "Inventory.Transfer"; break; case SubTranBook.Suspense: bookName = "Inventory.Suspense"; break; } } return bookName; }
public static MergeModel GetMergeModel(Collection <int> ids, TranBook book, SubTranBook subBook) { int rowIndex = 0; if (ids == null) { return(new MergeModel()); } if (ids.Count.Equals(0)) { return(new MergeModel()); } MergeModel model = new MergeModel(); foreach (int tranId in ids) { model.AddTransactionIdToCollection(tranId); } model.Book = book; model.SubBook = subBook; using (NpgsqlConnection connection = new NpgsqlConnection(DbConnection.ConnectionString())) { using (NpgsqlCommand command = SalesQuotation.GetSalesQuotationViewCommand(ids)) { command.Connection = connection; command.Connection.Open(); NpgsqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); if (!reader.HasRows) { return(new MergeModel()); } while (reader.Read()) { if (rowIndex.Equals(0)) { model.ValueDate = Conversion.TryCastDate(reader["value_date"]); model.PartyCode = Conversion.TryCastString(reader["party_code"]); model.PriceTypeId = Conversion.TryCastInteger(reader["price_type_id"]); model.ReferenceNumber = Conversion.TryCastString(reader["reference_number"]); model.StatementReference = Conversion.TryCastString(reader["statement_reference"]); } ProductDetailsModel product = new ProductDetailsModel(); product.ItemCode = Conversion.TryCastString(reader["item_code"]); product.ItemName = Conversion.TryCastString(reader["item_name"]); product.Unit = Conversion.TryCastString(reader["unit_name"]); product.Quantity = Conversion.TryCastInteger(reader["quantity"]); product.Price = Conversion.TryCastDecimal(reader["price"]); product.Amount = product.Quantity * product.Price; product.Discount = Conversion.TryCastDecimal(reader["discount"]); product.Subtotal = product.Amount - product.Discount; product.Rate = Conversion.TryCastDecimal(reader["tax_rate"]); product.Tax = Conversion.TryCastDecimal(reader["tax"]); product.Total = product.Subtotal + product.Tax; model.AddViewToCollection(product); rowIndex++; } } } if (ids.Count > 0) { if (!string.IsNullOrWhiteSpace(model.StatementReference)) { model.StatementReference += Environment.NewLine; } model.StatementReference += "(" + Conversion.GetBookAcronym(book, subBook) + "# " + string.Join(",", ids) + ")"; } return(model); }