Пример #1
0
        protected void BtnCreateOrder_Click(object sender, EventArgs e)
        {
            List <int>  QtyList  = new List <int>();
            List <Item> ItemList = new List <Item>();

            ItemList.Clear();
            QtyList.Clear();
            bool flag = false;
            Dictionary <string, string> orderIDMap = new Dictionary <string, string>();

            foreach (GridViewRow r in GridViewROtable.Rows)
            {
                CheckBox cb = (CheckBox)r.Cells[0].FindControl("CheckBoxReorder");
                if (cb.Checked == true)
                {
                    ItemList.Add(POC.GetItemByItem_ID(r.Cells[2].Text));
                    QtyList.Add(Convert.ToInt32(r.Cells[7].Text));
                    flag = true;
                }
            }
            if (flag == true)
            {
                List <ItemWithQtyModel>      IWQList = SPOL.CreateItemWithQty(ItemList, QtyList);
                List <OrderDetailController> ODList  = SPOL.CreateOrderLists(IWQList);
                SPOL.DistributeToSuppliers(ODList);

                Session["ALPAList"] = SPOL.ALPAod;
                Session["BANEList"] = SPOL.BANEod;
                Session["CHEPList"] = SPOL.CHEPod;
                Session["OMEGList"] = SPOL.OMEGod;

                GridViewALPH.DataSource = POC.CreatePurchaseOrderGridView(SPOL.ALPAod);
                GridViewALPH.DataBind();

                GridViewBANE.DataSource = POC.CreatePurchaseOrderGridView(SPOL.BANEod);
                GridViewBANE.DataBind();

                GridViewCHEP.DataSource = POC.CreatePurchaseOrderGridView(SPOL.CHEPod);
                GridViewCHEP.DataBind();

                GridViewOMEG.DataSource = POC.CreatePurchaseOrderGridView(SPOL.OMEGod);
                GridViewOMEG.DataBind();


                if (SPOL.ALPAod.Count > 0)
                {
                    Panel1.Visible = true;
                    string orderid = POC.CreateOrderID("ALPA");
                    orderIDMap.Add("ALPA", orderid);
                    LbOrderID1.Text = "Order ID: " + orderid;
                }

                if (SPOL.BANEod.Count > 0)
                {
                    Panel2.Visible = true;
                    string orderid = POC.CreateOrderID("BANE");
                    orderIDMap.Add("BANE", orderid);
                    LbOrderID2.Text = "Order ID: " + orderid;
                }

                if (SPOL.CHEPod.Count > 0)
                {
                    Panel3.Visible = true;
                    string orderid = POC.CreateOrderID("CHEP");
                    orderIDMap.Add("CHEP", orderid);
                    LbOrderID3.Text = "Order ID: " + orderid;
                }

                if (SPOL.OMEGod.Count > 0)
                {
                    Panel4.Visible = true;
                    string orderid = POC.CreateOrderID("OMEG");
                    orderIDMap.Add("OMEG", orderid);
                    LbOrderID4.Text = "Order ID: " + orderid;
                }
                Session["SupMap"]    = orderIDMap;
                Panelcontrol.Visible = true;
                PanelMain.Visible    = false;
                LBNotEnough.Text     = SPOL.InsufficientInfo;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Please choose at least one item! ')</script>");
            }
        }
Пример #2
0
        protected void BtnCreate_Click(object sender, EventArgs e)
        {
            TextBox      tbQty   = new TextBox();
            DropDownList drpItem = new DropDownList();
            SubmitPurchaseOrderController SPOL = new SubmitPurchaseOrderController();
            List <int>  QtyList = new List <int>();
            List <Item> IList   = new List <Item>();
            Dictionary <string, string> orderIDMap = new Dictionary <string, string>();

            foreach (GridViewRow r in GridViewCreateOrder.Rows)
            {
                tbQty = (TextBox)r.Cells[3].FindControl("TextboxQty");
                if (tbQty.Text == "")
                {
                    LBforValidation.Text = "Please fill all Qty fields";
                }
                else
                {
                    LBforValidation.Text = "";
                }
            }
            if (TbEDD.Text == "")
            {
                LBEDDValidate.Text = "Please choose the Expected Delivery Date.";
            }
            else
            {
                DateTime EED = TC.DateConvert(TbEDD.Text);
                if (EED < DateTime.Today.Date)
                {
                    LBEDDValidate.Text = "The expected delivery date can not be before today.";
                }
                else
                {
                    LBEDDValidate.Text = "";
                    if (LBforValidation.Text != "Please fill all Qty fields")
                    {
                        for (int i = 0; i < GridViewCreateOrder.Rows.Count; i++)
                        {
                            drpItem = (DropDownList)GridViewCreateOrder.Rows[i].Cells[1].FindControl("DropDownListItemCode");
                            Item additem = POC.GetItemByItem_ID(drpItem.SelectedValue);
                            IList.Add(additem);
                            tbQty = (TextBox)GridViewCreateOrder.Rows[i].Cells[3].FindControl("TextboxQty");
                            QtyList.Add(Convert.ToInt32(tbQty.Text));
                        }

                        List <ItemWithQtyModel>      IWQList = SPOL.CreateItemWithQty(IList, QtyList);
                        List <OrderDetailController> ODList  = SPOL.CreateOrderLists(IWQList);
                        SPOL.DistributeToSuppliers(ODList);

                        Session["ALPAList"] = SPOL.ALPAod;
                        Session["BANEList"] = SPOL.BANEod;
                        Session["CHEPList"] = SPOL.CHEPod;
                        Session["OMEGList"] = SPOL.OMEGod;

                        GridViewALPH.DataSource = POC.CreatePurchaseOrderGridView(SPOL.ALPAod);
                        GridViewALPH.DataBind();

                        GridViewBANE.DataSource = POC.CreatePurchaseOrderGridView(SPOL.BANEod);
                        GridViewBANE.DataBind();

                        GridViewCHEP.DataSource = POC.CreatePurchaseOrderGridView(SPOL.CHEPod);
                        GridViewCHEP.DataBind();

                        GridViewOMEG.DataSource = POC.CreatePurchaseOrderGridView(SPOL.OMEGod);
                        GridViewOMEG.DataBind();


                        if (SPOL.ALPAod.Count > 0)
                        {
                            PanelSup1.Visible = true;
                            string orderid = POC.CreateOrderID("ALPA");
                            orderIDMap.Add("ALPA", orderid);
                            LbOrderID1.Text = "Order ID: " + orderid;
                            LbSupEDD1.Text  = "Expected Dellivery Date: " + TbEDD.Text;
                            //PurchaseOrderPDF POPDF = new PurchaseOrderPDF();
                            //POPDF.MakePurchaseOrderPDF("ALPA",orderid,LbSupEDD1.Text, "Tony", SPOL.ALPAod);
                        }

                        if (SPOL.BANEod.Count > 0)
                        {
                            PanelSup2.Visible = true;
                            string orderid = POC.CreateOrderID("BANE");
                            orderIDMap.Add("BANE", orderid);
                            LbOrderID2.Text = "Order ID: " + orderid;
                            LbSupEDD2.Text  = "Expected Dellivery Date: " + TbEDD.Text;
                            //PurchaseOrderPDF POPDF = new PurchaseOrderPDF();
                            // POPDF.MakePurchaseOrderPDF("BANE", "002", LbSupEDD1.Text, "Tony", SPOL.BANEod);
                        }

                        if (SPOL.CHEPod.Count > 0)
                        {
                            PanelSup3.Visible = true;
                            string orderid = POC.CreateOrderID("CHEP");
                            orderIDMap.Add("CHEP", orderid);
                            LbOrderID3.Text = "Order ID: " + orderid;
                            LbSupEDD3.Text  = "Expected Dellivery Date: " + TbEDD.Text;
                            //PurchaseOrderPDF POPDF = new PurchaseOrderPDF();
                            //POPDF.MakePurchaseOrderPDF("CHEP", "003", LbSupEDD1.Text, "Tony", SPOL.CHEPod);
                        }

                        if (SPOL.OMEGod.Count > 0)
                        {
                            PanelSup4.Visible = true;
                            string orderid = POC.CreateOrderID("OMEG");
                            orderIDMap.Add("OMEG", orderid);
                            LbOrderID4.Text = "Order ID: " + orderid;
                            LbSupEDD4.Text  = "Expected Dellivery Date: " + TbEDD.Text;
                        }
                        Session["SupMap"]        = orderIDMap;
                        PanelContorl.Visible     = true;
                        PanelCreateOrder.Visible = false;

                        LBNotEnough.Text = SPOL.InsufficientInfo;
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Please fill all Qty fields')</script>");
                    }
                }
            }
        }