示例#1
0
        public static void AddCustomer(PostClCustomer customer)
        {
            //var oauthValidator = new OAuthRequestValidator(
            //    ConfigurationManager.AppSettings["accessToken"].ToString(CultureInfo.InvariantCulture),
            //    ConfigurationManager.AppSettings["accessTokenSecret"].ToString(CultureInfo.InvariantCulture),
            //    ConfigurationManager.AppSettings["consumerKey"].ToString(CultureInfo.InvariantCulture),
            //    ConfigurationManager.AppSettings["consumerKeySecret"].ToString(CultureInfo.InvariantCulture));

            //var context = new ServiceContext(
            //    oauthValidator,
            //    ConfigurationManager.AppSettings["realmId"].ToString(CultureInfo.InvariantCulture),
            //    IntuitServicesType.QBO);

            //var dataServices = new DataServices(context);

            //var newCustomer = new Customer
            //    {
            //        Active = true,
            //        GivenName = customer.FirstName,
            //        FamilyName = customer.LastName,
            //        Name = customer.QuickBookAccountName,
            //        Email = new EmailAddress[1],
            //        Phone = new TelephoneNumber[1],
            //        WebSite = new WebSiteAddress[1],
            //        Address = new PhysicalAddress[1],
            //        DBAName = customer.DealerName,
            //        OpenBalanceDate = DateTime.Now,
            //        SalesTermName = "Due On Reciept",
            //        SalesTermId = new IdType
            //            {
            //                Value = "1"
            //            },
            //        Notes = new Note[1]
            //    };

            //newCustomer.Notes[0] = new Note
            //    {
            //        Content = "New account is just set up without credit card infomation",
            //    };

            //newCustomer.Email[0] = new EmailAddress { Address = customer.CustomerEmail };

            //newCustomer.Phone[0] = new TelephoneNumber
            //    {
            //        FreeFormNumber = customer.CustomerPhone,
            //        DateLastVerified = DateTime.Now
            //    };


            //newCustomer.Address[0] = new PhysicalAddress
            //    {
            //        Country = "USA",
            //        City = customer.DealerCity,
            //        CountryCode = "01",
            //        Line1 = customer.DealerStreetAddress,
            //        PostalCode = customer.DealerZipCode,
            //        Tag = new[] { "Billing" }
            //    };

            //var quickbookCustomer = dataServices.Add(newCustomer);



            //customer.QuickBookAccountId = quickbookCustomer.Id.Value;

            //if (!String.IsNullOrEmpty(customer.QuickBookAccountId))
            //{
            //    DataHelper.AddNewDealer(customer);
            //}
            DataHelper.AddNewDealer(customer);
        }
示例#2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                if (!String.IsNullOrEmpty(_mode) && _mode.Equals("Edit"))
                {
                    var selectedLeadFormat = (LeadFormat)cbFormat.SelectedItem;

                    var selectedState = (UsState)cbState.SelectedItem;

                    var newCustomer = new PostClCustomer
                    {
                        FirstName            = txtFirstName.Text,
                        LastName             = txtLastName.Text,
                        CustomerEmail        = txtCustomerEmail.Text,
                        CustomerPhone        = txtCustomerPhone.Text,
                        QuickBookAccountName = txtDealerName.Text + " - " + txtCustomerEmail.Text,
                        DealerName           = txtDealerName.Text,
                        WebSiteAddress       = txtWebSiteAddress.Text,
                        DealerStreetAddress  = txtStreetAddress.Text,
                        DealerZipCode        = txtZipcode.Text,
                        DealerCity           = txtCity.Text,
                        DealerState          = selectedState.StateAbbr,
                        DealerPhone          = txtDealerPhone.Text,
                        LeadEmail            = txtLeadEmail.Text,
                        LeadFormat           = selectedLeadFormat.LeadId,
                        DailyLimit           = _dailyLimit
                    };

                    DataHelper.UpdateDealerInfo(newCustomer);

                    DataHelper.InitializeGlobalDealerInfoVariable(GlobalVar.CurrentAccount.DealerId);

                    this.Close();
                }
                else
                {
                    if (!DataHelper.CheckAccountNameExist(txtCustomerEmail.Text))
                    {
                        btnOK.Enabled = false;

                        panelIndicator.Visible = true;

                        Refresh();

                        var selectedLeadFormat = (LeadFormat)cbFormat.SelectedItem;

                        var selectedState = (UsState)cbState.SelectedItem;

                        _newCustomer = new PostClCustomer
                        {
                            FirstName            = txtFirstName.Text.Trim(),
                            LastName             = txtLastName.Text.Trim(),
                            CustomerEmail        = txtCustomerEmail.Text.Trim(),
                            CustomerPhone        = txtCustomerPhone.Text,
                            QuickBookAccountName = txtDealerName.Text + " - " + txtCustomerEmail.Text,
                            DealerName           = txtDealerName.Text.Trim(),
                            WebSiteAddress       = txtWebSiteAddress.Text.Trim(),
                            DealerStreetAddress  = txtStreetAddress.Text.Trim(),
                            DealerZipCode        = txtZipcode.Text.Trim(),
                            DealerCity           = txtCity.Text.Trim(),
                            DealerState          = selectedState.StateAbbr,
                            DealerPhone          = txtDealerPhone.Text,
                            LeadEmail            = txtLeadEmail.Text.Trim(),
                            LeadFormat           = selectedLeadFormat.LeadId,
                            DailyLimit           = _dailyLimit
                        };



                        bgCustomerSignUp.RunWorkerAsync();
                    }
                    else
                    {
                        MessageBox.Show(
                            "This email is already in use. Please register with another email.",
                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else
            {
                MessageBox.Show(
                    "Please fill correct info in required fields. ",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }