protected void RBtnLDuration_SelectedIndexChanged(object sender, EventArgs e) { string type = Request.QueryString["type"]; int selectedIndex = RBtnLDuration.SelectedIndex; if (type.Equals("RTR")) { switch (selectedIndex) { case 0: LblFrom.Visible = false; DDLFrom.Visible = false; DDLDuration.Visible = false; BtnDurationAdd.Visible = false; GVDuration.Visible = false; LblDurAlert.Visible = false; ViewState["durSel"] = 0; break; case 1: LblFrom.Visible = true; DDLFrom.Visible = true; DDLDuration.Visible = false; BtnDurationAdd.Visible = false; GVDuration.Visible = false; LblDurAlert.Visible = false; ViewState["durSel"] = 1; GenerateRequisitionTrendController grtc = new GenerateRequisitionTrendController(); List <string> allMonths = grtc.GetRequisitionsUpTo2MonthsAgo(); DDLFrom.DataSource = allMonths; DDLFrom.DataBind(); ViewState["fromMonth"] = DDLFrom.SelectedValue; break; case 2: LblFrom.Visible = false; DDLFrom.Visible = false; DDLDuration.Visible = true; BtnDurationAdd.Visible = true; GVDuration.Visible = true; ViewState["durSel"] = 2; GenerateRequisitionTrendController Grtc1 = new GenerateRequisitionTrendController(); List <string> FromMths = Grtc1.GetUniqueRequisitionMonths(); DDLDuration.DataSource = FromMths; DDLDuration.DataBind(); break; } } else { switch (selectedIndex) { case 0: LblFrom.Visible = false; DDLFrom.Visible = false; DDLDuration.Visible = false; BtnDurationAdd.Visible = false; GVDuration.Visible = false; LblDurAlert.Visible = false; ViewState["durSel"] = 0; break; case 1: LblFrom.Visible = true; DDLFrom.Visible = true; DDLDuration.Visible = false; BtnDurationAdd.Visible = false; GVDuration.Visible = false; LblDurAlert.Visible = false; ViewState["durSel"] = 1; GenerateReorderTrendController grtc = new GenerateReorderTrendController(); List <string> allMonths = grtc.GetRequisitionsUpTo2MonthsAgo(); DDLFrom.DataSource = allMonths; DDLFrom.DataBind(); ViewState["fromMonth"] = DDLFrom.SelectedValue; break; case 2: LblFrom.Visible = false; DDLFrom.Visible = false; DDLDuration.Visible = true; BtnDurationAdd.Visible = true; GVDuration.Visible = true; ViewState["durSel"] = 2; GenerateReorderTrendController Grtc1 = new GenerateReorderTrendController(); List <string> FromMths = Grtc1.GetUniqueRequisitionMonths(); DDLDuration.DataSource = FromMths; DDLDuration.DataBind(); break; } } }
protected void BtnGenerate_Click(object sender, EventArgs e) { try { bool areAllFieldsValid = VerifyAllCustomFieldsAreValid(); ReportToSelect = Request.QueryString["type"]; if (ReportToSelect == "RTR") { if (areAllFieldsValid) { GenerateRequisitionTrendController genRTC = new GenerateRequisitionTrendController(); List <string> deptSelected = GetSelectedDepartments(); List <string> catSelected = GetSelectedCategories(); List <string> duratnSelected = GetSelectedDuration(); List <TrendReport> basicReportObjects = new List <TrendReport>(); int splitBySelected = RBtnLSplit.SelectedIndex; if (splitBySelected == 0) { foreach (string dept in deptSelected) { string categoryName; string departmentName = dept; int month1 = 0, month2 = 0, month3 = 0; foreach (string cat in catSelected) { categoryName = cat; TrendReport input; if (duratnSelected.Count == 1) { month1 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[0], dept, cat); input = new TrendReport(departmentName, categoryName, month1, duratnSelected[0]); basicReportObjects.Add(input); } else if (duratnSelected.Count == 2) { month1 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[0], dept, cat); month2 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[1], dept, cat); input = new TrendReport(departmentName, categoryName, month1, month2, duratnSelected[0], duratnSelected[1]); basicReportObjects.Add(input); } else { month1 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[0], dept, cat); month2 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[1], dept, cat); month3 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[2], dept, cat); input = new TrendReport(departmentName, categoryName, month1, month2, month3, duratnSelected[0], duratnSelected[1], duratnSelected[2]); basicReportObjects.Add(input); } } } } else { foreach (string cat in catSelected) { string categoryName = cat; string departmentName = ""; int month1 = 0, month2 = 0, month3 = 0; foreach (string dept in deptSelected) { departmentName = dept; TrendReport input; if (duratnSelected.Count == 1) { month1 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[0], dept, cat); input = new TrendReport(departmentName, categoryName, month1, duratnSelected[0]); basicReportObjects.Add(input); } else if (duratnSelected.Count == 2) { month1 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[0], dept, cat); month2 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[1], dept, cat); input = new TrendReport(departmentName, categoryName, month1, month2, duratnSelected[0], duratnSelected[1]); basicReportObjects.Add(input); } else { month1 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[0], dept, cat); month2 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[1], dept, cat); month3 = genRTC.GetTotalRequisitionByCategoryGivenMonth(duratnSelected[2], dept, cat); input = new TrendReport(departmentName, categoryName, month1, month2, month3, duratnSelected[0], duratnSelected[1], duratnSelected[2]); basicReportObjects.Add(input); } } } } Session["reportsToDisplay"] = basicReportObjects; Session["typeOfReport"] = splitBySelected; Response.Redirect("~/Store/TrendReportDisplay.aspx"); } else { //Utility.DisplayAlertMessage(Message.CustomFieldsNotSelected); if ((int)ViewState["catSel"] == 1 && GVCategory.Rows.Count == 0) { LblCatAlert.Visible = true; } if ((int)ViewState["durSel"] == 2 && GVDuration.Rows.Count == 0) { LblDurAlert.Visible = true; } if ((int)ViewState["sharedListSel"] == 1 && GVShared.Rows.Count == 0) { LblSharedAlert.Visible = true; } } } else if (ReportToSelect == "ROR") { if (areAllFieldsValid) { GenerateReorderTrendController genRTC = new GenerateReorderTrendController(); List <string> duratnSelected = GetSelectedDuration(); List <string> catSelected = GetSelectedCategories(); List <string> supplierSelected = GetSelectedSuppliers(); List <TrendReport> basicReportObjects = new List <TrendReport>(); int splitBySelected = RBtnLSplitROR.SelectedIndex; if (splitBySelected == 0) { foreach (string suppl in supplierSelected) { string categoryName; string supplierName = suppl; int month1 = 0, month2 = 0, month3 = 0; foreach (string cat in catSelected) { categoryName = cat; TrendReport input; if (duratnSelected.Count == 1) { month1 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[0], suppl, cat); input = new TrendReport(supplierName, categoryName, month1, duratnSelected[0]); basicReportObjects.Add(input); } else if (duratnSelected.Count == 2) { month1 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[0], suppl, cat); month2 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[1], suppl, cat); input = new TrendReport(supplierName, categoryName, month1, month2, duratnSelected[0], duratnSelected[1]); basicReportObjects.Add(input); } else { month1 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[0], suppl, cat); month2 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[1], suppl, cat); month3 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[2], suppl, cat); input = new TrendReport(supplierName, categoryName, month1, month2, month3, duratnSelected[0], duratnSelected[1], duratnSelected[2]); basicReportObjects.Add(input); } } } Session["typeOfReport"] = 2; } else { foreach (string cat in catSelected) { string categoryName = cat; string supplierName = ""; int month1 = 0, month2 = 0, month3 = 0; foreach (string suppl in supplierSelected) { supplierName = suppl; TrendReport input; if (duratnSelected.Count == 1) { month1 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[0], suppl, cat); input = new TrendReport(supplierName, categoryName, month1, duratnSelected[0]); basicReportObjects.Add(input); } else if (duratnSelected.Count == 2) { month1 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[0], suppl, cat); month2 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[1], suppl, cat); input = new TrendReport(supplierName, categoryName, month1, month2, duratnSelected[0], duratnSelected[1]); basicReportObjects.Add(input); } else { month1 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[0], suppl, cat); month2 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[1], suppl, cat); month3 = genRTC.GetTotalReorderByCategoryGivenMonth(duratnSelected[2], suppl, cat); input = new TrendReport(supplierName, categoryName, month1, month2, month3, duratnSelected[0], duratnSelected[1], duratnSelected[2]); basicReportObjects.Add(input); } } } Session["typeOfReport"] = 3; } Session["reportsToDisplay"] = basicReportObjects; Response.Redirect("~/Store/TrendReportDisplay.aspx"); } else { //Utility.DisplayAlertMessage(Message.CustomFieldsNotSelected); if ((int)ViewState["catSel"] == 1 && GVCategory.Rows.Count == 0) { LblCatAlert.Visible = true; } if ((int)ViewState["durSel"] == 2 && GVDuration.Rows.Count == 0) { LblDurAlert.Visible = true; } if ((int)ViewState["sharedListSel"] == 1 && GVShared.Rows.Count == 0) { LblSharedAlert.Visible = true; } } } } catch (Exception) { Utility.DisplayAlertMessage(Message.GeneralError); } }