Ejemplo n.º 1
0
    protected void btnVoyageIdSave_Click(object sender, EventArgs e)
    {
        try
        {
            int CreatedBy, ModifiedBy;
            if (ViewState["Mode"].ToString() == "Add")
            {
                if (txtValue.Text.ToString().Trim() != "")
                {
                    CreatedBy = UDFLib.ConvertToInteger(Session["userid"].ToString());
                    int reslt = BLL_OPS_VoyageReports.Insert_VoyageNo(txtValue.Text.Trim(), CreatedBy);
                    if (reslt == 1)
                    {
                        string js2 = "alert('Voyage Number saved successfully..!');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true);
                        ViewState["ID"]   = "";
                        ViewState["Mode"] = "";
                    }
                    else if (reslt == 0)
                    {
                        string js2 = "alert('Voyage Number is already exist..!');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true);
                    }
                    else
                    {
                        string js2 = "alert('Voyage Number saving unsuccessful..!');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true);
                    }
                }
                else
                {
                    string js2 = "alert('Voyage Number should not be blank...!');";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true);
                }
            }
            else if (ViewState["Mode"].ToString() == "EDIT")
            {
                if (txtValue.Text.ToString().Trim() != "")
                {
                    int ID = Convert.ToInt32(ViewState["ID"].ToString());

                    ModifiedBy = UDFLib.ConvertToInteger(Session["userid"].ToString());
                    int reslt = BLL_OPS_VoyageReports.Update_VoyageNo(txtValue.Text.Trim(), ModifiedBy, ID);
                    if (reslt == 1)
                    {
                        string js2 = "alert('Voyage Number Updated Successfully');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true);
                        ViewState["ID"]   = "";
                        ViewState["Mode"] = "";
                    }
                    else if (reslt == 0)
                    {
                        string js2 = "alert('Voyage Number is already exist..!');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true);
                    }
                    else
                    {
                        string js2 = "alert('Voyage Number Updated Unsuccessful');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true);
                    }
                }
                else
                {
                    string js2 = "alert('Voyage Number should not be blank...!');";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert9", js2, true);
                }
            }



            txtValue.Text  = "";
            txtfilter.Text = "";

            BindVoyageNumber();
            updCat.Update();
        }
        catch (Exception)
        {
            throw;
        }
    }