Пример #1
0
        protected bool saveLienholder()
        {
            int id = Convert.ToInt32(hf_id.Value);

            clientID = Core.SessionHelper.getClientId();


            Mortgagee mortgagee = null;

            // 2013-08-07 tortega
            using (TransactionScope scope = new TransactionScope()) {
                if (id > 0)
                {
                    mortgagee = MortgageeManager.Get(id);
                }
                else
                {
                    bool exists = MortgageeManager.IsExist(txtName.Text.Trim(), clientID);
                    if (exists)
                    {
                        lblMessage.Text     = "Mortgagee name already exists.";
                        lblMessage.CssClass = "error";
                        txtName.Focus();
                        return(false);
                    }

                    mortgagee        = new Mortgagee();
                    mortgagee.Status = true;
                }

                mortgagee.ClientID     = clientID;
                mortgagee.MortageeName = txtName.Text.Trim();
                mortgagee.AddressLine1 = txtAddress.Text.Trim();
                mortgagee.AddressLine2 = txtAddress2.Text.Trim();

                mortgagee.CityID    = Convert.ToInt32(ddlCity.SelectedValue);
                mortgagee.StateID   = Convert.ToInt32(this.ddlState.SelectedValue);
                mortgagee.ZipCodeID = Convert.ToInt32(this.ddlLossZip.SelectedValue);

                mortgagee.Phone = txtPhone.Text.Trim();
                mortgagee.Fax   = txtFax.Text.Trim();
                mortgagee.Email = txtEmail.Text;

                mortgagee.ContactName = txtContactName.Text;

                if (ddlCountry.SelectedIndex > 0)
                {
                    mortgagee.CountryID = Convert.ToInt32(ddlCountry.SelectedValue);
                }

                MortgageeManager.Save(mortgagee);

                scope.Complete();
            }
            return(true);
        }
Пример #2
0
        protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Mortgagee mortgagee = null;

            if (e.CommandName == "DoEdit")
            {
                hf_id.Value = e.CommandArgument.ToString();

                mortgagee = MortgageeManager.Get(Convert.ToInt32(e.CommandArgument));

                if (mortgagee != null)
                {
                    pnlEdit.Visible = true;
                    pnlList.Visible = false;

                    hf_id.Value = mortgagee.MortgageeID.ToString();

                    CollectionManager.FillCollection(ddlState, "StateId", "StateName", State.GetAll());
                    CollectionManager.FillCollection(ddlCity, "CityId", "CityName", City.GetAll(mortgagee.StateID ?? 0));
                    CollectionManager.FillCollection(ddlLossZip, "ZipCodeID", "ZipCode", ZipCode.getByCityID(mortgagee.CityID ?? 0));

                    txtName.Text     = mortgagee.MortageeName;
                    txtAddress.Text  = mortgagee.AddressLine1;
                    txtAddress2.Text = mortgagee.AddressLine2;
                    txtFax.Text      = mortgagee.Fax;
                    txtPhone.Text    = mortgagee.Phone;

                    txtEmail.Text       = mortgagee.Email;
                    txtContactName.Text = mortgagee.ContactName;


                    if (mortgagee.StateID != null)
                    {
                        ddlState.SelectedValue = mortgagee.StateID.ToString();
                    }

                    if (mortgagee.CityID != null)
                    {
                        ddlCity.SelectedValue = mortgagee.CityID.ToString();
                    }

                    if (mortgagee.ZipCodeID != null)
                    {
                        ddlLossZip.SelectedValue = mortgagee.ZipCodeID.ToString();
                    }

                    this.ddlCountry.SelectedValue = (mortgagee.CountryID ?? 0).ToString();
                }
            }

            if (e.CommandName == "DoDelete")
            {
                mortgagee = MortgageeManager.Get(Convert.ToInt32(e.CommandArgument));
                if (mortgagee != null)
                {
                    mortgagee.Status = false;

                    MortgageeManager.Save(mortgagee);

                    bindLienholders();
                }
            }
        }