Exemplo n.º 1
0
        public void ShowLines()
        {
            JoinPlToVpToProdBindingList data = JoinPlToVpToProdBindingList.GetOrderLines(
                mOrderId, false, mCategories, mSubCategoriesById, mBrandsById, out mOrder);

            mHelper.DataSource = data;
        }
Exemplo n.º 2
0
        private void FindVendorPartNumber()
        {
            string vendorPartNumber = txtVendorCode.Text.Trim();

            if (vendorPartNumber.Length == 0)
            {
                MessageBox.Show("Please enter a vendor code first.");
                return;
            }
            JoinPlToVpToProdBindingList data = (JoinPlToVpToProdBindingList)mHelper.DataSource;

            foreach (JoinPlToVpToProd row in data)
            {
                if (row.VendorProduct_VendorPartNum == vendorPartNumber)
                {
                    mHelper.CurrentEntity = row;
                    return;
                }
            }
            MessageBox.Show("Vendor code not found.", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Stop);
        }
Exemplo n.º 3
0
        protected override void WriteContent(TextWriter textWriter)
        {
            JoinPlToVpToProdBindingList sortedData = JoinPlToVpToProdBindingList.GetOrderLines(
                mOrderId, mShelfOrder, mCategories, mSubCategories, mBrands, out mOrder);
            decimal totalCost = 0m;

            foreach (JoinPlToVpToProd join in sortedData)
            {
                totalCost += join.ExtendedCost;
            }
            mOrder.UnpersistedTotal = totalCost + mOrder.Freight;

            mWriter.Init(mTitle, mOrder, mVendor, textWriter);
            textWriter.WriteLine("<html>");
            textWriter.WriteLine("<head>");
            textWriter.WriteLine("<style>");
            textWriter.WriteLine("td, th, p, h1, h2, h3, h4 { font-family: sans-serif; }");
            mWriter.AddToStylesheet();
            textWriter.WriteLine("</style>");
            textWriter.WriteLine("</head>");
            textWriter.WriteLine("<body>");
            mWriter.StartBody();
            textWriter.WriteLine("<table border='0' class='TableBorder' cellpadding='3'>");
            textWriter.WriteLine("<tr>");
            mWriter.OutputTableHeader();
            textWriter.WriteLine("</tr>");
            foreach (JoinPlToVpToProd line in sortedData)
            {
                if (mFilter.IncludeLine(line))
                {
                    textWriter.WriteLine("<tr>");
                    mWriter.OutputLine(line);
                    textWriter.WriteLine("</tr>");
                }
            }
            textWriter.WriteLine("</table>");
            textWriter.WriteLine("</body>");
            textWriter.WriteLine("</html>");
        }
Exemplo n.º 4
0
        private void btnCreateProducts_Click(object sender, EventArgs e)
        {
            JoinPlToVpToProdBindingList data         = (JoinPlToVpToProdBindingList)mHelper.DataSource;
            List <JoinPlToVpToProd>     skippedDupes = new List <JoinPlToVpToProd>();
            int  numberToCreate      = data.Count(p => p.PurLine_VendorProductId.IsNull);
            int  numberCreated       = 0;
            bool confirmIndividually = (numberToCreate < 5);

            if (!confirmIndividually)
            {
                string prompt = "Found " + numberToCreate.ToString() + " products to create. Okay to proceed?";
                if (MessageBox.Show(prompt, "Confirm", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
            }
            foreach (JoinPlToVpToProd purLine in data)
            {
                if (purLine.PurLine_VendorProductId.IsNull)
                {
                    if (confirmIndividually)
                    {
                        string prompt = "Create product \"" + (purLine.PurLine_ProductName + " " + purLine.PurLine_Size).TrimEnd() + "\"?";
                        if (MessageBox.Show(prompt, "Confirm", MessageBoxButtons.OKCancel) != DialogResult.OK)
                        {
                            continue;
                        }
                    }
                    using (ITranScope trans = Ambient.DbSession.CreateTranScope())
                    {
                        using (Ambient.DbSession.Activate())
                        {
                            List <VendorProduct> dupeVendorProducts = OrderingRepositories.VendorProduct.Get(mVendorId, purLine.PurLine_VendorPartNum);
                            if (dupeVendorProducts.Count > 0)
                            {
                                skippedDupes.Add(purLine);
                            }
                            else
                            {
                                Product newProduct = new Product();
                                newProduct.IsActive             = true;
                                newProduct.ManufacturerBarcode  = purLine.PurLine_ManufacturerBarcode;
                                newProduct.ManufacturerPartNum  = purLine.PurLine_ManufacturerPartNum;
                                newProduct.ProductBrandId       = purLine.PurLine_ProductBrandId;
                                newProduct.ProductSubCategoryId = purLine.PurLine_ProductSubCategoryId;
                                newProduct.ProductName          = purLine.PurLine_ProductName;
                                newProduct.Size        = purLine.PurLine_Size;
                                newProduct.RetailPrice = purLine.PurLine_RetailPrice;
                                OrderingRepositories.Product.Insert(newProduct);

                                VendorProduct newVendorProduct = new VendorProduct();
                                newVendorProduct.VendorId            = mVendorId;
                                newVendorProduct.ProductId           = newProduct.Id;
                                newVendorProduct.CaseCost            = purLine.PurLine_CaseCost;
                                newVendorProduct.CountInCase         = purLine.PurLine_CountInCase;
                                newVendorProduct.EachCost            = purLine.PurLine_EachCost;
                                newVendorProduct.PreferredSource     = purLine.PurLine_PreferredSource;
                                newVendorProduct.RetailPriceOverride = purLine.PurLine_RetailPriceOverride;
                                newVendorProduct.ShelfOrder          = purLine.PurLine_ShelfOrder;
                                newVendorProduct.VendorPartNum       = purLine.PurLine_VendorPartNum;
                                newVendorProduct.WholeCasesOnly      = purLine.PurLine_WholeCasesOnly;
                                OrderingRepositories.VendorProduct.Insert(newVendorProduct);

                                purLine.PurLine_VendorProductId = newVendorProduct.Id;
                                OrderingRepositories.PurLine.Update(purLine.InnerPurLine);

                                numberCreated++;
                            }
                        }
                        trans.Complete();
                    }
                }
            }
            ShowLines();
            ShowTotalCost();
            if (numberCreated > 0)
            {
                MessageBox.Show("Created " + numberCreated.ToString() + " products.");
            }
            else
            {
                MessageBox.Show("No products created.");
            }
            if (skippedDupes.Count > 0)
            {
                MessageBox.Show("Skipped the following products because they would have created duplicate vendor codes.");
                foreach (JoinPlToVpToProd purLine in skippedDupes)
                {
                    MessageBox.Show("Skipped \"" + purLine.InnerPurLine.ProductName + "\"");
                }
            }
        }