Exemple #1
0
    /// <summary>
    /// Save / Update Pre Joining Experience details
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSavePreJoiningExp_Click(object sender, EventArgs e)
    {
        try
        {
            int BHP = 0, GRT = 0;

            DateTime?ToDate, FromDate;
            if (txtPJDateTo.Text != "" && txtPJDateFrom.Text != "")
            {
                try
                {
                    ToDate   = DateTime.Parse(UDFLib.ConvertToDefaultDt(txtPJDateTo.Text));
                    FromDate = DateTime.Parse(UDFLib.ConvertToDefaultDt(txtPJDateFrom.Text));
                }
                catch
                {
                    lblMsgPreJoining.Text = "Enter valid Period of Service From or Period of Service To Date" + TodayDateFormat;
                    CurrentOperatorCheck();
                    string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                    return;
                }
            }
            else
            {
                lblMsgPreJoining.Text = "Enter Period of Service From and Period of Service To Date";
                CurrentOperatorCheck();
                string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                return;
            }
            int CrewID = GetCrewID();
            if (CrewID > 0)
            {
                foreach (GridViewRow row in GridView_PreJoiningExp.Rows)
                {
                    Label PreJoiningExpId = row.FindControl("lblPreJoiningExpId") as Label;
                    if (!PreJoiningExpId.Text.Equals(ViewState["PreJoiningId"]))
                    {
                        Label    a          = row.FindControl("lblDate_To") as Label;
                        DateTime?LastToDate = UDFLib.ConvertToDate(a.Text);
                        if (FromDate < LastToDate)
                        {
                            Label    b            = row.FindControl("lblDate_From") as Label;
                            DateTime?LastFromDate = UDFLib.ConvertToDate(b.Text);
                            if (FromDate >= LastFromDate)
                            {
                                lblMsgPreJoining.Text = "Two Different working experience cannot be on same date";
                                string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                                return;
                            }
                            if (ToDate >= LastFromDate)
                            {
                                lblMsgPreJoining.Text = "Two Different working experience cannot be on same date";
                                string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                                return;
                            }
                        }
                    }
                }
                if (txtCompanyName.Text.Trim() == "")
                {
                    lblMsgPreJoining.Text = "Company Name can not be blank";
                    CurrentOperatorCheck();
                    string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                }
                else if (txtPJVessel.Text.Trim() == "")
                {
                    lblMsgPreJoining.Text = "Vessel Name can not be blank";
                    CurrentOperatorCheck();
                    string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                }
                else if (txtPJFlag.Text.Trim() == "")
                {
                    lblMsgPreJoining.Text = "Flag can not be blank";
                    CurrentOperatorCheck();
                    string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                }
                else if (ToDate < FromDate)
                {
                    lblMsgPreJoining.Text = "To Date can not be less than From date";
                    CurrentOperatorCheck();
                    string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                }
                else
                {
                    if (txtGRT.Text.Trim() != "")
                    {
                        try
                        {
                            GRT = int.Parse(txtGRT.Text);
                        }
                        catch
                        {
                            lblMsgPreJoining.Text = "GRT value should be numeric";
                            CurrentOperatorCheck();
                            string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                            return;
                        }
                    }

                    if (txtMEBHP.Text.Trim() != "")
                    {
                        try
                        {
                            BHP = int.Parse(txtMEBHP.Text);
                        }
                        catch
                        {
                            lblMsgPreJoining.Text = "BHP value should be numeric";
                            CurrentOperatorCheck();
                            string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                            return;
                        }
                    }
                    int    result;
                    string VesselType = ddlPJVesselType.SelectedValue == "0" ? "" : ddlPJVesselType.SelectedItem.ToString();
                    if (ViewState["PreJoiningId"] == null)
                    {
                        result = objBLLCrew.INS_CrewPreJoiningExp(CrewID, txtPJVessel.Text, txtPJFlag.Text, VesselType, txtPJDWT.Text, GRT, txtCompanyName.Text, UDFLib.ConvertToInteger(ddPJRank.SelectedValue), UDFLib.ConvertToDefaultDt(txtPJDateFrom.Text), UDFLib.ConvertToDefaultDt(txtPJDateTo.Text), 0, 0, int.Parse(Session["USERID"].ToString()), txtMEModel.Text, BHP, UDFLib.ConvertIntegerToNull(UDFLib.ConvertStringToNull(hdnVesselManager.Value)));
                        if (result == 1)
                        {
                            UDFLib.GetException("SuccessMessage/SaveMessage");
                        }
                    }
                    else
                    {
                        objBLLCrew.UPDATE_CrewPreJoiningExp(int.Parse(ViewState["PreJoiningId"].ToString()), txtPJVessel.Text, txtPJFlag.Text, VesselType, txtPJDWT.Text, txtGRT.Text.Trim(), txtCompanyName.Text, UDFLib.ConvertToInteger(ddPJRank.SelectedValue), UDFLib.ConvertToDefaultDt(txtPJDateFrom.Text), UDFLib.ConvertToDefaultDt(txtPJDateTo.Text), int.Parse(Session["USERID"].ToString()), txtMEModel.Text, BHP, UDFLib.ConvertIntegerToNull(UDFLib.ConvertStringToNull(hdnVesselManager.Value)));
                        result = 1;
                        UDFLib.GetException("SuccessMessage/UpdateMessage");
                    }

                    if (result == 1)
                    {
                        ClearPreJoiningDetails();
                        GridView_PreJoiningExp.DataBind();
                        string hidemodal = String.Format("hideModal('dvAddPreJoiningExp')");
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true);
                    }
                    else
                    {
                        UDFLib.GetException("FailureMessage/DataSaveMessage");
                        lblMsgPreJoining.Text = "Unable to add Pre-Joining details !!";
                        string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
                    }
                }
            }
            else
            {
                lblMsgPreJoining.Text = "First save crew details !!";
                string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
            }
        }
        catch (Exception ex)
        {
            lblMsgPreJoining.Text = "Unable to add Pre-Joining details !! " + ex.Message;
            string AddPreJoining = String.Format("showModal('dvAddPreJoiningExp',false);");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddPreJoining", AddPreJoining, true);
        }
    }
Exemple #2
0
 protected void ImgReloadPreJoining_Click(object sender, ImageClickEventArgs e)
 {
     GridView_PreJoiningExp.DataBind();
     Load_CrewPreviousContactDetails(GetCrewID());
 }