Ejemplo n.º 1
0
    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);
            }
        }
    }
Ejemplo n.º 2
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.GetVoyageDataNOx(listVoyage.Items[x].Value.Trim(), Convert.ToInt32(ddlvessel.SelectedValue)).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";
            }

            for (int i = 0; i < gvVoyage.Rows.Count; i++)
            {
                Label lbl = (Label)gvVoyage.Rows[i].Cells[1].FindControl("lblTo4");
                if (Convert.ToDouble(lbl.Text) > Convert.ToDouble(hiddenAVG.Value))
                {
                    gvVoyage.Rows[i].BackColor = System.Drawing.ColorTranslator.FromHtml("#FFC7CE");
                }
                else
                {
                    gvVoyage.Rows[i].BackColor = System.Drawing.Color.White;
                }
            }
        }
        GetGoal();
    }