private Parameter[] generateParameters(CustomerEdit ce) { List<Parameter> parms = new List<Parameter>(); var names = ce.tName.Text.Trim().Split(' '); parms.Add(new Parameter("first_name", names[0])); parms.Add(new Parameter("last_name", names[1])); parms.Add(new Parameter("dob", ce.tDoB.Value)); parms.Add(new Parameter("address", ce.tAddress.Text.Trim())); parms.Add(new Parameter("city", ce.tCity.Text.Trim())); parms.Add(new Parameter("country", ce.tCountry.Text.Trim())); parms.Add(new Parameter("postal_code", ce.tPostalCode.Text.Trim())); parms.Add(new Parameter("phone", ce.tPhone.Text.Trim())); parms.Add(new Parameter("email", ce.tEmail.Text.Trim())); parms.Add(new Parameter("company", ce.tCompany.Text.Trim())); return parms.ToArray(); }
private void tPhone_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) { IProgress<Customer> customerProgess = new Progress<Customer>( c => { this.c = c; ceView.tName.Text = c.Name; ceView.tCompany.Text = c.Company; ceView.tAddress.Text = c.Address; ceView.tCity.Text = c.City; ceView.tCountry.Text = c.Country; ceView.tPostalCode.Text = c.PostalCode; ceView.tPhone.Text = c.Phone; ceView.tDoB.Value = c.DoB; ceView.tID.Text = c.ID.ToString(); ceView.tEmail.Text = c.Email; bPay.Click -= bPay_NoCustomer; bPay.Click += bPay_Click; }); new Loading("Loading customer", () => { var phone = tPhone.Text; var phone2 = string.Format("1-{0}-{1}-{2}", phone.Substring(0, 3), phone.Substring(3, 3), phone.Substring(6)); #if DEBUG Console.WriteLine(phone2); #endif uint cid = 0; if (uint.TryParse("" + DB.Instance.SelectSingleValue("select id from customer where phone = '" + phone2 + "'"), out cid)) { customerProgess.Report(new Customer(cid)); } else { if (MessageBox.Show("No Customer Found!\nWould you like to rigister?", "Customer", MessageBoxButtons.YesNo) == DialogResult.Yes) { CustomerEdit ce = new CustomerEdit(); ce.tPhone.Text = phone2; if ((new EditWindow(ce).ShowDialog()) == DialogResult.OK) { cid = (uint)DB.Instance.SelectSingleValue("select id from customer where phone = '" + phone2 + "'"); customerProgess.Report(new Customer(cid)); } } } }); } }