Example #1
0
    protected void btnsave_Click(object sender, EventArgs e)
    {
        //if (HiddenFlag.Value == "Add")
        //{

        //    int responseid = objBLL.InsertCompany(int.Parse(txtCompCode.Text.Trim()), int.Parse(ddlCompanyType.SelectedValue), txtCompName.Text.Trim(), txtRegNo.Text.Trim()
        //      , UDFLib.ConvertDateToNull(txtDtIncorp.Text.Trim()), UDFLib.ConvertToInteger(ddlCountryIncorp.SelectedValue), UDFLib.ConvertIntegerToNull(ddlCurrency.SelectedValue), txtAddrerss.Text.Trim()
        //      , UDFLib.ConvertIntegerToNull(ddlAddressCountry.SelectedValue), txtEmail.Text.Trim(), txtPhone.Text.Trim()
        //      , UDFLib.ConvertToInteger(Session["UserID"]),txtShortName.Text, txtEmail2.Text, txtPhone2.Text, txtFax1.Text, txtFax2.Text);


        //    if (responseid != -1)
        //    {
        //        objBLL.InsertCompanyReletionship(UDFLib.ConvertToInteger(ddlParentCompany.SelectedValue), responseid, UDFLib.ConvertToInteger(ddlRelation.SelectedValue), UDFLib.ConvertToInteger(Session["UserID"]));
        //    }
        //    else
        //    {
        //        string js1 = "alert('Company name already exists');";
        //        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser", js1, true);
        //    }

        //}
        //else
        //{
        //    int responseid = objBLL.EditCompany(Convert.ToInt32(txtCompanyID.Text), Convert.ToInt32(txtCompCode.Text), Convert.ToInt32(ddlCompanyType.SelectedValue)
        //        , txtCompName.Text, txtShortName.Text, txtRegNo.Text, txtDtIncorp.Text, UDFLib.ConvertIntegerToNull(ddlCountryIncorp.SelectedValue), UDFLib.ConvertIntegerToNull(ddlCurrency.SelectedValue)
        //        , txtAddrerss.Text, UDFLib.ConvertIntegerToNull(ddlAddressCountry.SelectedValue), txtEmail.Text, txtPhone.Text, txtEmail2.Text, txtPhone2.Text, txtFax1.Text, txtFax2.Text, UDFLib.ConvertToInteger(Session["UserID"]));

        //}


        if (HiddenFlag.Value == "Add")
        {
            if (txtCompName.Text != "")
            {
                txtShortName.Text = txtCompName.Text.Substring(0, 3);
            }

            DataTable dt = objBLL.CheckCompanyExist(txtShortName.Text.Trim());

            if (dt.Rows.Count > 0)
            {
                string js1 = "alert('Company name already exists');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser", js1, true);
                //string AddCompmodal = String.Format("showModal('CompanyExist',false);");
                //   ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AddCompmodal", AddCompmodal, true);
            }
            else
            {
                int responseid = objBLL.InsertCompany(int.Parse(txtCompCode.Text.Trim()), int.Parse(ddlCompanyType.SelectedValue), txtCompName.Text.Trim(), txtRegNo.Text.Trim()
                                                      , UDFLib.ConvertDateToNull(txtDtIncorp.Text.Trim()), UDFLib.ConvertToInteger(ddlCountryIncorp.SelectedValue), UDFLib.ConvertIntegerToNull(ddlCurrency.SelectedValue), txtAddrerss.Text.Trim()
                                                      , UDFLib.ConvertIntegerToNull(ddlAddressCountry.SelectedValue), txtEmail.Text.Trim(), txtPhone.Text.Trim()
                                                      , UDFLib.ConvertToInteger(Session["UserID"]), txtShortName.Text, txtEmail2.Text, txtPhone2.Text, txtFax1.Text, txtFax2.Text);


                string emailid    = "";
                string ContactDet = "";
                if (txtEmail2.Text != "")
                {
                    emailid = txtEmail.Text.Trim() + "," + txtEmail2.Text;
                }
                else
                {
                    emailid = txtEmail.Text.Trim();
                }
                if (txtPhone2.Text != "")
                {
                    ContactDet = txtPhone.Text.Trim() + "," + txtPhone2.Text;
                }
                else
                {
                    ContactDet = txtPhone.Text.Trim();
                }

                if (responseid != -1)
                {
                    //objBLL.InsertCompanyReletionship(UDFLib.ConvertToInteger(ddlParentCompany.SelectedValue), responseid, UDFLib.ConvertToInteger(ddlRelation.SelectedValue), UDFLib.ConvertToInteger(Session["UserID"]));
                    objBLL.InsertCompanyReletionship(95, responseid, UDFLib.ConvertToInteger(ddlRelation.SelectedValue), UDFLib.ConvertToInteger(Session["UserID"]));

                    string url = HttpContext.Current.Request.Url.AbsoluteUri;

                    string[] segment = url.Split('/');
                    string   newstr  = "";



                    for (int i = 0; i < segment.Length; i++)
                    {
                        if (segment[i] == "JIBE")
                        {
                            newstr += segment[i].ToString() + "/";
                            break;
                        }
                        //if(i==0)
                        newstr += segment[i].ToString() + "/";
                        //else
                        //    newstr += segment[i].ToString() + "/";
                    }

                    newstr += "Account/Company.aspx?CompanyType=VesselManager&CompanyID=" + responseid.ToString() + "";// + Session["USERCOMPANYID"] + "";

                    //btnsave.Enabled = false;

                    string js1 = "alert('Saved Successfully');";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser", js1, true);
                    // objBLL.SendSurveyVesselORegistration(emailid, ContactDet, txtCompName.Text.Trim(), newstr);

                    //divadd.Visible = false;
                    //dvAddtd.Visible = false;
                    //divadd.Visible = false;
                    //SuccessId.Visible = true;
                }
                else
                {
                    string js1 = "alert('Company name already exists');";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser", js1, true);
                }
            }
        }
        else
        {
            txtDtIncorp.Text = DateTime.Now.ToString("dd/MM/yyyy");
            int responseid = objBLL.EditCompany(Convert.ToInt32(txtCompanyID.Text), Convert.ToInt32(txtCompCode.Text), Convert.ToInt32(ddlCompanyType.SelectedValue)
                                                , txtCompName.Text, txtShortName.Text, txtRegNo.Text, txtDtIncorp.Text, UDFLib.ConvertIntegerToNull(ddlCountryIncorp.SelectedValue), UDFLib.ConvertIntegerToNull(ddlCurrency.SelectedValue)
                                                , txtAddrerss.Text, UDFLib.ConvertIntegerToNull(ddlAddressCountry.SelectedValue), txtEmail.Text, txtPhone.Text, txtEmail2.Text, txtPhone2.Text, txtFax1.Text, txtFax2.Text, UDFLib.ConvertToInteger(Session["UserID"]));
        }

        BindCompany();

        string hidemodal = String.Format("hideModal('divadd')");

        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true);
    }