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(); }
protected void loadSODetails() { String prodName = Request.QueryString.GetValues("prodName")[0]; Dictionary <String, PurchaseOrderQuote> poDict = PurchaseOrder.getPurchaseOrdersForProdNameAndRespEntDB(prodName, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); Dictionary <String, float> rfqDeliveredQnty = new Dictionary <string, float>(); ArrayList rfqList = new ArrayList(); foreach (KeyValuePair <String, PurchaseOrderQuote> kvp in poDict) { rfqList.Add(kvp.Key.Split(new String[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1]); } if (rfqList.Count > 0) { rfqDeliveredQnty = PurchaseOrder.getTotalDeliveredQntyByRFQIdAndProductName(rfqList, prodName); } DataTable dt = new DataTable(); dt.Columns.Add("So_No"); dt.Columns.Add("RFQNo"); dt.Columns.Add("delivered"); dt.Columns.Add("quote"); dt.Columns.Add("units"); int counter = 0; float unitsToDeliver = 0, unitsDelivered = 0; foreach (KeyValuePair <String, PurchaseOrderQuote> kvp in poDict) { PurchaseOrderQuote quoteObj = kvp.Value; dt.Rows.Add(); dt.Rows[counter]["So_No"] = quoteObj.getPo_id(); dt.Rows[counter]["RFQNo"] = kvp.Key.Split(new String[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1]; dt.Rows[counter]["delivered"] = rfqDeliveredQnty.ContainsKey(dt.Rows[counter]["RFQNo"].ToString()) ? rfqDeliveredQnty[dt.Rows[counter]["RFQNo"].ToString()] : 0; unitsDelivered += float.Parse(dt.Rows[counter]["delivered"].ToString()); dt.Rows[counter]["quote"] = quoteObj.getQuote(); dt.Rows[counter]["units"] = quoteObj.getUnits(); //if(dt.Rows[counter]["delivered"].Equals("N")) unitsToDeliver += quoteObj.getUnits(); counter++; } if (dt.Rows.Count > 0) { GridView1.Visible = true; GridView1.DataSource = dt; GridView1.DataBind(); Label_Total_Text.Text = "Total units of this product ordered:"; Label_Total_No.Text = unitsToDeliver.ToString(); Label_Total_Delivered_Text.Text = "Total units delivered as per invoice records (only considering invoices where 'Delivery Status' is set to 'Delivered':"; Label_Total_Delivered_No.Text = unitsDelivered.ToString(); Label_Total_No.Visible = true; Label_Total_Text.Visible = true; Label_Total_Delivered_Text.Visible = true; Label_Total_Delivered_No.Visible = true; Label_Total_No.ForeColor = System.Drawing.Color.Green; } else { Label_Empty_Grid.Visible = true; Label_Empty_Grid.Text = "No Sales Order Received for this product"; Label_Empty_Grid.ForeColor = System.Drawing.Color.Red; } }