public Int32 SaveCustomer(Customer customer) { Customer query = new Customer(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { if (customer.id != 0) { query = db.Customers.Where(m => m.id == customer.id).FirstOrDefault(); } if (query != default(Customer)) { query.Name = customer.Name; query.Address = customer.Address; query.Address2 = customer.Address2; query.City = customer.City; query.State = customer.State; query.Phone = customer.Phone.CleanPhone(); query.Zip = customer.Zip; query.Tax = customer.Tax; query.ImageUrl = customer.ImageUrl; } if (customer.id == 0) { db.Customers.InsertOnSubmit(query); } db.SubmitChanges(); // Update ImageName for a new category if (customer.id == 0 && query.ImageUrl != null) { query.ImageUrl = String.Format("{0}{1}", query.id, customer.ImageUrl); db.SubmitChanges(); } // Create infrastructure String path = String.Format("{0}//Images/Menus/{1}", AppDomain.CurrentDomain.BaseDirectory, customer.id); if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); String subpath = String.Format("{0}/Customers", path); if (!Directory.Exists(subpath)) { di = Directory.CreateDirectory(subpath); } subpath = String.Format("{0}/Users", path); if (!Directory.Exists(subpath)) { di = Directory.CreateDirectory(subpath); } subpath = String.Format("{0}/Categories", path); if (!Directory.Exists(subpath)) { di = Directory.CreateDirectory(subpath); } subpath = String.Format("{0}/Items", path); if (!Directory.Exists(subpath)) { di = Directory.CreateDirectory(subpath); } } } } catch (Exception ex) { throw ex; } return query.id; }
public ActionResult Index(RegistrationModel model) { // Save Customer info Customer customer; User user; try { customer = new Customer(); user = new User(); customer.id = 0; customer.Name = model.Customer.Name; customer.Address = model.Customer.Address; customer.Address2 = model.Customer.Address2; customer.City = model.Customer.City; customer.State = model.Customer.State; customer.Zip = model.Customer.Zip; customer.Phone = model.Customer.Phone; customer.Tax = model.Customer.Tax; customer.ImageUrl = model.Customer.ImageUrl; Int32 result = _customerService.SaveCustomer(customer); // Save registered modules _customerService.SaveModulesByCustomer(result, model.Modules.Split(',').Select(Int32.Parse).ToArray()); SessionData.customer = customer; // Save user personal info user.id = 0; user.CustomerId = SessionData.customer.id; user.FirstName = model.User.FirstName; user.LastName = model.User.LastName; user.WorkPhone = model.User.WorkPhone.CleanPhone(); user.MobilePhone = model.User.MobilePhone.CleanPhone(); user.Password = model.User.Password; user.Email = model.User.Email; user.Active = false; user.Hash = Utility.GetNewConfirmationNumber(); user.Type = (Int32)Common.UserType.Administrator; result = _userService.SaveUser(user); SessionData.user = user; base.Log(Common.LogType.Activity, "Registering", String.Format("{0} {1}, phone#{2}, mobile#{3}", model.User.FirstName, model.User.LastName, model.User.WorkPhone, model.User.MobilePhone)); EmailHelper.SendEmailConfirmation(this.ControllerContext, user); return RedirectToAction("Index", "Login"); } catch (Exception ex) { base.Log(ex); } finally { } return null; }
public ActionResult SaveCustomer(CustomerModel model) { Customer customer ; try { customer = new Customer(); customer.id = model.id; customer.Name = model.Name; customer.Address = model.Address; customer.Address2 = model.Address2; customer.City = model.City; customer.State = model.State; customer.Zip = model.Zip; customer.Tax = model.Tax; customer.Phone = model.Phone; customer.ImageUrl = model.ImageUrl; // Image if (model.Image != null) { if (customer.id == 0) customer.ImageUrl = Path.GetExtension(model.Image.FileName); else customer.ImageUrl = String.Format("{0}{1}", model.id, Path.GetExtension(model.Image.FileName)); } Int32 result = _customerService.SaveCustomer(customer); if (result == 0) return RedirectToAction("Index", "Error"); SessionData.customer = customer; String fileName = (model.Image == null ? model.ImageUrl : model.Image.FileName); String path = Path.Combine(Server.MapPath("~/Images/Menus/"), SessionData.customer.id.ToString(), "Customers", String.Format("{0}{1}", result, Path.GetExtension(fileName))); if (model.Image == null && model.ImageUrl == null) { if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } else if (model.Image != null) { model.Image.SaveAs(path); } SaveSetting(Common.Settings.Language, model.SelectedLanguage); SaveSetting(Common.Settings.PrinterPOS, model.PrinterPOS); SaveSetting(Common.Settings.PrinterKitchen, model.PrinterKitchen); SaveSetting(Common.Settings.PrinterPOSWidth, ((Int32)(Common.PrinterWidth)Enum.Parse(typeof(Common.PrinterWidth), model.PrinterPOSWidth)).ToString()); SaveSetting(Common.Settings.PrinterKitchenWidth, ((Int32)(Common.PrinterWidth)Enum.Parse(typeof(Common.PrinterWidth), model.PrinterKitchenWidth)).ToString()); return RedirectToAction("Index", "Login"); } catch (Exception ex) { base.Log(ex); } finally { } return null; }
private void changeState(Customer.CustomerDataTable customerDataTable, int rowindex) { if(customerDataTable.Rows.Count>0) { var row = customerDataTable.Rows[rowindex] as Customer.CustomerRow; if (row != null) { txtAddress.Text = row.IsAddress_1Null() ? "" : row.Address_1; txtDateBirth.Text = row.IsBirthdayNull() ? "" : String.Format("{0:d/M/yyyy}", row.Birthday); txtDateCloseAccount.Text = row.IsAcct_Close_DateNull() ? "" : String.Format("{0:d/M/yyyy}", row.Acct_Close_Date); txtDateCustomer.Text = row.IsCreateDateNull() ? "" : String.Format("{0:d/M/yyyy}", row.CreateDate); txtDateOpenAccount.Text = row.IsAcct_Open_DateNull() ? "" : String.Format("{0:d/M/yyyy}", row.Acct_Open_Date); txtDiscountPercent.Text = row.Discount_Percent.ToString(); txtEmail.Text = row.IsEMailNull() ? "" : row.EMail; txtMaKH.Text = row.CustNum; txtMaxBalance.Text = row.IsAcct_Max_BalanceNull() ? "" : String.Format("{0:0,0}", row.Acct_Max_Balance); txtMobilephone.Text = row.IsPhone_1Null() ? "" : row.Phone_1; lbCustName.Text = txtName.Text = row.Last_Name; txtNameCompany.Text = row.IsCompanyNull() ? "" : row.Company; txtTelephone.Text = row.IsPhone_2Null() ? "" : row.Phone_2; lblNumberOfAdd.Text = row.IsAcct_BalanceNull() ? "" : String.Format("{0:0,0}", row.Acct_Balance); // Swipe listBox1.Items.Clear(); swipeList = serviceGet.GetCustSwipeById(row.CustNum); foreach (Persistence.CustomerSwipe customerSwipe in swipeList) { listBox1.Items.Add(customerSwipe); } } } }
public List<Booking> GetAllCustomersOnBooking(Customer customer) { return _bookingCtr.GetAllCustomersOnBooking(customer); }
partial void DeleteCustomer(Customer instance);
partial void UpdateCustomer(Customer instance);
partial void InsertCustomer(Customer instance);