protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (dealerBiz == null)
                {
                    dealerBiz = new DealerBiz();
                }

                if (dealerBiz.IsDealerExist(txtCustomerID.Text.Trim()))
                {
                    lblAddNewError.Text = GetLocaleResourceString("Dealer.DealerIDExistMessage");
                    return;
                }

                lwg_Dealer newDealer = new lwg_Dealer();
                newDealer.DealerID     = txtCustomerID.Text.Trim();
                newDealer.AddressLine1 = txtAddress1.Text.Trim();
                newDealer.AddressLine2 = txtAddress2.Text.Trim();
                newDealer.City         = txtCity.Text.Trim();
                newDealer.Contact      = txtContact.Text.Trim();
                newDealer.Fax          = txtFax.Text.Trim();
                newDealer.Name         = txtName.Text.Trim();
                newDealer.NewIssue     = txtNewIssue.Text.Trim();
                newDealer.Phone        = txtPhone.Text.Trim();
                if (ddlUSState.SelectedValue == "00")
                {
                    newDealer.State = txtState.Text.Trim();
                }
                else
                {
                    newDealer.State = ddlUSState.SelectedValue;
                }
                newDealer.WebAddress    = txtWebAddress.Text.Trim();
                newDealer.Zip           = txtZip.Text.Trim();
                newDealer.AddressSearch = string.Format("{0} {1} {2} {3} {4}", txtAddress1.Text.Trim(), txtAddress2.Text.Trim(), txtCity.Text.Trim(), txtState.Text.Trim(), txtZip.Text.Trim());

                if (dealerBiz.AddDealer(newDealer))
                {
                    Response.Redirect("dealer.aspx");
                    //pnlAddNew.Visible = false;
                    //pnlAddNewMessage.Visible = true;
                }
                else
                {
                    pnlAddNew.Visible        = true;
                    pnlAddNewMessage.Visible = false;
                    lblAddNewError.Text      = GetLocaleResourceString("Dealer.AddFailMessage");
                }
            }
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (dealerBiz == null)
                {
                    dealerBiz = new DealerBiz();
                }
                lwg_Dealer dealer = dealerBiz.GetDealerByDealerID(DealerID);
                lblError.Text   = string.Empty;
                lblSuccess.Text = string.Empty;
                bool updateNewID = false;

                if (txtDealerID.Text.Trim() != DealerID && dealerBiz.IsDealerExist(txtDealerID.Text.Trim()))
                {
                    lblError.Text = GetLocaleResourceString("Dealer.DealerIDExistMessage");
                    return;
                }
                else
                if (txtDealerID.Text.Trim() != DealerID && !dealerBiz.IsDealerExist(txtDealerID.Text.Trim()))  // new id
                {
                    updateNewID = true;
                }
                if (dealer != null)
                {
                    dealer.AddressLine1 = txtAddress1.Text.Trim();
                    dealer.AddressLine2 = txtAddress2.Text.Trim();
                    dealer.City         = txtCity.Text.Trim();
                    dealer.Contact      = txtContact.Text.Trim();
                    dealer.Fax          = txtFax.Text.Trim();
                    dealer.Name         = txtName.Text.Trim();
                    dealer.NewIssue     = txtNewIssue.Text.Trim();
                    dealer.Phone        = txtPhone.Text.Trim();
                    if (ddlUSState.SelectedValue == "00")
                    {
                        dealer.State = txtState.Text.Trim();
                    }
                    else
                    {
                        dealer.State = ddlUSState.SelectedValue;
                    }
                    dealer.WebAddress    = txtWebAddress.Text.Trim();
                    dealer.Zip           = txtZip.Text.Trim();
                    dealer.AddressSearch = string.Format("{0} {1} {2} {3} {4}", txtAddress1.Text.Trim(), txtAddress2.Text.Trim(), txtCity.Text.Trim(), txtState.Text.Trim(), txtZip.Text.Trim());

                    bool updateSuccess;
                    if (updateNewID)
                    {
                        updateSuccess = dealerBiz.UpdateDealer(dealer, txtDealerID.Text.Trim());
                    }
                    else
                    {
                        updateSuccess = dealerBiz.UpdateDealer(dealer, string.Empty);
                    }

                    if (updateSuccess)
                    {
                        if (updateNewID)
                        {
                            Session["DealerUpdateSuccess"] = GetLocaleResourceString("Dealer.UpdateSuccessMessage");
                            Response.Redirect(string.Format("dealerdetails.aspx?dealerid={0}", txtDealerID.Text.Trim()));
                        }
                        else
                        {
                            lblSuccess.Text = GetLocaleResourceString("Dealer.UpdateSuccessMessage");
                        }
                    }
                    else
                    {
                        lblError.Text = GetLocaleResourceString("Dealer.UpdateFailMessage");
                    }
                }
            }
        }