Example #1
0
    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)
        { }
    }
Example #2
0
    protected 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_ValuesNOX(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)
        {
        }
    }