protected void lnkDisplayInputs(object sender, EventArgs e) { EHSProfile profile = null; LinkButton lnk = (LinkButton)sender; string cmdID = lnk.CommandArgument; string id = lnk.ID; CheckBox cb; EHSCalcsCtl esMgr = new EHSCalcsCtl().CreateNew(SessionManager.FYStartDate().Month, DateSpanOption.SelectRange); foreach (RepeaterItem r in rptProfile.Items) { Repeater rptStatus = (Repeater)r.FindControl("rptProfileStatus"); foreach (RepeaterItem item in rptStatus.Items) { lnk = (LinkButton)item.FindControl("lnkInputs"); if (lnk.CommandArgument == cmdID) { profile = LocalProfileList().Where(l => l.Plant.PLANT_ID == Convert.ToDecimal(cmdID)).FirstOrDefault(); Ucl_MetricList ucl = (Ucl_MetricList)item.FindControl("uclInputsList"); if (id.Contains("Inputs")) { cb = (CheckBox)item.FindControl("cbInputsSelect"); cb.Checked = cb.Checked == false ? true : false; if (cb.Checked) { ucl.BindInputsList(profile); ucl.BindHistoryList(null, null); // cb.Focus(); } else { ucl.BindInputsList(null); } } else { cb = (CheckBox)item.FindControl("cbHistorySelect"); cb.Checked = cb.Checked == false ? true : false; if (cb.Checked) { esMgr.LoadMetricHistory(new decimal[1] { profile.Plant.PLANT_ID }, profile.InputPeriod.PeriodDate, profile.InputPeriod.PeriodDate, DateIntervalType.month, false); ucl.BindHistoryList(profile, esMgr.MetricHst); ucl.BindInputsList(null); // cb.Focus(); } else { ucl.BindHistoryList(null, null); } } break; } } } ((LinkButton)sender).Focus(); }
private void SearchAuditSchedulers() { string selectedValue = ""; List <decimal> plantIDS = SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => Convert.ToDecimal(i.Value)).ToList(); var typeList = new List <decimal>(); typeList = rcbAuditType.Items.Where(c => c.Checked).Select(c => Convert.ToDecimal(c.Value)).ToList(); selectedValue = rcbStatusSelect.SelectedValue; List <int> dayofweekList = SQMBasePage.GetComboBoxCheckedItems(rcbScheduleDay).Select(i => Convert.ToInt32(i.Value)).ToList(); EHSCalcsCtl calcs = new EHSCalcsCtl(); List <EHSAuditSchedulerData> scheduler = calcs.SelectAuditSchedulerList(plantIDS, typeList, dayofweekList, selectedValue); uclAuditScheduleList.BindAuditListRepeater(scheduler, "EHS"); pnlAuditDetails.Visible = lnkAuditDetailsClose.Visible = false; HtmlGenericControl div = (HtmlGenericControl)uclAuditScheduleDetail.FindControl("divAuditForm"); div.Visible = false; }
public void LoadMetricHistory() { SetLocalProfileList(new List <EHSProfile>()); foreach (RadComboBoxItem item in SQMBasePage.GetComboBoxCheckedItems(ddlExportPlantSelect)) { if (radExportDateSelect1.SelectedDate != null) { EHSProfile profile = new EHSProfile().Load(Convert.ToDecimal(item.Value), false, true); if (profile.Profile != null) { LocalProfileList().Add(profile); DateTime fromDate = (DateTime)radExportDateSelect1.SelectedDate; DateTime toDate = new DateTime(radExportDateSelect2.SelectedDate.Value.Year, radExportDateSelect2.SelectedDate.Value.Month, DateTime.DaysInMonth(radExportDateSelect1.SelectedDate.Value.Year, radExportDateSelect1.SelectedDate.Value.Month)); EHSCalcsCtl esMgr = new EHSCalcsCtl().CreateNew(SessionManager.FYStartDate().Month, DateSpanOption.SelectRange).LoadMetricHistory(new decimal[1] { profile.Plant.PLANT_ID }, fromDate, toDate, DateIntervalType.month, false); uclHistoryList.BindHistoryList(profile, esMgr.MetricHst); } } } }
protected void Page_Load(object sender, EventArgs e) { PSsqmEntities ctx = new PSsqmEntities(); string delimStr = "~"; char[] delimiter = delimStr.ToCharArray(); string[] exportParms = null; string[] plants = null; int loop1; exportParms = SessionManager.ExportCriteria.Split(delimiter); delimStr = ","; delimiter = null; delimiter = delimStr.ToCharArray(); plants = exportParms[1].Split(delimiter); decimal[] plantIDs = new decimal[plants.Length]; for (loop1 = 0; loop1 < plants.Length; loop1++) { plantIDs[loop1] = Convert.ToDecimal(plants[loop1]); } DateTime dtFrom = Convert.ToDateTime(exportParms[2]); DateTime dtTo = Convert.ToDateTime(exportParms[3]); EHSCalcsCtl esMgr = new EHSCalcsCtl().CreateNew(SessionManager.FYStartDate().Month, DateSpanOption.SelectRange, "E"); esMgr.LoadMetricHistory(plantIDs, dtFrom, dtTo, DateIntervalType.month, false); List <MetricData> metric_history = esMgr.MetricHst.OrderBy(l => l.MetricRec.PLANT_ID).ThenBy(l => l.MetricRec.PERIOD_YEAR).ThenBy(l => l.MetricRec.PERIOD_MONTH).ThenBy(l => l.Measure.MEASURE_CATEGORY).ThenBy(l => l.Measure.MEASURE_CD).ToList(); string uom_cd; string uom_input_cd; decimal uom_id = 0; // need to cycle thru and populate the UOM and other formatting try { string filename = exportParms[0].Trim() + ".xls"; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename)); Response.Clear(); InitializeWorkbook(); ISheet sheet1 = hssfworkbook.CreateSheet("Metric History"); //// create the header - Plant Name, DUNS Code, Measure, Measure Name, Period Year, Period Month, Period from Date, Period To Date, Value, UOM, UOM Name, Input Value, Cost, Currency, Input Cost, Input Currency IRow row = sheet1.CreateRow(0); row.CreateCell(0).SetCellValue("Plant Name"); row.CreateCell(1).SetCellValue("DUNS Code"); row.CreateCell(2).SetCellValue("Measure"); row.CreateCell(3).SetCellValue("Measure Name"); row.CreateCell(4).SetCellValue("Period Year"); row.CreateCell(5).SetCellValue("Period Month"); row.CreateCell(6).SetCellValue(Resources.LocalizedText.Value); row.CreateCell(7).SetCellValue("UOM"); row.CreateCell(8).SetCellValue("Input Value"); row.CreateCell(9).SetCellValue("Input UOM"); row.CreateCell(10).SetCellValue(Resources.LocalizedText.Cost); row.CreateCell(11).SetCellValue("Currency"); row.CreateCell(12).SetCellValue("Input Cost"); row.CreateCell(13).SetCellValue("Input Currency"); ICell cellNumeric; ICellStyle cellStyleNumeric = hssfworkbook.CreateCellStyle(); cellStyleNumeric.DataFormat = HSSFDataFormat.GetBuiltinFormat("0.00"); for (int irows = 0; irows < metric_history.Count; irows++) { int rownum = irows + 1; UOM uom = null; uom_id = metric_history[irows].MetricRec.UOM_ID; uom = SessionManager.UOMList.FirstOrDefault(l => l.UOM_ID == uom_id); if (uom != null) { uom_cd = uom.UOM_CD; } else { uom_cd = ""; } try { uom_id = Convert.ToDecimal(metric_history[irows].MetricRec.INPUT_UOM_ID.ToString()); uom = SessionManager.UOMList.FirstOrDefault(l => l.UOM_ID == uom_id); if (uom != null) { uom_input_cd = uom.UOM_CD; } else { uom_input_cd = ""; } } catch { uom_input_cd = ""; } // create a column for each field we want PLANT plant = SQMModelMgr.LookupPlant(ctx, metric_history[irows].MetricRec.PLANT_ID, ""); //metric_history[irows].Plant; EHS_MEASURE measure = metric_history[irows].Measure as EHS_MEASURE; row = sheet1.CreateRow(rownum); try { row.CreateCell(0).SetCellValue(plant.PLANT_NAME); } catch { row.CreateCell(0).SetCellValue(""); } try { row.CreateCell(1).SetCellValue(plant.DUNS_CODE); } catch { row.CreateCell(1).SetCellValue(""); } try { row.CreateCell(2).SetCellValue(measure.MEASURE_CD); } catch { row.CreateCell(2).SetCellValue(""); } try { row.CreateCell(3).SetCellValue(measure.MEASURE_NAME); } catch { row.CreateCell(3).SetCellValue(""); } try { row.CreateCell(4).SetCellValue(metric_history[irows].MetricRec.PERIOD_YEAR); } catch { row.CreateCell(4).SetCellValue(""); } try { row.CreateCell(5).SetCellValue(metric_history[irows].MetricRec.PERIOD_MONTH); } catch { row.CreateCell(5).SetCellValue(""); } try { cellNumeric = row.CreateCell(6); cellNumeric.CellStyle = cellStyleNumeric; cellNumeric.SetCellValue(Convert.ToDouble(metric_history[irows].MetricRec.MEASURE_VALUE)); } catch { row.CreateCell(6).SetCellValue(""); } try { row.CreateCell(7).SetCellValue(uom_cd); } catch { row.CreateCell(7).SetCellValue(""); } try { cellNumeric = row.CreateCell(8); cellNumeric.CellStyle = cellStyleNumeric; cellNumeric.SetCellValue(Convert.ToDouble(metric_history[irows].MetricRec.INPUT_VALUE)); } catch { row.CreateCell(8).SetCellValue(""); } try { row.CreateCell(9).SetCellValue(uom_input_cd); } catch { row.CreateCell(9).SetCellValue(""); } try { cellNumeric = row.CreateCell(10); cellNumeric.CellStyle = cellStyleNumeric; cellNumeric.SetCellValue(Convert.ToDouble(metric_history[irows].MetricRec.MEASURE_COST)); } catch { row.CreateCell(10).SetCellValue(""); } try { row.CreateCell(11).SetCellValue(metric_history[irows].MetricRec.CURRENCY_CODE); } catch { row.CreateCell(11).SetCellValue(""); } try { cellNumeric = row.CreateCell(12); cellNumeric.CellStyle = cellStyleNumeric; cellNumeric.SetCellValue(Convert.ToDouble(metric_history[irows].MetricRec.INPUT_COST)); } catch { row.CreateCell(12).SetCellValue(""); } try { row.CreateCell(13).SetCellValue(metric_history[irows].MetricRec.INPUT_CURRENCY_CODE); } catch { row.CreateCell(13).SetCellValue(""); } } sheet1.AutoSizeColumn(0); sheet1.AutoSizeColumn(1); sheet1.AutoSizeColumn(2); sheet1.AutoSizeColumn(3); sheet1.AutoSizeColumn(4); sheet1.AutoSizeColumn(5); sheet1.AutoSizeColumn(6); sheet1.AutoSizeColumn(7); sheet1.AutoSizeColumn(8); sheet1.AutoSizeColumn(9); sheet1.AutoSizeColumn(10); sheet1.AutoSizeColumn(11); sheet1.AutoSizeColumn(12); sheet1.AutoSizeColumn(13); GetExcelStream().WriteTo(Response.OutputStream); Response.End(); } catch (Exception ex) { //Response.Write("Error processing the file:" + ex.Message.ToString()); Response.End(); } }