Beispiel #1
0
    protected void SaveData()
    {
        ltmessage.Text = "";
        int res = -1;

        if (ViewState["Bunker_Id"] != null)
        {
            res = objCP.UPD_BunkerDetail(UDFLib.ConvertIntegerToNull(ViewState["Bunker_Id"]), UDFLib.ConvertIntegerToNull(Session["CPID"]), UDFLib.ConvertIntegerToNull(ddlFuelType.SelectedValue),
                                         ddlFuelType.SelectedItem.Text, ViewState["OType"].ToString(), UDFLib.ConvertToDouble(txtUnit.Text), UDFLib.ConvertToDouble(txtPricePerUnit.Text), GetSessionUserID());
        }
        else
        {
            res = objCP.INS_BunkerDetail(UDFLib.ConvertIntegerToNull(Session["CPID"]), UDFLib.ConvertIntegerToNull(ddlFuelType.SelectedValue), ddlFuelType.SelectedItem.Text, ViewState["OType"].ToString(),
                                         UDFLib.ConvertToDouble(txtUnit.Text), UDFLib.ConvertToDouble(txtPricePerUnit.Text), GetSessionUserID());
        }

        if (res == 0)
        {
            ltmessage.Text = "Record already exist for same type ! Please check.";
        }
        else
        {
            ClearData();
        }
    }
Beispiel #2
0
    public void mapLoad(bool isRoute)
    {
        string map_type         = "";
        int    i                = 0;
        string strInfoHtml      = "";
        int    Vessel_Count     = 0;
        int    Err_Vessel_Count = 0;

        string Err_Vessel_Msg = "<table>";

        lbtn_error.Visible = false;

        int Vessel_ID = int.Parse(ddl_veslist.SelectedValue);
        int Fleet_ID  = int.Parse(ddlTechmanager.SelectedValue);

        try
        {
            DataTable dtData = new DataTable();

            if (isRoute)
            {
                GoogleMapForASPNet1.GoogleMapObject.Points.Clear();
                dtData = BLL_OPS_DPL.Get_TelegramData_Route(Vessel_ID, Fleet_ID, Convert.ToDateTime(txtFromDT.Text), Convert.ToDateTime(txtTODT.Text), strReportType);

                // GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5;
            }
            else
            {
                GoogleMapForASPNet1.GoogleMapObject.AutomaticBoundaryAndZoom = false;
                GoogleMapForASPNet1.GoogleMapObject.Points.Clear();
                dtData = BLL_OPS_DPL.Get_TelegramData(Vessel_ID, Fleet_ID, strReportType);
                GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 3;
            }

            //You must specify Google Map API Key for this component. You can obtain this key from http://code.google.com/apis/maps/signup.html
            //For samples to run properly, set GoogleAPIKey in Web.Config file

            //  GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
            GoogleMapForASPNet1.GoogleMapObject.Width  = "100%"; // You can also specify percentage(e.g. 80%) here
            GoogleMapForASPNet1.GoogleMapObject.Height = "850px";


            map_type = htxt_sat_nor_hybrid.Text.ToString();

            if (map_type == "satmap")
            {
                GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.SATELLITE_MAP;
            }

            if (map_type == "hybridmap")
            {
                GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.HYBRID_MAP;
            }

            if (map_type == "normalmap")
            {
                GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.NORMAL_MAP;
            }

            if (map_type == "")
            {
                GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.NORMAL_MAP;
            }

            GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.HYBRID_MAP;
            GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear();

            if (dtData.Rows.Count > 0)
            {
                StringBuilder sb = new StringBuilder();


                GooglePoint[] gp = new GooglePoint[dtData.Rows.Count];


                int             AreaID     = 0;
                int             VertexID   = 0;
                GooglePolygon[] PiracyArea = new GooglePolygon[2];

                #region -- Draw Piracy Area --
                if (chkPiracyArea.Checked == true)
                {
                    GoogleMapForASPNet1.GoogleMapObject.Polygons.Clear();

                    DataTable dt = BLL_OPS_DPL.Get_PiracyArea();

                    if (dt.Rows.Count > 0)
                    {
                        GooglePolygon PG = new GooglePolygon();
                        PG.FillColor     = "#FF0000";
                        PG.FillOpacity   = 0.3;
                        PG.StrokeColor   = "#FF0000";
                        PG.StrokeOpacity = 1;
                        PG.StrokeWeight  = 1;

                        AreaID = UDFLib.ConvertToInteger(dt.Rows[0]["AreaID"].ToString());

                        GooglePoint GP1 = new GooglePoint();
                        GP1.ID        = "GP" + VertexID.ToString();
                        GP1.Latitude  = UDFLib.ConvertToDouble(dt.Rows[0]["Latitude"].ToString());
                        GP1.Longitude = UDFLib.ConvertToDouble(dt.Rows[0]["Longitude"].ToString());


                        foreach (DataRow dr in dt.Rows)
                        {
                            VertexID++;

                            if (AreaID != UDFLib.ConvertToInteger(dr["AreaID"].ToString()))
                            {
                                PG.ID = "PG" + AreaID.ToString();
                                PG.Points.Add(GP1);
                                GoogleMapForASPNet1.GoogleMapObject.Polygons.Add(PG);
                                PiracyArea[AreaID - 1] = PG;


                                PG               = new GooglePolygon();
                                PG.FillColor     = "#FF0000";
                                PG.FillOpacity   = 0.3;
                                PG.StrokeColor   = "#FF0000";
                                PG.StrokeOpacity = 1;
                                PG.StrokeWeight  = 1;

                                AreaID = UDFLib.ConvertToInteger(dr["AreaID"].ToString());

                                GP1           = new GooglePoint();
                                GP1.ID        = "GP" + VertexID.ToString();
                                GP1.Latitude  = UDFLib.ConvertToDouble(dr["Latitude"].ToString());
                                GP1.Longitude = UDFLib.ConvertToDouble(dr["Longitude"].ToString());
                            }

                            GooglePoint GP = new GooglePoint();
                            GP.ID        = "GP" + VertexID.ToString();
                            GP.Latitude  = UDFLib.ConvertToDouble(dr["Latitude"].ToString());
                            GP.Longitude = UDFLib.ConvertToDouble(dr["Longitude"].ToString());

                            PG.Points.Add(GP);
                        }

                        PG.ID = "PG" + AreaID.ToString();
                        PG.Points.Add(GP1);
                        GoogleMapForASPNet1.GoogleMapObject.Polygons.Add(PG);
                        PiracyArea[AreaID - 1] = PG;
                    }
                }
                else
                {
                    GoogleMapForASPNet1.GoogleMapObject.Polygons.Clear();
                }
                #endregion

                if (!isRoute)
                {
                    #region ---------Draw all vessels icons and baloons--------

                    foreach (DataRow dr in dtData.Rows)
                    {
                        Vessel_Count++;

                        gp[i] = new GooglePoint();

                        //string sangle = dr[5].ToString();
                        string sangle = dr["Vessel_Course"].ToString();


                        CreateImage(dr["Vessel_Short_Name"].ToString());



                        string  latitude = ""; string longitude = "";
                        string  longi_pos1; string longi_pos2; string lati_pos1; string lati_pos2;
                        decimal lat_degree = 0; decimal lat_min = 0; decimal lat_sec = 0; string slat_dir = "";
                        decimal long_degree = 0; decimal long_min = 0; decimal long_sec = 0; string slong_dir = "";


                        try
                        {
                            lat_degree = UDFLib.ConvertToDecimal(dr["Latitude_Degrees"].ToString());
                            lat_min    = UDFLib.ConvertToDecimal(dr["Latitude_Minutes"].ToString());
                            lat_sec    = UDFLib.ConvertToDecimal(dr["Latitude_Seconds"].ToString());
                            slat_dir   = dr["LATITUDE_N_S"].ToString();
                            if (slat_dir != "N" && slat_dir != "S")
                            {
                                slat_dir = "N";
                            }

                            latitude = Conv_Deg2Decimal_new(Convert.ToDouble(lat_degree), Convert.ToDouble(lat_min), Convert.ToDouble(lat_sec), slat_dir.ToString());

                            long_degree = UDFLib.ConvertToDecimal(dr["Longitude_Degrees"].ToString());
                            long_min    = UDFLib.ConvertToDecimal(dr["Longitude_Minutes"].ToString());
                            long_sec    = UDFLib.ConvertToDecimal(dr["Longitude_Seconds"].ToString());
                            slong_dir   = dr["Longitude_E_W"].ToString();
                            if (slong_dir != "E" && slong_dir != "W")
                            {
                                slat_dir = "E";
                            }

                            longitude = Conv_Deg2Decimal_new(Convert.ToDouble(long_degree), Convert.ToDouble(long_min), Convert.ToDouble(long_sec), slong_dir.ToString());

                            if (Convert.ToString(dr["Telegram_Type"]).ToUpper() == "N")
                            {
                                gp[i].IconImage = dr["Vessel_Short_Name"].ToString() + ".png";
                            }

                            else if (Convert.ToString(dr["Telegram_Type"]).ToUpper() == "P")
                            {
                                gp[i].IconImage = dr["Vessel_Short_Name"].ToString() + "-P" + ".png";
                            }


                            gp[i].Latitude  = double.Parse(latitude);
                            gp[i].Longitude = double.Parse(longitude);


                            // - check if in piracy area
                            bool iPointInPolygon = PointInPolygon(gp[i], PiracyArea);
                            if (iPointInPolygon == true)
                            {
                                GooglePoint shipInPiracy = new GooglePoint();
                                shipInPiracy.Latitude  = double.Parse(latitude);
                                shipInPiracy.Longitude = double.Parse(longitude);
                                shipInPiracy.IconImage = "../Images/star.gif";
                                //shipInPiracy.IconImageHeight = 20;
                                //shipInPiracy.IconImageWidth = 20;
                                GoogleMapForASPNet1.GoogleMapObject.Points.Add(shipInPiracy);
                            }



                            string simagename = "";
                            if (sangle == "" || sangle == null)
                            {
                                simagename = "boat_.png";
                            }

                            else
                            {
                                Double angle = Convert.ToDouble(sangle);

                                if ((angle >= 0) && (angle <= 90))
                                {
                                    simagename = "UpSide45_f_.png";
                                }

                                if ((angle >= 90) && (angle <= 180))
                                {
                                    simagename = "UpSide_135_.png";
                                }

                                if ((angle >= 180) && (angle <= 270))
                                {
                                    simagename = "Down_225_.png";
                                }

                                if ((angle >= 270) && (angle <= 360))
                                {
                                    simagename = "Down_315_.png";
                                }
                            }



                            strInfoHtml  = "<table border=0 cellspacing=0 cellpadding=0 style='font-size:10px;font-family:Verdana'>";
                            strInfoHtml += "<tr><td colspan=2 style='font-weight:bold;'>" + dr["Vessel_Name"].ToString() + "&nbsp;&nbsp;<img src='images/" + simagename + "'>" + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Report Date:</td><td style='color:blue;font-weight:bold'>" + dr["infodate"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Location:</td><td>" + dr["Location_Name"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Latitude:</td><td>" + dr["Latitude_Degrees"].ToString() + " " + dr["Latitude_Minutes"].ToString() + " " + dr["Latitude_Seconds"].ToString() + " " + dr["LATITUDE_N_S"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Longitude:</td><td>" + dr["Longitude_Degrees"].ToString() + " " + dr["Longitude_Minutes"].ToString() + " " + dr["Longitude_Seconds"].ToString() + " " + dr["Longitude_E_W"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Course:</td><td>" + sangle.ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Wind Direction/ Force:</td><td>" + dr["Wind_Direction"].ToString() + "/" + dr["Wind_Force"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Average speed:</td><td>" + dr["AVERAGE_SPEED"].ToString() + " knts</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Next port/<br>ETA:</td><td>" + dr["PORT_NAME"].ToString() + "<br>" + dr["etanextport"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'></td><td></td></tr>";

                            string CrewLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Crew/CrewList_PhotoView.aspx?vcode=" + dr["Vessel_Short_Name"].ToString() + "' target='_blank'>Crew List</a>";
                            string NoonLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Operations/NoonReport.aspx?LastNoon=" + dr["Vessel_Short_Name"].ToString() + "&ID=" + dr["PKID"].ToString() + "' target='_blank'>Last Noon</a>";



                            strInfoHtml += "<td>" + CrewLink + "</td><td>" + NoonLink + "</td>";
                            strInfoHtml += "</tr>";
                            strInfoHtml += "</table>";

                            gp[i].InfoHTML = strInfoHtml.ToString();

                            GoogleMapForASPNet1.GoogleMapObject.Points.Add(gp[i]);


                            i++;
                        }
                        catch
                        {
                            Err_Vessel_Count++;

                            lbtn_error.Visible = true;

                            lati_pos1  = "1";
                            lati_pos2  = "2";
                            longi_pos1 = "1";
                            longi_pos2 = "2";

                            gp[i].Latitude  = double.Parse(lati_pos1 + lati_pos2);
                            gp[i].Longitude = double.Parse(longi_pos1 + longi_pos2);

                            Err_Vessel_Msg += "<tr><td>" + dr[1].ToString() + "</td><td>" + dr[2].ToString() + "</td><td>Latitude:" + UDFLib.ConvertToInteger(latitude.ToString()) + "</td><td>Longitude:" + longitude.ToString() + "</td></tr>";


                            continue;
                        }
                    } //End For



                    if (Err_Vessel_Msg == "<table>")
                    {
                        Err_Vessel_Msg = "";
                    }
                    else
                    {
                        Err_Vessel_Msg += "</table>";
                    }

                    if (Err_Vessel_Count > 0)
                    {
                        lblVessels.ForeColor = System.Drawing.Color.Red;
                        lblVessels.Text      = "Total Ships: " + Vessel_Count.ToString() + " (" + Err_Vessel_Count.ToString() + " Ship(s) found with Error!!)";

                        lblLoadingIssues.Text = Err_Vessel_Msg;
                    }
                    else
                    {
                        lblVessels.ForeColor = System.Drawing.Color.Blue;
                        lblVessels.Text      = "Total Ships: " + Vessel_Count.ToString();
                    }
                    #endregion
                }
                else
                {
                    #region ---------------- Route----------


                    double lat_pos_g = 0;
                    double log_pos_g = 0;

                    GooglePolyline objPolyLine = new GooglePolyline();

                    if (strReportType == "N")
                    {
                        objPolyLine.ColorCode = "#7FFF00";
                    }
                    else
                    {
                        objPolyLine.ColorCode = "#FF00FF";
                    }

                    objPolyLine.Width    = 1;
                    objPolyLine.Geodesic = true;

                    foreach (DataRow dr in dtData.Rows)
                    {
                        Vessel_Count++;

                        gp[i] = new GooglePoint();

                        //string sangle = dr[5].ToString();
                        string sangle = dr["Vessel_Course"].ToString();

                        CreateImage(dr["Vessel_Short_Name"].ToString());


                        string  latitude = ""; string longitude = "";
                        string  longi_pos1; string longi_pos2; string lati_pos1; string lati_pos2;
                        decimal lat_degree = 0; decimal lat_min = 0; decimal lat_sec = 0; string slat_dir = "";
                        decimal long_degree = 0; decimal long_min = 0; decimal long_sec = 0; string slong_dir = "";

                        try
                        {
                            lat_degree = UDFLib.ConvertToDecimal(dr["Latitude_Degrees"].ToString());
                            lat_min    = UDFLib.ConvertToDecimal(dr["Latitude_Minutes"].ToString());
                            lat_sec    = UDFLib.ConvertToDecimal(dr["Latitude_Seconds"].ToString());
                            slat_dir   = dr["LATITUDE_N_S"].ToString();
                            if (slat_dir != "N" && slat_dir != "S")
                            {
                                slat_dir = "N";
                            }

                            latitude = Conv_Deg2Decimal_new(Convert.ToDouble(lat_degree), Convert.ToDouble(lat_min), Convert.ToDouble(lat_sec), slat_dir.ToString());

                            long_degree = UDFLib.ConvertToDecimal(dr["Longitude_Degrees"].ToString());
                            long_min    = UDFLib.ConvertToDecimal(dr["Longitude_Minutes"].ToString());
                            long_sec    = UDFLib.ConvertToDecimal(dr["Longitude_Seconds"].ToString());
                            slong_dir   = dr["Longitude_E_W"].ToString();
                            if (slong_dir != "E" && slong_dir != "W")
                            {
                                slat_dir = "E";
                            }

                            longitude = Conv_Deg2Decimal_new(Convert.ToDouble(long_degree), Convert.ToDouble(long_min), Convert.ToDouble(long_sec), slong_dir.ToString());

                            //else if (Convert.ToString(dr["Telegram_Type"]).ToUpper() == "P")
                            //    gp[i].IconImage = dr["Vessel_Short_Name"].ToString() + "-P" + ".png";

                            gp[i].Latitude  = double.Parse(latitude);
                            gp[i].Longitude = double.Parse(longitude);

                            string simagename = "";
                            if (sangle == "" || sangle == null)
                            {
                                simagename = "boat_.png";
                            }

                            else
                            {
                                Double angle = Convert.ToDouble(sangle);

                                if ((angle >= 0) && (angle <= 90))
                                {
                                    simagename = "UpSide45_f_.png";
                                }

                                if ((angle >= 90) && (angle <= 180))
                                {
                                    simagename = "UpSide_135_.png";
                                }

                                if ((angle >= 180) && (angle <= 270))
                                {
                                    simagename = "Down_225_.png";
                                }

                                if ((angle >= 270) && (angle <= 360))
                                {
                                    simagename = "Down_315_.png";
                                }
                            }

                            strInfoHtml  = "<table border=0 cellspacing=0 cellpadding=0 style='font-size:10px;font-family:Verdana'>";
                            strInfoHtml += "<tr><td colspan=2 style='font-weight:bold;'>" + dr["Vessel_Name"].ToString() + "&nbsp;&nbsp;<img src='images/" + simagename + "'>" + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Report Date:</td><td style='color:blue;font-weight:bold'>" + dr["infodate"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Location:</td><td>" + dr["Location_Name"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Latitude:</td><td>" + dr["Latitude_Degrees"].ToString() + " " + dr["Latitude_Minutes"].ToString() + " " + dr["Latitude_Seconds"].ToString() + " " + dr["LATITUDE_N_S"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Longitude:</td><td>" + dr["Longitude_Degrees"].ToString() + " " + dr["Longitude_Minutes"].ToString() + " " + dr["Longitude_Seconds"].ToString() + " " + dr["Longitude_E_W"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Course:</td><td>" + sangle.ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Wind Direction/ Force:</td><td>" + dr["Wind_Direction"].ToString() + "/" + dr["Wind_Force"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Average speed:</td><td>" + dr["AVERAGE_SPEED"].ToString() + " knts</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'>Next port/<br>ETA:</td><td>" + dr["PORT_NAME"].ToString() + "<br>" + dr["etanextport"].ToString() + "</td></tr>";
                            strInfoHtml += "<tr><td style='width:80px'></td><td></td></tr>";

                            string ReportName = rbtnNoonReport.Checked == true ? "Noon Report" : (rbtnPurpleReport.Checked == true ? "PurpleFinder" : "Noon Report");
                            string CrewLink   = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Crew/CrewListHistory.aspx?VesselID=" + dr["Vessel_ID"].ToString() + "&AsofDate=" + dr["Telegram_Date"].ToString() + "' target='_blank'>Crew List</a>";
                            string NoonLink   = "";

                            if (strReportType == "N")
                            {
                                NoonLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Operations/NoonReport.aspx?id=" + dr["PKID"].ToString() + "' target='_blank'>" + ReportName + "</a>";
                            }
                            else
                            {
                                NoonLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Operations/PurpleReport.aspx?id=" + dr["PKID"].ToString() + "' target='_blank'>" + ReportName + "</a>";
                            }

                            strInfoHtml += "<td>" + CrewLink + "</td><td>" + NoonLink + "</td>";
                            strInfoHtml += "</tr>";
                            strInfoHtml += "</table>";

                            gp[i].InfoHTML = strInfoHtml.ToString();

                            objPolyLine.Points.Add(gp[i]);

                            if (i == 0)
                            {
                                //gp[i].IconImage = "red-button.png";

                                lat_pos_g = double.Parse(latitude);
                                log_pos_g = double.Parse(longitude);
                                GoogleMapForASPNet1.GoogleMapObject.Points.Add(gp[i]);
                            }
                            else
                            {
                                gp[i].IconImage = "number_" + Convert.ToDateTime(dr["Telegram_Date"]).Day.ToString() + ".png";

                                GoogleMapForASPNet1.GoogleMapObject.Points.Add(gp[i]);
                            }

                            i++;
                        }
                        catch
                        {
                            Err_Vessel_Count++;

                            lbtn_error.Visible = true;

                            lati_pos1  = "1";
                            lati_pos2  = "2";
                            longi_pos1 = "1";
                            longi_pos2 = "2";

                            gp[i].Latitude  = double.Parse(lati_pos1 + lati_pos2);
                            gp[i].Longitude = double.Parse(longi_pos1 + longi_pos2);

                            Err_Vessel_Msg += "<tr><td>" + dr[1].ToString() + "</td><td>" + dr[2].ToString() + "</td><td>Latitude:" + UDFLib.ConvertToInteger(latitude.ToString()) + "</td><td>Longitude:" + longitude.ToString() + "</td></tr>";


                            continue;
                        }
                    }


                    GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(objPolyLine);
                    GoogleMapForASPNet1.GoogleMapObject.CenterPoint.Latitude     = lat_pos_g;
                    GoogleMapForASPNet1.GoogleMapObject.CenterPoint.Longitude    = log_pos_g;
                    GoogleMapForASPNet1.GoogleMapObject.AutomaticBoundaryAndZoom = true;

                    #endregion
                }
            }
            else
            {
                lblVessels.Text = "Total Ships: " + Err_Vessel_Count.ToString();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
Beispiel #3
0
    protected void SaveBunkerData()
    {
        ltmessage.Text = "";
        int res = -1;

        if (ViewState["Bunker_Id"] != null)
        {
            res = oCP.UPD_BunkerDetail(UDFLib.ConvertIntegerToNull(ViewState["Bunker_Id"]), UDFLib.ConvertIntegerToNull(Session["CPID"]), UDFLib.ConvertIntegerToNull(ddlFuelType.SelectedValue),
                                       ddlFuelType.SelectedItem.Text, ViewState["OType"].ToString(), UDFLib.ConvertToDouble(txtUnit.Text), UDFLib.ConvertToDouble(txtPricePerUnit.Text), GetSessionUserID());
        }
        else
        {
            res = oCP.INS_BunkerDetail(UDFLib.ConvertIntegerToNull(Session["CPID"]),
                                       UDFLib.ConvertIntegerToNull(ddlFuelType.SelectedValue), ddlFuelType.SelectedItem.Text, ViewState["OType"].ToString(), UDFLib.ConvertToDouble(txtUnit.Text), UDFLib.ConvertToDouble(txtPricePerUnit.Text), GetSessionUserID());
        }
        ViewState["Bunker_Id"] = null;
        if (res == 0)
        {
            ltmessage.Text = "Record already exist for same type ! Please check.";
            string show = String.Format("showDivAddBunker('dvAddBunker')");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "showmodal", show, true);
        }
        else
        {
            ClearBunker();
            BindBunkerDetail();
            ReBindBunkerDetail();
            string hidemodal = String.Format("hideModal('dvAddBunker')");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true);
        }
    }
Beispiel #4
0
    protected void gvInspecrionSchedule_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "onDelete")
            {
                objInsp.Del_ScheduledInspection(UDFLib.ConvertIntegerToNull(e.CommandArgument.ToString()), UDFLib.ConvertIntegerToNull(Session["USERID"]));
                Load_Current_Schedules();
            }
            if (e.CommandName == "ReOpen")
            {
                ViewState["SchDetailId"] = UDFLib.ConvertToInteger(e.CommandArgument.ToString().Split(';')[0]);;
            }
            if (e.CommandName.ToUpper() == "EDIT_SCHEDULE")
            {
            }
            if (e.CommandName.ToUpper() == "INSPUPD")
            {
                if (ViewState["edit"].ToString() == "0")
                {
                    btnUpdateInspection.Enabled = false;
                }

                ViewState["ShowImages"]  = 0;
                ViewState["SchDetailId"] = 1;
                string js;

                DataTable dtSup = objInsp.Get_Supritendent_Users(null, UDFLib.ConvertToInteger(e.CommandArgument.ToString().Split(';')[8]));

                if (dtSup != null)
                {
                    if (dtSup.Rows.Count > 0)
                    {
                        DDLInspectorA.DataSource     = dtSup;
                        DDLInspectorA.DataTextField  = "Name";
                        DDLInspectorA.DataValueField = "UserID";
                        DDLInspectorA.DataBind();
                        DDLInspectorA.Items.Insert(0, new ListItem("--SELECT--", null));
                        txtInsectionDate.Text = DateTime.Now.ToString("dd/MMM/yy");


                        ViewState["ScheduleID"]  = UDFLib.ConvertToInteger(e.CommandArgument.ToString().Split(';')[0]);
                        ViewState["SchDetailId"] = UDFLib.ConvertToInteger(e.CommandArgument.ToString().Split(';')[2]);
                        try
                        {
                            try
                            {
                                DDLInspectorA.SelectedValue = e.CommandArgument.ToString().Split(';')[1];
                            }
                            catch (Exception)
                            {
                                DDLInspectorA.SelectedValue = e.CommandArgument.ToString().Split(';')[4];
                            }
                        }
                        catch (Exception)
                        {
                            DDLInspectorA.SelectedIndex = 0;
                        }

                        try
                        {
                            txtInsectionDate.Text = Convert.ToDateTime(e.CommandArgument.ToString().Split(';')[5]).ToString("dd/MMM/yy");
                        }
                        catch (Exception)
                        {
                            txtInsectionDate.Text = Convert.ToDateTime(e.CommandArgument.ToString().Split(';')[6]).ToString("dd/MMM/yy");
                        }

                        try
                        {
                            hdfNewinspectionPortid.Value = "";
                            DataSet   dtAssignPortList = objInsp.INSP_Get_InspectionPort(UDFLib.ConvertToInteger(e.CommandArgument.ToString().Split(';')[2]));
                            DataTable dtPort           = objInfra.Get_PortList();

                            DDLPort.DataSource     = dtPort;
                            DDLPort.DataValueField = "PORT_ID";
                            DDLPort.DataTextField  = "PORT_NAME";
                            DDLPort.DataBind();
                            DDLPort.Items.Insert(0, new ListItem("-SELECT-", null));

                            if (dtAssignPortList.Tables[0].Rows.Count > 0)
                            {
                                try
                                {
                                    DDLPort.SelectedValue = dtAssignPortList.Tables[0].Rows[0]["PortID"].ToString();
                                }
                                catch { }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }


                        txtDurJobsU.Text = e.CommandArgument.ToString().Split(';')[7].ToString();
                        txtDuration.Text = e.CommandArgument.ToString().Split(';')[7].ToString();
                        DateTime dt = Convert.ToDateTime(txtInsectionDate.Text);
                        dt = dt.AddDays(UDFLib.ConvertToDouble(txtDuration.Text) - 1);
                        txtCompletionDate.Text = dt.ToString("dd/MMM/yy");
                        txtOnboard.Text        = "";
                        txtOnShore.Text        = "";
                        txtDuration.Text       = "";
                        rdbCompleted.Checked   = false;
                        rdbPlanned.Checked     = true;

                        js = " $('#divAddSystem').prop('title', 'Update Inspection');showModal('dvUpdateInspe',false);";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "showModalJS", js, true);

                        js = " $('#dvUpdateInspe').prop('title', 'Update Inspection');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "", js, true);

                        js = "handleStatus();";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "handleModal", js, true);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
        }
    }