Ejemplo n.º 1
0
    protected void btnSaveUnionBranch_OnClick(object sender, EventArgs e)
    {
        try
        {
            DataTable      dt       = new DataTable();
            BLL_Crew_Admin objBLL   = new BLL_Crew_Admin();
            int            rowcount = 0;

            if (Convert.ToInt32(hdnUnionBranchID.Value) > 0)
            {
                if (hdnAddressType.Value == "1")
                {
                    dt = objBLL.CRUD_UnionBranchUS(txtUnionBranch.Text.Trim(), Convert.ToInt32(hdnUnionBranchID.Value), Convert.ToInt32(drpUnion.SelectedValue), txtAddress.Text.Trim(), Convert.ToInt32(drpCountry.SelectedValue), txtPhoneNumber.Text.Trim(), txtEmail.Text.Trim(), "U", GetSessionUserID(), "", "", null, null, null, ref rowcount, ref Result).Tables[0];
                }
                else
                {
                    dt = objBLL.CRUD_UnionBranch(txtUnionBranch.Text.Trim(), Convert.ToInt32(hdnUnionBranchID.Value), Convert.ToInt32(drpUnion.SelectedValue), txtAddressLine1.Text.Trim(), txtAddressLine2.Text.Trim(), txtCity.Text.Trim(), txtState.Text, Convert.ToInt32(drpCountry.SelectedValue), txtZipCode.Text.Trim(), txtPhoneNumber.Text.Trim(), txtEmail.Text.Trim(), "U", GetSessionUserID(), "", "", null, null, null, ref rowcount, ref Result).Tables[0];
                }

                if (Result > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('" + UDFLib.GetException("SuccessMessage/UpdateMessage") + "');hideModal('divAddUnionBranch');", true);
                }
            }
            else
            {
                if (hdnAddressType.Value == "1")
                {
                    dt = objBLL.CRUD_UnionBranchUS(txtUnionBranch.Text.Trim(), 0, Convert.ToInt32(drpUnion.SelectedValue), txtAddress.Text.Trim(), Convert.ToInt32(drpCountry.SelectedValue), txtPhoneNumber.Text.Trim(), txtEmail.Text.Trim(), "I", GetSessionUserID(), "", "", null, null, null, ref rowcount, ref Result).Tables[0];
                }
                else
                {
                    dt = objBLL.CRUD_UnionBranch(txtUnionBranch.Text.Trim(), 0, Convert.ToInt32(drpUnion.SelectedValue), txtAddressLine1.Text.Trim(), txtAddressLine2.Text.Trim(), txtCity.Text.Trim(), txtState.Text, Convert.ToInt32(drpCountry.SelectedValue), txtZipCode.Text.Trim(), txtPhoneNumber.Text.Trim(), txtEmail.Text.Trim(), "I", GetSessionUserID(), "", "", null, null, null, ref rowcount, ref Result).Tables[0];
                }

                if (Result > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('" + UDFLib.GetException("SuccessMessage/SaveMessage") + "');hideModal('divAddUnionBranch');", true);
                }
            }

            if (Result < 0)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('The selected Union Branch already exist in the system');showModal('divAddUnionBranch', false);", true);
            }
            BindUnionBranch();
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
        }
    }