예제 #1
0
        public static void MergeSalesQuotationToSalesOrder(Collection <int> ids)
        {
            MixERP.Net.Common.Models.Transactions.MergeModel model = new Common.Models.Transactions.MergeModel();
            Collection <MixERP.Net.Common.Models.Transactions.ProductDetailsModel> products = new Collection <Common.Models.Transactions.ProductDetailsModel>();

            using (DataTable table = MixERP.Net.DatabaseLayer.Transactions.NonGLStockTransaction.GetSalesQuotationView(ids))
            {
                if (table.Rows.Count.Equals(0))
                {
                    return;
                }

                model.ValueDate          = MixERP.Net.Common.Conversion.TryCastDate(table.Rows[0]["value_date"]);
                model.PartyCode          = MixERP.Net.Common.Conversion.TryCastString(table.Rows[0]["party_code"]);
                model.PriceTypeId        = MixERP.Net.Common.Conversion.TryCastInteger(table.Rows[0]["price_type_id"]);
                model.ReferenceNumber    = MixERP.Net.Common.Conversion.TryCastString(table.Rows[0]["reference_number"]);
                model.StatementReference = MixERP.Net.Common.Conversion.TryCastString(table.Rows[0]["statement_reference"]);


                foreach (DataRow row in table.Rows)
                {
                    MixERP.Net.Common.Models.Transactions.ProductDetailsModel product = new Common.Models.Transactions.ProductDetailsModel();

                    product.ItemCode = MixERP.Net.Common.Conversion.TryCastString(row["item_code"]);
                    product.ItemName = MixERP.Net.Common.Conversion.TryCastString(row["item_name"]);
                    product.Unit     = MixERP.Net.Common.Conversion.TryCastString(row["unit_name"]);


                    product.Quantity = MixERP.Net.Common.Conversion.TryCastInteger(row["quantity"]);
                    product.Price    = MixERP.Net.Common.Conversion.TryCastDecimal(row["price"]);
                    product.Amount   = product.Quantity * product.Price;

                    product.Discount = MixERP.Net.Common.Conversion.TryCastDecimal(row["discount"]);
                    product.Subtotal = product.Amount - product.Discount;

                    product.Rate  = MixERP.Net.Common.Conversion.TryCastDecimal(row["tax_rate"]);
                    product.Tax   = MixERP.Net.Common.Conversion.TryCastDecimal(row["tax"]);
                    product.Total = product.Subtotal + product.Tax;

                    products.Add(product);
                }

                model.View = products;
            }

            HttpContext.Current.Session["Product"] = model;
            HttpContext.Current.Response.Redirect("~/Sales/Order.aspx");
        }
예제 #2
0
        private void AddRowToTable(string itemCode, string itemName, int quantity, string unit, decimal price, decimal discount, decimal taxRate, decimal tax)
        {
            Collection <MixERP.Net.Common.Models.Transactions.ProductDetailsModel> table = this.GetTable();

            decimal amount   = price * quantity;
            decimal subTotal = amount - discount;
            decimal total    = subTotal + tax;

            MixERP.Net.Common.Models.Transactions.ProductDetailsModel row = new Common.Models.Transactions.ProductDetailsModel();
            row.ItemCode = itemCode;
            row.ItemName = itemName;
            row.Quantity = quantity;
            row.Unit     = unit;
            row.Price    = price;
            row.Amount   = amount;
            row.Discount = discount;
            row.Subtotal = subTotal;
            row.Rate     = taxRate;
            row.Tax      = tax;
            row.Total    = total;

            table.Add(row);
            Session[this.ID] = table;
        }
예제 #3
0
        public static void MergeSalesQuotationToSalesOrder(Collection<int> ids)
        {
            MixERP.Net.Common.Models.Transactions.MergeModel model = new Common.Models.Transactions.MergeModel();
            Collection<MixERP.Net.Common.Models.Transactions.ProductDetailsModel> products = new Collection<Common.Models.Transactions.ProductDetailsModel>();

            using(DataTable table = MixERP.Net.DatabaseLayer.Transactions.NonGLStockTransaction.GetSalesQuotationView(ids))
            {
                if(table.Rows.Count.Equals(0))
                {
                    return;
                }

                model.ValueDate = MixERP.Net.Common.Conversion.TryCastDate(table.Rows[0]["value_date"]);
                model.PartyCode = MixERP.Net.Common.Conversion.TryCastString(table.Rows[0]["party_code"]);
                model.PriceTypeId = MixERP.Net.Common.Conversion.TryCastInteger(table.Rows[0]["price_type_id"]);
                model.ReferenceNumber = MixERP.Net.Common.Conversion.TryCastString(table.Rows[0]["reference_number"]);
                model.StatementReference = MixERP.Net.Common.Conversion.TryCastString(table.Rows[0]["statement_reference"]);

                foreach(DataRow row in table.Rows)
                {
                    MixERP.Net.Common.Models.Transactions.ProductDetailsModel product = new Common.Models.Transactions.ProductDetailsModel();

                    product.ItemCode = MixERP.Net.Common.Conversion.TryCastString(row["item_code"]);
                    product.ItemName = MixERP.Net.Common.Conversion.TryCastString(row["item_name"]);
                    product.Unit = MixERP.Net.Common.Conversion.TryCastString(row["unit_name"]);

                    product.Quantity = MixERP.Net.Common.Conversion.TryCastInteger(row["quantity"]);
                    product.Price = MixERP.Net.Common.Conversion.TryCastDecimal(row["price"]);
                    product.Amount = product.Quantity * product.Price;

                    product.Discount = MixERP.Net.Common.Conversion.TryCastDecimal(row["discount"]);
                    product.Subtotal = product.Amount - product.Discount;

                    product.Rate = MixERP.Net.Common.Conversion.TryCastDecimal(row["tax_rate"]);
                    product.Tax = MixERP.Net.Common.Conversion.TryCastDecimal(row["tax"]);
                    product.Total = product.Subtotal + product.Tax;

                    products.Add(product);
                }

                model.View = products;
            }

            HttpContext.Current.Session["Product"] = model;
            HttpContext.Current.Response.Redirect("~/Sales/Order.aspx");
        }
예제 #4
0
        private void AddRowToTable(string itemCode, string itemName, int quantity, string unit, decimal price, decimal discount, decimal taxRate, decimal tax)
        {
            Collection<MixERP.Net.Common.Models.Transactions.ProductDetailsModel> table = this.GetTable();

            decimal amount = price * quantity;
            decimal subTotal = amount - discount;
            decimal total = subTotal + tax;

            MixERP.Net.Common.Models.Transactions.ProductDetailsModel row = new Common.Models.Transactions.ProductDetailsModel();
            row.ItemCode = itemCode;
            row.ItemName = itemName;
            row.Quantity = quantity;
            row.Unit = unit;
            row.Price = price;
            row.Amount = amount;
            row.Discount = discount;
            row.Subtotal = subTotal;
            row.Rate = taxRate;
            row.Tax = tax;
            row.Total = total;

            table.Add(row);
            Session[this.ID] = table;
        }
예제 #5
0
        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"]);
                        }

                        Common.Models.Transactions.ProductDetailsModel product = new Common.Models.Transactions.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;
        }