Пример #1
0
        protected void loadProductGrid(String poId)
        {
            ArrayList rfqSpecList = new ArrayList();
            String    context     = Request.QueryString.GetValues("context")[0];

            if (context.Equals("client"))
            {
                rfqSpecList = (ArrayList)Session[SessionFactory.ALL_PURCHASE_ALL_RFQ_RFQ_SPEC];
            }
            else if (context.Equals("vendor"))
            {
                rfqSpecList = (ArrayList)Session[SessionFactory.ALL_SALE_ALL_POTENTIAL_POTN_SPEC];
            }
            else if (context.Equals("clientInvoiceGrid") || context.Equals("vendInvoiceGrid"))
            {//If this is sent from the Invoice grid in Purchase screen
                rfqSpecList = BackEndObjects.RFQProductServiceDetails.getAllProductServiceDetailsbyRFQIdDB(Request.QueryString.GetValues("rfId")[0]);
            }

            ArrayList poQuoteList = PurchaseOrderQuote.getPurcahseOrderQuoteListbyPOIdDB(poId);

            DataTable dt = new DataTable();

            dt.Columns.Add("Hidden_Cat_Id");
            dt.Columns.Add("Serial");
            dt.Columns.Add("Qnty");
            dt.Columns.Add("Prod_Name");
            dt.Columns.Add("Cat_Name");
            dt.Columns.Add("Unit_Price");
            dt.Columns.Add("Cat_Total");

            float totalAmnt = 0;

            for (int i = 0; i < poQuoteList.Count; i++)
            {
                BackEndObjects.PurchaseOrderQuote poQntyObj = (PurchaseOrderQuote)poQuoteList[i];
                //Preference to toQuantity
                float  qnty  = poQntyObj.getUnits();
                String catId = poQntyObj.getProd_srv_category();

                dt.Rows.Add();
                dt.Rows[i]["Hidden_Cat_Id"] = catId;
                dt.Rows[i]["Serial"]        = i + 1;
                dt.Rows[i]["Qnty"]          = qnty.ToString();
                dt.Rows[i]["Prod_Name"]     = poQntyObj.getProduct_name();
                dt.Rows[i]["Cat_Name"]      = BackEndObjects.ProductCategory.getProductCategorybyIdwoFeaturesDB(catId).getProductCategoryName();
                dt.Rows[i]["Unit_Price"]    = poQntyObj.getQuote();
                dt.Rows[i]["Cat_Total"]     = qnty * poQntyObj.getQuote();

                totalAmnt += poQntyObj.getQuote() * qnty;
            }


            GridView1.Visible    = true;
            GridView1.DataSource = dt;
            GridView1.DataBind();
            GridView1.Columns[0].Visible = false;

            foreach (GridViewRow gVR in GridView1.Rows)
            {
                // if (!context.Equals("client"))
                //{
                ((TextBox)gVR.Cells[2].FindControl("TextBox_Qnty")).Enabled       = false;
                ((TextBox)gVR.Cells[2].FindControl("TextBox_Unit_Price")).Enabled = false;
                //}
                DataTable dtSpec = new DataTable();
                dtSpec.Columns.Add("Hidden");
                dtSpec.Columns.Add("FeatName");
                dtSpec.Columns.Add("SpecText");
                dtSpec.Columns.Add("FromSpec");
                dtSpec.Columns.Add("ToSpec");
                int rowCount = 0;

                for (int j = 0; j < rfqSpecList.Count; j++)
                {
                    BackEndObjects.RFQProductServiceDetails rfqSpecObj = (BackEndObjects.RFQProductServiceDetails)rfqSpecList[j];

                    if (rfqSpecObj.getPrdCatId().Equals(((Label)gVR.Cells[1].FindControl("Label_Hidden")).Text))
                    {
                        dtSpec.Rows.Add();
                        String featName = BackEndObjects.Features.getFeaturebyIdwoSpecDB(rfqSpecObj.getFeatId()).getFeatureName();
                        dtSpec.Rows[rowCount]["Hidden"]   = rfqSpecObj.getFeatId();
                        dtSpec.Rows[rowCount]["FeatName"] = (featName != null ? featName.Trim() : "");
                        dtSpec.Rows[rowCount]["SpecText"] = rfqSpecObj.getSpecText();
                        if (!rfqSpecObj.getFromSpecId().Equals(""))
                        {
                            dtSpec.Rows[rowCount]["FromSpec"] = BackEndObjects.Specifications.getSpecificationDetailbyIdDB(rfqSpecObj.getFromSpecId()).getSpecName();
                        }
                        if (!rfqSpecObj.getToSpecId().Equals(""))
                        {
                            dtSpec.Rows[rowCount]["ToSpec"] = BackEndObjects.Specifications.getSpecificationDetailbyIdDB(rfqSpecObj.getToSpecId()).getSpecName();
                        }

                        rowCount++;
                    }
                }
                ((GridView)gVR.Cells[2].FindControl("GridView1_Inner")).DataSource = dtSpec;
                ((GridView)gVR.Cells[2].FindControl("GridView1_Inner")).DataBind();
                ((GridView)gVR.Cells[2].FindControl("GridView1_Inner")).Visible            = true;
                ((GridView)gVR.Cells[2].FindControl("GridView1_Inner")).Columns[0].Visible = false;
            }

            Label_Sub_Total_Amount_Value.Visible = true;
            Label_Sub_Total_Amount_Value.Text    = totalAmnt.ToString();
            if (TextBox_Taxable_Amount.Text.Equals("") || float.Parse(TextBox_Taxable_Amount.Text) == 0)
            {
                TextBox_Taxable_Amount.Text = totalAmnt.ToString();
            }
            Label_Total_Amount_Value.Visible = true;
            Label_Total_Amount_Value.Text    = updateTotalINVAmount();
        }
Пример #2
0
        protected void Button_Create_Req_Click(object sender, EventArgs e)
        {
            BackEndObjects.PurchaseOrder POObj = new BackEndObjects.PurchaseOrder();
            String context = Request.QueryString.GetValues("context")[0];

            String poId = new BackEndObjects.Id().getNewId(BackEndObjects.Id.ID_TYPE_PO_ID_STRING);

            POObj.setDate_created(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            POObj.setPo_id(poId);
            POObj.setPo_ship_via(TextBox_Ship_Via.Text);
            POObj.setPo_tnc(TextBox_TnC.Text);
            POObj.setRfq_id(Request.QueryString.GetValues("rfqId")[0]);
            POObj.setTotal_tax_rate((!TextBox_tax.Text.Equals("")?TextBox_tax.Text:"0"));
            POObj.setCurrency(DropDownList_Curr.SelectedValue);
            if (context.Equals("client"))
            {
                POObj.setRespEntId(Request.QueryString.GetValues("respCompId")[0]);
            }
            else
            {
                POObj.setRespEntId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
            }


            ArrayList POQuoteObjList = new ArrayList();

            foreach (GridViewRow gVR in GridView1.Rows)
            {
                BackEndObjects.PurchaseOrderQuote POQuoteObj = new BackEndObjects.PurchaseOrderQuote();

                POQuoteObj.setPo_id(poId);
                POQuoteObj.setProd_srv_category(((Label)gVR.Cells[0].FindControl("Label_Hidden")).Text);
                POQuoteObj.setProduct_name(((Label)gVR.Cells[0].FindControl("Label_Product_Name")).Text);
                POQuoteObj.setQuote(float.Parse(((TextBox)gVR.Cells[0].FindControl("TextBox_Unit_Price")).Text));
                POQuoteObj.setUnits(float.Parse(((TextBox)gVR.Cells[0].FindControl("TextBox_Qnty")).Text));

                POQuoteObjList.Add(POQuoteObj);
            }

            try
            {
                BackEndObjects.PurchaseOrder.insertPurchaseOrderDB(POObj);
                BackEndObjects.PurchaseOrderQuote.insertPurchaseOrderQuoteListDB(POQuoteObjList);
                Label_PO_No.Visible              = true;
                Label_PO_No.Text                 = poId;
                Label_PO_Creation_Stat.Visible   = true;
                Label_PO_Creation_Stat.ForeColor = System.Drawing.Color.Green;
                if (context.Equals("client"))
                {
                    Label_PO_Creation_Stat.Text = "Purchase Order Created Successfully";
                }
                else
                {
                    Label_PO_Creation_Stat.Text = "Sales Order Created Successfully";
                }

                String dataItemIndex = Request.QueryString.GetValues("dataItemIndex") != null?Request.QueryString.GetValues("dataItemIndex")[0] : "";

                if (!dataItemIndex.Equals(""))
                {
                    DataTable dt = (DataTable)Session[SessionFactory.ALL_SALE_ALL_POTENTIAL_GRID_DATA];
                    dt.Rows[Int32.Parse(dataItemIndex)]["PO_Id"]             = POObj.getPo_id();
                    Session[SessionFactory.ALL_SALE_ALL_POTENTIAL_GRID_DATA] = dt;
                    ScriptManager.RegisterStartupScript(this, typeof(string), "RefreshPotnGrid", "RefreshParent();", true);
                }
                Button_Create_PO.Enabled = false;
            }
            catch (Exception ex)
            {
                Label_PO_Creation_Stat.Visible   = true;
                Label_PO_Creation_Stat.ForeColor = System.Drawing.Color.Red;
                if (context.Equals("client"))
                {
                    Label_PO_Creation_Stat.Text = "Purchase Order Creation Failed";
                }
                else
                {
                    Label_PO_Creation_Stat.Text = "Sales Order Creation Failed";
                }
            }
        }