protected void btnUpdate_Click(object sender, EventArgs e) { try { DateTime?dtWEF = null; double? value = 0.00; DateTime?dtWET = null; if (txtEffectivedate.Text != "") { dtWEF = Convert.ToDateTime(txtEffectivedate.Text); } if (txtEfffectTo.Text != "") { dtWET = Convert.ToDateTime(txtEfffectTo.Text); } if (txtSB.Text != "") { value = Convert.ToDouble(txtSB.Text); } PI_ID = Convert.ToInt32(Request.QueryString["PI_ID"]); BLL_TMSA_PI.Update_PI_Head(Convert.ToInt32(ViewState["Detail_ID"].ToString()), Convert.ToInt32(Request.QueryString[0]), ddlYear.SelectedValue, null, dtWEF, dtWET, null, value, UDFLib.ConvertToInteger(Session["UserID"].ToString())); LoadSearchResults(); divEDIT.Visible = false; txtEffectivedate.Text = ""; txtEfffectTo.Text = ""; } catch (Exception ex) { ltmessage.Text = ex.ToString(); } }
protected void SaveData() { ltmessage.Text = ""; try { string Interval = ddlIntervalUnit.SelectedValue; string PI_Name = txtItemDescription.Text; string PICode = txtPICode.Text; string Description = txtItemDescription.Text; string Context = null; DataTable dtPI = new DataTable(); dtPI.Columns.Add("PI_ID"); foreach (ListItem chkitem in chkPI.Items) { if (chkitem.Selected) { DataRow dr = dtPI.NewRow(); dr["PI_ID"] = chkitem.Value; } } int result = BLL_TMSA_PI.INS_KPI_Details(PI_Name, PICode, Interval, Description, dtPI, UDFLib.ConvertToInteger(Session["UserID"].ToString())); ClearData(); } catch (Exception ex) { ltmessage.Text = ex.ToString(); } }
/// <summary> /// Description:Method to bind PI header information /// </summary> protected void BindHeadinfo() { //ClearData(); PI_ID = Convert.ToInt32(Request.QueryString[0]); if (ViewState["Detail_ID"] != null) { Detail_ID = Convert.ToInt32(ViewState["Detail_ID"]); DataTable dt = BLL_TMSA_PI.Get_PI_Head_Details(PI_ID, Detail_ID).Tables[0]; ddlYear.SelectedValue = dt.Rows[0]["ForYear"].ToString(); txtEffectivedate.Text = dt.Rows[0]["Effective_From"].ToString(); txtEfffectTo.Text = dt.Rows[0]["Effective_To"].ToString(); string QtrMonth = dt.Rows[0]["QtrMonth"].ToString(); if (ddlMonths.Items.FindByValue(QtrMonth) != null) { ddlMonths.SelectedValue = ddlMonths.Items.FindByValue(QtrMonth).Value; } if (ddlQuarter.Items.FindByValue(QtrMonth) != null) { ddlQuarter.SelectedValue = ddlQuarter.Items.FindByValue(QtrMonth).Value; } if (Convert.ToInt16(dt.Rows[0]["Vessel_Id"]) != 0) { divEDIT.Visible = true; lblVesselName.Text = BLL_TMSA_PI.Get_PI_Head_Details(PI_ID, Detail_ID).Tables[1].Rows[0]["Vessel_Name"].ToString(); txtSB.Text = dt.Rows[0]["Value"].ToString(); } else { txtSBU.Text = dt.Rows[0]["Value"].ToString(); } //BindPIValues(); } }
protected void BindGrid() { try { string category = ddlCategory.SelectedValue; if (ddlCategory.SelectedIndex == 0) { category = ""; } int rowcount = ucCustomPager1.isCountRecord; DataTable dt = BLL_TMSA_PI.Get_KPI_List(txtSearch.Text, ucCustomPager1.CurrentPageIndex, ucCustomPager1.PageSize, ref rowcount, category).Tables[0]; if (dt.Rows.Count > 0) { btnExport.Visible = true; } if (ucCustomPager1.isCountRecord == 1) { ucCustomPager1.CountTotalRec = rowcount.ToString(); ucCustomPager1.BuildPager(); } gvKPIList.DataSource = dt; gvKPIList.DataBind(); } catch (Exception ex) { } }
protected void loadPIDetails() { DataSet ds = BLL_TMSA_PI.Get_KPI_Detail(UDFLib.ConvertIntegerToNull(hiddenKPIID.Value)); if (ds.Tables[0].Rows.Count > 0) { ltKPI.Text = ds.Tables[0].Rows[0]["Name"].ToString(); hiddenKPIName.Value = ds.Tables[0].Rows[0]["Name"].ToString(); DataTable dt = new DataTable(); DataTable dtPIDtl = ds.Tables[1]; dt.Columns.Add(new DataColumn("sno", typeof(int))); dt.Columns.Add(new DataColumn("PID", typeof(string))); dt.Columns.Add(new DataColumn("value", typeof(string))); dt.Columns.Add(new DataColumn("PIName", typeof(string))); string exp = ""; foreach (DataRow row in dtPIDtl.Rows) { dt.Rows.Add(new object[] { Convert.ToInt32(row["SerialNumber"].ToString()), row["PI_ID"].ToString(), row["value"].ToString(), row["Name"].ToString() }); exp = exp + row["value"].ToString(); } lblFormula.Text = "KPI Formula : " + exp; DataTable dt_PI = dt; dt_PI.DefaultView.RowFilter = "PID <> ''"; DataList1.DataSource = dt_PI.DefaultView; DataList1.DataBind(); } }
/// <summary> /// Method to export data to excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExport_Click(object sender, ImageClickEventArgs e) { try { int rowcount = ucCustomPager1.isCountRecord; string PIName = "PI Name: "; PI_ID = Convert.ToInt32(Request.QueryString["PI_ID"]); DateTime?dtWEF = null; DateTime?dtWET = null; if (txtSearchFrom.Text != "") { dtWEF = Convert.ToDateTime(txtSearchFrom.Text); } if (txtSearchTo.Text != "") { dtWET = Convert.ToDateTime(txtSearchTo.Text); } if (ViewState["PI_Name"] != null) { PIName = PIName + ViewState["PI_Name"].ToString(); } DataTable dt = BLL_TMSA_PI.Get_Vessel_Values(Convert.ToInt32(ddlVessel.SelectedValue), dtWEF, dtWET, PI_ID, null, null, ref rowcount).Tables[0]; string[] HeaderCaptions = { "Vessel", "Effect From", "Effect To", "PI Value", "Created ON" }; string[] DataColumnsName = { "Vessel_Name", "Effective_From", "Effective_To", "Value", "Date_Of_Creation" }; GridViewExportUtil.ExportToExcel(dt, HeaderCaptions, DataColumnsName, PIName, PIName); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
/// <summary> /// Method to export data to excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExport_Click(object sender, ImageClickEventArgs e) { int rowcount = ucCustomPager1.isCountRecord; string PIName = "PI Name: "; PI_ID = Convert.ToInt32(Request.QueryString["PI_ID"]); DateTime?dtWEF = null; DateTime?dtWET = null; if (txtSearchFrom.Text != "") { dtWEF = Convert.ToDateTime(txtSearchFrom.Text); } if (txtSearchTo.Text != "") { dtWET = Convert.ToDateTime(txtSearchTo.Text); } DataSet ds = BLL_TMSA_PI.Get_RankWise_Values(Convert.ToInt32(ddlRank.SelectedValue), dtWEF, dtWET, PI_ID, null, null, ref rowcount); DataTable dt = ds.Tables[0]; PIName = "PI Rankwise : " + ds.Tables[1].Rows[0]["Name"]; string[] HeaderCaptions = { "Rank", "Effect From", "Effect To", "PI Value", "Created On", "Last Modified" }; string[] DataColumnsName = { "Rank", "Effective_From_Str", "Effective_To", "Value", "Date_Of_Creation", "Date_Of_Modification" }; GridViewExportUtil.ExportToExcel(dt, HeaderCaptions, DataColumnsName, PIName, PIName); }
protected void loadPIDetails() { int KPI_ID = 0; DataTable dtKPI = objKPI.GetGoal(0, "KPI030", 0); if (dtKPI.Rows[0]["KPI_ID"] != null) { KPI_ID = Convert.ToInt32(dtKPI.Rows[0]["KPI_ID"]); } DataSet ds = BLL_TMSA_PI.Get_KPI_Detail(KPI_ID); DataTable dt = new DataTable(); DataTable dtPIDtl = ds.Tables[1]; dt.Columns.Add(new DataColumn("sno", typeof(int))); dt.Columns.Add(new DataColumn("PID", typeof(string))); dt.Columns.Add(new DataColumn("value", typeof(string))); dt.Columns.Add(new DataColumn("PIName", typeof(string))); string exp = ""; if (dtPIDtl.Rows.Count > 0) { foreach (DataRow row in dtPIDtl.Rows) { dt.Rows.Add(new object[] { Convert.ToInt32(row["SerialNumber"].ToString()), row["PI_ID"].ToString(), row["value"].ToString(), row["Name"].ToString() }); exp = exp + row["value"].ToString(); } lblFormula.Text = "KPI Formula : " + exp; DataTable dt_PI = dt; dt_PI.DefaultView.RowFilter = "PID <> ''"; DataList1.DataSource = dt_PI.DefaultView; DataList1.DataBind(); } }
/// <summary> /// Description: If by voyage is selected , for all vessels voyage ddl wil populate based on search date /// </summary> protected void ddlVoyage_SelectedIndexChanged(object sender, EventArgs e) { try { DateTime?Startdate = null; //Startdate = Convert.ToDateTime(txtStartDate.Text); Startdate = Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtStartDate.Text)); DateTime?EndDate = null; //EndDate = Convert.ToDateTime(txtEndDate.Text); EndDate = Convert.ToDateTime(UDFLib.ConvertToDate(txtEndDate.Text)); DropDownList ddlVoyage = (DropDownList)sender; GridDataItem item = (GridDataItem)ddlVoyage.NamingContainer; Label txtSrno = (Label)item.FindControl("Vessel_Average"); HiddenField hdf = (HiddenField)item.FindControl("hdVesselID"); LinkButton lnkVessel = (LinkButton)item.FindControl("Item_Name"); if (ddlVoyage.SelectedIndex != 0) { string val = ddlVoyage.SelectedValue.Trim().Split(':')[0] + ":" + ddlVoyage.SelectedValue.Trim().Split(':')[1]; DataTable dtq = BLL_TMSA_PI.GetTelDate(val.Trim(), Convert.ToInt32(hdf.Value)).Tables[0]; if (dtq.Rows[0][0].ToString() != "") { Startdate = Convert.ToDateTime(dtq.Rows[0][1].ToString()); hiddenStartDate.Value = Startdate.Value.Date.ToString("dd-MM-yyyy"); } if (dtq.Rows[dtq.Rows.Count - 1][0].ToString() != "") { EndDate = Convert.ToDateTime(dtq.Rows[dtq.Rows.Count - 1][1].ToString()); hiddenEndDate.Value = EndDate.Value.Date.ToString("dd-MM-yyyy"); } } DataTable dt = BLL_TMSA_PI.GetVoyageDataNOx(ddlVoyage.SelectedValue.Trim(), Convert.ToInt32(hdf.Value)).Tables[0]; if (dt.Rows.Count > 0) { txtSrno.Text = Math.Round(Convert.ToDouble(dt.Rows[0]["Value"].ToString()), 2).ToString(); if (Convert.ToDouble(dt.Rows[0]["Value"]) == 0) { lnkVessel.Enabled = false; item["Vessel"].BackColor = System.Drawing.Color.White; } else { lnkVessel.Enabled = true; } } else { txtSrno.Text = "0"; lnkVessel.Enabled = false; item["Vessel"].BackColor = System.Drawing.Color.White; } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
protected void btnExport_Click(object sender, ImageClickEventArgs e) { try { if (checkVoyage.Checked == false) { if (txtStartDate.Text != "") { Startdate = Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtStartDate.Text)); } if (txtEndDate.Text != "") { EndDate = Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtEndDate.Text)); } DataTable dt = BLL_TMSA_PI.Search_PI_ValuesNOX(Convert.ToInt32(ddlvessel.SelectedValue), Convert.ToDateTime(txtStartDate.Text).ToString("yyyy-MM-dd"), Convert.ToDateTime(txtEndDate.Text).ToString("yyyy-MM-dd")).Tables[0]; string[] HeaderCaptions = { "Record_Date", "Value" }; string[] DataColumnsName = { "Record_Date", "Value" }; GridViewExportUtil.ShowExcel(dt, HeaderCaptions, DataColumnsName, "NOX Effeciency-" + ddlvessel.SelectedItem.Text, "NOX Effeciency-" + ddlvessel.SelectedItem.Text); } else { DataTable liTable = new DataTable(); if (listVoyage.Items.Count > 0) { for (int x = 0; x < listVoyage.Items.Count; x++) { //string v1 = listVoyage.Items[0].Value.Split(':')[1].Trim(); //string v2 = listVoyage.Items[listVoyage.Items.Count - 1].Value.Split(':')[0].Trim(); string val = listVoyage.Items[x].Value.Split(':')[0] + ":" + listVoyage.Items[x].Value.Split(':')[1]; DataTable dtq = BLL_TMSA_PI.GetTelDate(val.Trim(), Convert.ToInt32(ddlvessel.SelectedValue)).Tables[0]; if (dtq.Rows[0]["Telegram_Date_DDMM"].ToString() != "") { Startdate = Convert.ToDateTime(dtq.Rows[0]["Telegram_Date_DDMM"].ToString()); } if (dtq.Rows[dtq.Rows.Count - 1]["Telegram_Date_DDMM"].ToString() != "") { EndDate = Convert.ToDateTime(dtq.Rows[dtq.Rows.Count - 1]["Telegram_Date_DDMM"].ToString()); } DataTable dt = BLL_TMSA_PI.GetVoyageDataNOx(listVoyage.Items[x].Value.Trim(), Convert.ToInt32(ddlvessel.SelectedValue)).Tables[0]; liTable.Merge(dt); } string[] HeaderCaptions = { "From Port", "To Port", "Effective From", "Effective To", "Efficiency" }; string[] DataColumnsName = { "FromPort", "ToPort", "EffectiveFrom", "EffectiveTo", "Value" }; GridViewExportUtil.ExportToExcel(liTable, HeaderCaptions, DataColumnsName, "NOX Effeciency-" + ddlvessel.SelectedItem.Text, "NOX Effeciency(Voyage)-" + ddlvessel.SelectedItem.Text); } } } catch (Exception ex) { } }
protected void LoadQueryList() { BLL_TMSA_PI objPIBLL = new BLL_TMSA_PI(); ddlListSource.DataSource = objPIBLL.Get_SavedQuery("", "TMSA_KPI_Daemon_SP", GetSessionUserID()); ddlListSource.DataTextField = "ObjectName"; ddlListSource.DataValueField = "ObjectName"; ddlListSource.DataBind(); ddlListSource.Items.Insert(0, new ListItem("-SELECT-", "0")); }
protected void BindVoyageData() { DataTable liTable = new DataTable(); if (listVoyage.Items.Count > 0) { for (int x = 0; x < listVoyage.Items.Count; x++) { //string v1 = listVoyage.Items[0].Value.Split(':')[1].Trim(); //string v2 = listVoyage.Items[listVoyage.Items.Count - 1].Value.Split(':')[0].Trim(); string val = listVoyage.Items[x].Value.Split(':')[0] + ":" + listVoyage.Items[x].Value.Split(':')[1]; DataTable dtq = BLL_TMSA_PI.GetTelDate(val.Trim(), Convert.ToInt32(ddlvessel.SelectedValue)).Tables[0]; if (dtq.Rows[0]["Telegram_Date_DDMM"].ToString() != "") { Startdate = Convert.ToDateTime(dtq.Rows[0]["Telegram_Date_DDMM"].ToString()); } if (dtq.Rows[dtq.Rows.Count - 1]["Telegram_Date_DDMM"].ToString() != "") { EndDate = Convert.ToDateTime(dtq.Rows[dtq.Rows.Count - 1]["Telegram_Date_DDMM"].ToString()); } DataTable dt = BLL_TMSA_PI.GetVoyageData(listVoyage.Items[x].Value.Trim(), Convert.ToInt32(ddlvessel.SelectedValue), KPI_ID).Tables[0]; liTable.Merge(dt); } gvVoyage.Visible = true; gvSearch.Visible = false; gvVoyage.DataSource = liTable; gvVoyage.DataBind(); if (liTable.Rows.Count != 0) { double AVG = Convert.ToDouble(liTable.Compute("AVG(Value)", "").ToString()); hiddenAVG.Value = Math.Round(AVG, 2).ToString(); gvVoyage.FooterRow.Cells[4].Text = "Average: " + Math.Round(AVG, 2).ToString(); gvVoyage.FooterRow.Cells[4].HorizontalAlign = HorizontalAlign.Center; gvVoyage.FooterRow.Cells[4].ForeColor = System.Drawing.Color.Black; gvVoyage.FooterRow.Cells[4].BorderColor = System.Drawing.ColorTranslator.FromHtml("#EFEFEF"); gvVoyage.FooterRow.Cells[3].BorderColor = System.Drawing.ColorTranslator.FromHtml("#EFEFEF"); gvVoyage.FooterRow.Cells[2].BorderColor = System.Drawing.ColorTranslator.FromHtml("#EFEFEF"); gvVoyage.FooterRow.Cells[1].BorderColor = System.Drawing.ColorTranslator.FromHtml("#EFEFEF"); gvVoyage.FooterRow.Cells[0].BorderColor = System.Drawing.ColorTranslator.FromHtml("#EFEFEF"); //txtGoal.Text = ds.Tables[1].Rows[0]["Goal"].ToString(); gvVoyage.FooterRow.BackColor = System.Drawing.ColorTranslator.FromHtml("#abcdef"); hiddengVoyageCount.Value = "1"; } else { hiddengVoyageCount.Value = "0"; } getGoal(); } }
/// <summary> /// Description:Method to bind PI header information /// </summary> protected void BindPIDetails() { try { PI_ID = Convert.ToInt32(Request.QueryString[0]); DataTable dtDetail = BLL_TMSA_PI.Get_PI_Details(PI_ID).Tables[0]; if (dtDetail.Rows.Count > 0) { string sPIName = dtDetail.Rows[0]["Name"].ToString(); string sPICode = dtDetail.Rows[0]["Code"].ToString(); ltPageHeader.Text = ltPageHeader.Text + " [" + sPIName + "(" + sPICode + ")" + " ]"; ViewState["PI_Name"] = sPIName + "(" + sPICode + ")"; string sInterval = dtDetail.Rows[0]["Interval"].ToString(); int MeasuredForSBU = Convert.ToInt32(dtDetail.Rows[0]["MeasuredForSBU"]); if (MeasuredForSBU == 1) { ViewState["MeasuredForSBU"] = MeasuredForSBU; ltSBUValue.Visible = true; txtSBU.Visible = true; rgdItems.Visible = false; } else { ltSBUValue.Visible = false; txtSBU.Visible = false; // BindGrid(); } if (sInterval.ToUpper() == "QUARTER") { ltQtrMonth.Text = " For Quarter :"; ddlQuarter.Visible = true; ddlMonths.Visible = false; } else if (sInterval.ToUpper() == "MONTH") { ltQtrMonth.Text = " For Month :"; ddlQuarter.Visible = false; ddlMonths.Visible = true; } else { ltQtrMonth.Visible = false; ddlQuarter.Visible = false; ddlMonths.Visible = false; } } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
protected void InitialCountryBind() { int rowcount = 1; DataTable dt = BLL_TMSA_PI.Get_PI_List(null, "", null, null, ref rowcount).Tables[0]; ddlPIList.DataSource = dt; ddlPIList.DataTextField = "Name"; ddlPIList.DataValueField = "PI_ID"; ddlPIList.DataBind(); ddlPIList.Items.Insert(0, new ListItem("-Select-", "0")); }
protected void SaveData() { ltmessage.Text = ""; try { DateTime?dtWEF = null; DateTime?dtWET = null; double? SBU_Value = null; double? Value = 0.00; if (txtEffectivedate.Text != "") { dtWEF = Convert.ToDateTime(txtEffectivedate.Text); } if (txtEfffectTo.Text != "") { dtWET = Convert.ToDateTime(txtEfffectTo.Text); } else { dtWET = dtWEF; } if (txtSBU.Text != "") { SBU_Value = Convert.ToDouble(txtSBU.Text); } PI_ID = Convert.ToInt32(Request.QueryString["PI_ID"]); if (ddlMonths.Visible == true) { QtrMonth = ddlMonths.SelectedValue; } else if (ddlQuarter.Visible == true) { QtrMonth = ddlQuarter.SelectedValue; } if (dtWEF <= dtWET) { if (ViewState["Detail_ID"] != null) { Detail_ID = Convert.ToInt32(ViewState["Detail_ID"]); Value = 1.00; } DataTable dt = getValueData(); BLL_TMSA_PI.INSERT_PI_Detail(Detail_ID, Value, dt, PI_ID, ddlYear.SelectedValue, QtrMonth, dtWEF, dtWET, SBU_Value, UDFLib.ConvertToInteger(Session["UserID"].ToString()), ref IsExist); } } catch (Exception ex) { ltmessage.Text = ex.ToString(); } }
protected void BindGrid() { try { int rowcount = ucCustomPager1.isCountRecord; string SearchText = txtSearch.Text; string Category = null; if (ddlCategory.SelectedIndex == 0) { Category = ""; } else { Category = ddlCategory.SelectedValue; } DataTable dt = null; DataSet DS = BLL_TMSA_PI.Get_PI_List(SearchText, Category, ucCustomPager1.CurrentPageIndex, ucCustomPager1.PageSize, ref rowcount); if (DS.Tables.Count != 0) { dt = DS.Tables[0]; btnExport.Visible = true; if (ucCustomPager1.isCountRecord == 1) { ucCustomPager1.CountTotalRec = rowcount.ToString(); ucCustomPager1.BuildPager(); } if (dt.Rows.Count > 0) { gvPIList.DataSource = dt; gvPIList.DataBind(); } else { gvPIList.DataSource = null; gvPIList.DataBind(); } } else { gvPIList.DataSource = null; gvPIList.DataBind(); } } catch (Exception ex) { } }
protected void btnExport_Click(object sender, ImageClickEventArgs e) { if (checkVoyage.Checked == false) { if (txtStartDate.Text != "") { Startdate = Convert.ToDateTime(txtStartDate.Text); } if (txtEndDate.Text != "") { EndDate = Convert.ToDateTime(txtEndDate.Text); } string Value_Type = rdListValue.SelectedValue; KPI_ID = Convert.ToInt32(ddlKPIList.SelectedValue); DataTable dt = objKPI.Get_Vessel_KPI_Values(Convert.ToInt32(ddlvessel.SelectedValue), KPI_ID, ddlInterval.SelectedValue, Value_Type, Startdate, EndDate).Tables[0]; string[] HeaderCaptions = { "Record Duration", "KPI Value" }; string[] DataColumnsName = { "Record_Date_Str", "Value" }; GridViewExportUtil.ShowExcel(dt, HeaderCaptions, DataColumnsName, ddlvessel.SelectedItem.Text, ddlvessel.SelectedItem.Text); } else { DataTable liTable = new DataTable(); if (listVoyage.Items.Count > 0) { for (int x = 0; x < listVoyage.Items.Count; x++) { //string v1 = listVoyage.Items[0].Value.Split(':')[1].Trim(); //string v2 = listVoyage.Items[listVoyage.Items.Count - 1].Value.Split(':')[0].Trim(); string val = listVoyage.Items[x].Value.Split(':')[0] + ":" + listVoyage.Items[x].Value.Split(':')[1]; DataTable dtq = BLL_TMSA_PI.GetTelDate(val.Trim(), Convert.ToInt32(ddlvessel.SelectedValue)).Tables[0]; if (dtq.Rows[0][0].ToString() != "") { Startdate = Convert.ToDateTime(dtq.Rows[0][0].ToString()); } if (dtq.Rows[dtq.Rows.Count - 1][0].ToString() != "") { EndDate = Convert.ToDateTime(dtq.Rows[dtq.Rows.Count - 1][0].ToString()); } DataTable dt = BLL_TMSA_PI.GetVoyageDataNOx(listVoyage.Items[x].Value.Trim(), Convert.ToInt32(ddlvessel.SelectedValue)).Tables[0]; liTable.Merge(dt); } string[] HeaderCaptions = { "Deperture Date", "Arrival Date", "From Port", "To Port", "Average" }; string[] DataColumnsName = { "EffectiveFrom", "EffectiveTo", "FromPort", "ToPort", "Value" }; GridViewExportUtil.ExportToExcel(liTable, HeaderCaptions, DataColumnsName, ddlvessel.SelectedItem.Text, ddlvessel.SelectedItem.Text); } } }
/// <summary> /// Method to populate value grid for all vessels /// </summary> protected void BindPIValues() { try { DataTable dt = BLL_TMSA_PI.Get_All_Vessels(Convert.ToInt32(Session["USERCOMPANYID"].ToString())).Tables[0]; rgdItems.DataSource = dt; rgdItems.DataBind(); rgdItems.Visible = true; } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
private void loadFormula() { DataSet ds = BLL_TMSA_PI.Get_KPI_Detail(UDFLib.ConvertIntegerToNull(hiddenKPIID.Value)); DataTable dtPIDtl = ds.Tables[1]; string exp = ""; foreach (DataRow row in dtPIDtl.Rows) { exp = exp + row["value"].ToString(); } lblFormula.Text = "KPI Formula : " + exp; loadPIDetails(); }
public void loadTabs() { DataTable dt = BLL_TMSA_PI.Get_KPI_Category(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { TabPanel tbPanel = new TabPanel(); tbPanel.ID = "tb" + dr["Category"].ToString(); tbPanel.HeaderText = dr["Category"].ToString(); tbPanel.Attributes.Add("OnClick", "btnEdit_Click"); this.TabCon.Controls.Add(tbPanel); } } }
private void loadFormula() { DataTable dtKPI = objKPI.GetGoal(0, "KPI030", 0); string KPI_ID = dtKPI.Rows[0]["KPI_ID"].ToString(); hdnKPIID.Value = KPI_ID; DataSet ds = BLL_TMSA_PI.Get_KPI_Detail(UDFLib.ConvertIntegerToNull(KPI_ID)); DataTable dtPIDtl = ds.Tables[1]; string exp = ""; foreach (DataRow row in dtPIDtl.Rows) { exp = exp + row["value"].ToString(); } lblFormula.Text = "KPI Formula : " + exp; loadPIDetails(); }
private void BindDetails() { DataTable dt = BLL_TMSA_PI.Get_KPI_Detail(UDFLib.ConvertIntegerToNull(ViewState["KPI_ID"])).Tables[0]; if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; if (dr["Interval"] != null) { ddlIntervalUnit.SelectedValue = dr["Interval"].ToString(); } txtItemDescription.Text = dr["Description"].ToString(); txtPIName.Text = dr["Name"].ToString(); txtPICode.Text = dr["Code"].ToString(); } BindPI(); }
protected void BindGrid() { try { string category = ""; int rowcount = 1; DataTable dt = BLL_TMSA_PI.Get_KPI_List("", 1, 100, ref rowcount, category).Tables[0]; gvKPIList.DataSource = dt; gvKPIList.DataBind(); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
protected void btnExport_Click(object sender, ImageClickEventArgs e) { int rowcount = ucCustomPager1.isCountRecord; string SearchText = txtSearch.Text; string Category = null; if (ddlCategory.SelectedIndex == 0) { Category = ""; } else { Category = ddlCategory.SelectedValue; } DataTable dt = null; dt = BLL_TMSA_PI.Get_PI_List(SearchText, Category, null, null, ref rowcount).Tables[0]; string[] HeaderCaptions = { "PI Name", "Code", "Interval", "Description", "Unit", "Status" }; string[] DataColumnsName = { "Name", "Code", "Interval", "Description", "UOM", "Status" }; GridViewExportUtil.ExportToExcel(dt, HeaderCaptions, DataColumnsName, "PI List", "PI List"); }
protected void ddlVoyage_SelectedIndexChanged(object sender, EventArgs e) { try { DateTime?Startdate = null; Startdate = Convert.ToDateTime(txtStartDate.Text); DateTime?EndDate = null; EndDate = Convert.ToDateTime(txtEndDate.Text); int KPI_ID = 1; DropDownList ddlVoyage = (DropDownList)sender; GridDataItem item = (GridDataItem)ddlVoyage.NamingContainer; Label txtSrno = (Label)item.FindControl("Vessel_Average"); HiddenField hdf = (HiddenField)item.FindControl("hdVesselID"); if (ddlVoyage.SelectedIndex != 0) { string val = ddlVoyage.SelectedValue.Trim().Split(':')[0] + ":" + ddlVoyage.SelectedValue.Trim().Split(':')[1]; DataTable dtq = BLL_TMSA_PI.GetTelDate(val.Trim(), Convert.ToInt32(hdf.Value)).Tables[0]; if (dtq.Rows[0][0].ToString() != "") { Startdate = Convert.ToDateTime(dtq.Rows[0][0].ToString()); hiddenStartDate.Value = Startdate.Value.Date.ToString("dd-MM-yyyy"); } if (dtq.Rows[dtq.Rows.Count - 1][0].ToString() != "") { EndDate = Convert.ToDateTime(dtq.Rows[dtq.Rows.Count - 1][0].ToString()); hiddenEndDate.Value = EndDate.Value.Date.ToString("dd-MM-yyyy"); } } DataTable dt = BLL_TMSA_PI.GetVoyageData(ddlVoyage.SelectedValue.Trim(), Convert.ToInt32(hdf.Value), KPI_ID).Tables[0]; txtSrno.Text = Math.Round(Convert.ToDouble(dt.Rows[0]["Value"].ToString()), 2).ToString(); Button1.Visible = true; btnChart.Visible = false; } catch { } }
protected void BindPI() { this.InitialCountryBind(); int? KPI_ID = UDFLib.ConvertIntegerToNull(ViewState["KPI_ID"]); DataTable dt1 = BLL_TMSA_PI.Get_PI_ListByKPI(KPI_ID).Tables[0];//Load by notificationId Session["dtPI"] = dt1; chkPI.DataSource = dt1; chkPI.DataTextField = "Name"; chkPI.DataValueField = "PI_ID"; chkPI.DataBind(); foreach (ListItem chkitem in chkPI.Items) { chkitem.Selected = true; if (ddlPIList.Items.FindByValue(chkitem.Value) != null) { ListItem itemToRemove = ddlPIList.Items.FindByValue(chkitem.Value); ddlPIList.Items.Remove(itemToRemove); } } }
private void GenearteDiv2(string category) { PlaceHolder2.Controls.Clear(); int rowcount = 0; DataTable dt = BLL_TMSA_PI.Get_KPI_List("", null, null, ref rowcount, category).Tables[0]; var InActiveCount = dt.AsEnumerable().Where(r => r.Field <string>("KPI_STATUS") == "InActive").Count(); if (InActiveCount > 0) { dt.Rows.Remove(dt.AsEnumerable().Where(r => r.Field <string>("KPI_STATUS") == "InActive").FirstOrDefault()); } string[] arrKPI = new string[dt.Rows.Count]; string[] name = new string[dt.Rows.Count]; string[] URL = new string[dt.Rows.Count]; for (int k = 0; k < dt.Rows.Count; k++) { arrKPI[k] = dt.Rows[k]["KPI_ID"].ToString(); name[k] = dt.Rows[k]["name"].ToString(); URL[k] = dt.Rows[k]["URL"].ToString(); } hiddenKPIID.Value = String.Join(",", arrKPI); hiddenName.Value = String.Join(",", name); int totalKPI = dt.Rows.Count; int tblRows = 1; int tblCols = 1; if (totalKPI > 1) { if (totalKPI < 3) { tblRows = 1; tblCols = 2; } else if (totalKPI < 5) { tblRows = 2; tblCols = 2; } else { tblCols = 3; tblRows = (int)Math.Ceiling((double)totalKPI / 3); } } Table tbl = new Table(); tbl.Attributes.Add("align", "center"); PlaceHolder2.Controls.Add(tbl); //TableRow tr = new TableRow(); string sURL; int iCount = 0; for (int i = 0; i < tblRows; i++) { TableRow tr = new TableRow(); for (int j = 0; j < tblCols; j++) { TableCell tc = new TableCell(); HtmlGenericControl newControl = new HtmlGenericControl("div"); newControl.ID = "chartContainer2_" + i + j; newControl.Attributes.Add("Style", "Height:300px;width:600px;float:left"); // newControl.Attributes.Add("onclick", "redirect()"); if (iCount < totalKPI) { sURL = URL[iCount].ToString(); if (sURL != null && sURL != "") { newControl.Attributes.Add("onclick", "redirect('" + sURL + "')"); } } newControl.InnerHtml = ""; tc.Controls.Add(newControl); tr.Cells.Add(tc); iCount++; } tbl.Rows.Add(tr); } hiddenCount.Value = tblRows.ToString(); hiddenCount1.Value = tblCols.ToString(); }
/// <summary> /// Description: If by voyage is selected , for all vessels voyage ddl wil populate based on search date /// </summary> protected void ddlVoyage_SelectedIndexChanged(object sender, EventArgs e) { try { DateTime Startdate; Startdate = Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtStartDate.Text)); //Startdate= Convert.ToDateTime(txtStartDate.Text); DateTime EndDate; EndDate = Convert.ToDateTime(UDFLib.ConvertToDate(txtEndDate.Text)); //EndDate = Convert.ToDateTime(txtEndDate.Text); int KPI_ID = 1; DropDownList ddlVoyage = (DropDownList)sender; GridDataItem item = (GridDataItem)ddlVoyage.NamingContainer; Label avg = (Label)item.FindControl("Vessel_Average"); HiddenField hdf = (HiddenField)item.FindControl("hdVesselID"); LinkButton lnkVessel = (LinkButton)item.FindControl("Item_Name"); item["Average"].BackColor = System.Drawing.Color.White; avg.Text = "0"; if (ddlVoyage.SelectedIndex != 0) { string val = ddlVoyage.SelectedValue.Trim().Split(':')[0] + ":" + ddlVoyage.SelectedValue.Trim().Split(':')[1]; DataTable dtq = BLL_TMSA_PI.GetTelDate(val.Trim(), Convert.ToInt32(hdf.Value)).Tables[0]; if (dtq.Rows[0][0].ToString() != "") { Startdate = Convert.ToDateTime(dtq.Rows[0][1].ToString()); // hiddenVesselStartDate.Value = dtq.Rows[0][0].ToString(); // hiddenStartDate.Text = dtq.Rows[0][0].ToString(); hiddenStartDate.Value = Startdate.ToString("dd-MM-yyyy"); } if (dtq.Rows[dtq.Rows.Count - 1][0].ToString() != "") { EndDate = Convert.ToDateTime(dtq.Rows[dtq.Rows.Count - 1][1].ToString()); //hiddenVesselEndDate.Value = dtq.Rows[dtq.Rows.Count - 1][0].ToString(); //hiddenEndDate.Text = dtq.Rows[dtq.Rows.Count - 1][0].ToString(); hiddenEndDate.Value = EndDate.ToString("dd-MM-yyyy"); } } DataTable dt = BLL_TMSA_PI.GetVoyageData(ddlVoyage.SelectedValue.Trim(), Convert.ToInt32(hdf.Value), KPI_ID).Tables[0]; if (dt.Rows.Count > 0) { avg.Text = Math.Round(Convert.ToDouble(dt.Rows[0]["Value"].ToString()), 2).ToString(); if (Convert.ToDouble(avg.Text) == 0) { lnkVessel.Enabled = false; item["Vessel"].BackColor = System.Drawing.Color.White; } else { lnkVessel.Enabled = true; } } else { lnkVessel.Enabled = false; item["Vessel"].BackColor = System.Drawing.Color.White; } Label Vessel_Goal = (Label)item.FindControl("Vessel_Goal"); Label eedi = (Label)item.FindControl("eedi"); if (Convert.ToDouble(avg.Text) > 0 && Convert.ToDouble(eedi.Text) > 0) { if ((Convert.ToDouble(avg.Text) < Convert.ToDouble(Vessel_Goal.Text))) { item["Average"].BackColor = System.Drawing.Color.White; } if (Convert.ToDouble(avg.Text) > Convert.ToDouble(eedi.Text)) { item["Average"].BackColor = System.Drawing.ColorTranslator.FromHtml("#FFC7CE"); } else if ((Convert.ToDouble(avg.Text) > Convert.ToDouble(Vessel_Goal.Text)) && (Convert.ToDouble(avg.Text) < Convert.ToDouble(eedi.Text))) { item["Average"].BackColor = System.Drawing.ColorTranslator.FromHtml("#FABF8F"); } } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
public void item_click(object sender, EventArgs e) { try { GridDataItem item = (GridDataItem)((LinkButton)sender).NamingContainer; DropDownList ddlVoyage = (DropDownList)item.FindControl("ddlVoyage"); foreach (GridDataItem gvr in rgdItems.Items) { gvr["Vessel"].BackColor = System.Drawing.Color.White; } if (CheckBox1.Checked) { if (ddlVoyage.SelectedIndex <= 0) { string stralert = "alert('Please select a voyage ');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Alert", stralert, true); } else { item["Vessel"].BackColor = System.Drawing.Color.Yellow; } } else { item["Vessel"].BackColor = System.Drawing.Color.Yellow; } LinkButton itemName = (LinkButton)item.FindControl("Item_Name"); HiddenField hdf = (HiddenField)item.FindControl("hdVesselID"); Label hiddenStartDate = (Label)item.FindControl("hdnVesselStartDate"); Label hiddenEndDate = (Label)item.FindControl("hdnVesselEndDate"); int index2 = item.ItemIndex; hiddenVesselStartDate.Value = UDFLib.ConvertToDefaultDt(txtStartDate.Text); hiddenVesselEndDate.Value = UDFLib.ConvertToDefaultDt(txtEndDate.Text); getGoal(); string vesselname = itemName.Text; bool voyage = false; string jsMethodName = null; string val = ""; string val1 = ""; string val2 = ""; if (CheckBox1.Checked) { if (ddlVoyage.SelectedIndex > 0) { val = ddlVoyage.SelectedValue.Trim().Split(':')[0] + ":" + ddlVoyage.SelectedValue.Trim().Split(':')[1]; val1 = ddlVoyage.SelectedValue.Trim().Split(':')[0]; val2 = ddlVoyage.SelectedValue.Trim().Split(':')[1]; DataTable dtq = BLL_TMSA_PI.GetTelDate(val.Trim(), Convert.ToInt32(hdf.Value)).Tables[0]; if (dtq.Rows[0][1].ToString() != "") { hiddenStartDate.Text = dtq.Rows[0][1].ToString(); } if (dtq.Rows[dtq.Rows.Count - 1][1].ToString() != "") { hiddenEndDate.Text = dtq.Rows[dtq.Rows.Count - 1][1].ToString(); } voyage = true; jsMethodName = "showChart2('" + val1 + "','" + val2 + "','" + hiddenStartDate.Text + "','" + hiddenEndDate.Text + "','" + vesselname + "','" + hdf.Value + "','" + voyage + "','" + ddlVoyage.SelectedValue.Trim() + "')"; } } else { jsMethodName = "showChart2('" + val1 + "','" + val2 + "','" + Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtStartDate.Text)).ToString("yyyy-MM-dd") + "','" + Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtEndDate.Text)).ToString("yyyy-MM-dd") + "','" + vesselname + "','" + hdf.Value + "','" + voyage + "','" + ddlVoyage.SelectedValue.Trim() + "')"; } ScriptManager.RegisterClientScriptBlock(this, typeof(string), "uniqueKey", jsMethodName, true); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
private void bindgvSearch() { try { if (txtStartDate.Text != "") { Startdate = Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtStartDate.Text)); } if (txtEndDate.Text != "") { EndDate = Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtEndDate.Text)); } DataSet ds = BLL_TMSA_PI.Search_PI_ValuesSOX(Convert.ToInt32(ddlvessel.SelectedValue), Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtStartDate.Text)).ToString("yyyy-MM-dd"), Convert.ToDateTime(UDFLib.ConvertToDefaultDt(txtEndDate.Text)).ToString("yyyy-MM-dd")); if (ds == null || ds.Tables[0].Rows.Count == 0) { btnChart.Visible = false; btnExport.Visible = false; } else { btnChart.Visible = true; } gvSearch.DataSource = ds.Tables[0]; gvSearch.DataBind(); if (ds.Tables[0].Rows.Count != 0) { double AVG = Convert.ToDouble(ds.Tables[0].Compute("AVG(Value)", "").ToString()); hiddenAVG.Value = Math.Round(AVG, 2).ToString(); gvSearch.FooterRow.Cells[1].Text = "Average: " + Math.Round(AVG, 2).ToString(); gvSearch.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Center; gvSearch.FooterRow.Cells[1].ForeColor = System.Drawing.Color.Blue; gvSearch.FooterRow.Cells[1].BorderColor = System.Drawing.ColorTranslator.FromHtml("#EFEFEF"); gvSearch.FooterRow.Cells[0].BorderColor = System.Drawing.ColorTranslator.FromHtml("#EFEFEF"); hiddengdCount.Value = "1"; btnExport.Visible = true; divChart.Visible = true; hiddenStartDate.Value = ""; hiddenEndDate.Value = ""; hiddenStartDate.Value = UDFLib.ConvertToDefaultDt(txtStartDate.Text); hiddenEndDate.Value = UDFLib.ConvertToDefaultDt(txtEndDate.Text); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", "showChart();", true); } else { hiddengdCount.Value = "0"; } for (int i = 0; i < gvSearch.Rows.Count; i++) { Label lbl = (Label)gvSearch.Rows[i].Cells[1].FindControl("lblPORT_NAME"); if (Convert.ToDouble(lbl.Text) > Convert.ToDouble(hiddenAVG.Value)) { gvSearch.Rows[i].BackColor = System.Drawing.ColorTranslator.FromHtml("#FFC7CE"); } else { gvSearch.Rows[i].BackColor = System.Drawing.Color.White; } } } catch (Exception ex) { } }