Esempio n. 1
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);
        }
    }