Пример #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (BizObject != null && Validation.Validate(BizObject))
     {
         try
         {
             if (BizObject.Id != 0)
             {
                 Models.Customer Customer = (Models.Customer)TaxiDbContext.Instance.Users.Find(BizObject.Id);
                 Customer.FullName = BizObject.FullName;
                 Customer.Mobile   = BizObject.Mobile;
                 Customer.Address  = BizObject.Address;
                 TaxiDbContext.Instance.SaveChanges();
                 BizObject = null;
                 MessageBoxRTL.Info(".مشتری با موفقیت ویرایش شد", string.Empty);
                 UpdateGrid();
             }
             else if (BizObject.Id == 0)
             {
                 BizObject.Role       = Roles.Customer;
                 BizObject.DateJoined = DateTime.Today;
                 TaxiDbContext.Instance.Users.Add(BizObject);
                 TaxiDbContext.Instance.SaveChanges();
                 MessageBoxRTL.Info(".مشتری با موفقیت افزوده شد", string.Empty);
                 UpdateGrid();
             }
             BizObject = null;
         }
         catch
         {
             MessageBoxRTL.Error("ذخیره سازی مشتری با خطا روبرو شد.", string.Empty);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Save check code result for create user
        /// </summary>
        /// <param name=""></param>
        static public ReturnJasonConstruct <DTO.Account> Create(string telNo, int code)
        {
            ReturnJasonConstruct <DTO.Account> obj = new ReturnJasonConstruct <DTO.Account>();

            try
            {
                MissFreshEntities db = new MissFreshEntities();

                Models.Customer ct = new Models.Customer();
                ct.id         = Guid.NewGuid();
                ct.telNo      = telNo;
                ct.createTime = DateTime.Now;

                Models.Account ac = new Models.Account();
                ac.id     = Guid.NewGuid();
                ac.code   = code.ToString();
                ac.userId = ct.id;

                db.Customers.Add(ct);
                db.Accounts.Add(ac);
                db.SaveChanges();

                obj.status    = (int)executeStatus.success;
                obj.DTOObject = ac.ToDTO();

                return(obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
 public CustomerViewModel(Customer customer)
 {
     CustomerId = customer.Id;
     DateOfBirth = customer.DateOfBirth.ToShortDateString();
     FirstName = customer.FirstName;
     LastName = customer.LastName;
 }
Пример #4
0
 public Cart(Customer customer)
 {
     this.customerId = customer.id;
     this.price = 0;
     this.num = 0;
     this.Customer = customer;
     this.CartItems = new HashSet<CartItem>();
 }
 private void UpdateCustomer(SharedCustomer sharedCustomer, Customer customer)
 {
     customer.BillingAddress = sharedCustomer.BillingAddress;
     customer.FirstName = sharedCustomer.FullName.Split(Convert.ToChar(" "))[0];
     customer.LastName = sharedCustomer.FullName.Split(Convert.ToChar(" "))[1];
     customer.MasterId = sharedCustomer.Id;
     _customerManager.UpdateCustomer(true);
 }
Пример #6
0
 public static void DeepCopyCustomerProperties(Customer fromCustomer, ref Customer toCustomer)
 {
     toCustomer.FirstName = fromCustomer.FirstName;
     toCustomer.LastName = fromCustomer.LastName;
     toCustomer.Address = fromCustomer.Address;
     toCustomer.Telephone = fromCustomer.Telephone;
     toCustomer.Email = fromCustomer.Email;
 }
Пример #7
0
 public static void AddCustomerAlongWithItsLedgerToDatabase(Customer customer)
 {
     using (var context = new ERPContext())
     {
         context.Customers.Add(customer);
         context.SaveChanges();
     }
 }
Пример #8
0
 public static void SaveCustomerEditsToDatabase(Customer editingCustomer, Customer editedCustomer)
 {
     using (var ts = new TransactionScope())
     {
         var context = new ERPContext();
         SaveCustomerEditsToDatabaseContext(context, editingCustomer, editedCustomer);
         ts.Complete();
     }
 }
        private Customer HydrateContextCustomer(Customer customer)
        {
            var customerToUpdate = _customerManager.GetCustomerById(customer.Id);

            customerToUpdate.BillingAddress = customer.BillingAddress;
            customerToUpdate.FullName = customer.FullName;
            customerToUpdate.ShippingAddress = customer.ShippingAddress;

            return customerToUpdate;
        }
Пример #10
0
        /// <summary>
        /// Bind to the given model type
        /// </summary>
        /// <param name="context">Current context</param>
        /// <param name="modelType">Model type to bind to</param>
        /// <param name="blackList">Blacklisted property names</param>
        /// <returns>Bound model</returns>
        public object Bind(NancyContext context, Type modelType, params string[] blackList)
        {
            var customer = new Customer
                               {
                                   Name = context.Request.Form["Name"],
                                   RenewalDate = context.Request.Form["RenewalDate"]
                               };

            return customer;
        }
Пример #11
0
 private void HydrateUpdateGroup(Customer customer)
 {
     txtUpdateAddress.Text = customer.BillingAddress.Street;
     txtUpdateCity.Text = customer.BillingAddress.City;
     txtUpdateFirstName.Text = customer.FirstName;
     txtUpdateLastName.Text = customer.LastName;
     txtUpdateState.Text = customer.BillingAddress.State;
     txtUpdateZipCode.Text = customer.BillingAddress.ZipCode;
     lblUpdateId.Text = customer.Id.ToString();
 }
Пример #12
0
        public uint CalculateOrderCosts(Customer customer, IOrderManagement contract)
        {
            var orderCosts = contract.ReOrder(
                customer.Property.IsCreditChecked,
                customer.Property.Location,
                customer.AnnualBasicOrder,
                customer.Property.MonthlyQuantity,
                customer.AnnualOrderDiscountAllowance);

            return orderCosts;
        }
        private void AddCustomer(SharedCustomer sharedCustomer)
        {
            var customer = new Customer
            {
                BillingAddress = sharedCustomer.BillingAddress,
                FirstName = sharedCustomer.FullName.Split(Convert.ToChar(" "))[0],
                LastName = sharedCustomer.FullName.Split(Convert.ToChar(" "))[1],
                MasterId = sharedCustomer.Id
            };

            _customerManager.AddCustomer(customer, true);
        }
Пример #14
0
        private void EditBizObject()
        {
            BizObject = null;
            int id;

            int.TryParse(gridCustomers.SelectedCells.First().RowInfo.Cells["Id"].Value.ToString(), out id);
            UpdateGrid();
            Models.Customer CustomerToEdit = TaxiDbContext.Instance.Users.OfType <Models.Customer>().Include(u => u.Services).SingleOrDefault(c => c.Id == (int)id && c.Role == Roles.Customer);
            if (CustomerToEdit != null)
            {
                BizObject = (Models.Customer)CustomerToEdit.Clone();
            }
        }
Пример #15
0
        public frmCustomers()
        {
            InitializeComponent();

            if (TaxiDbContext.Instance.Users.OfType <Models.Customer>().Any())
            {
                UpdateGrid();
            }

            BizObject = new Models.Customer();

            gridCustomers.CellClick += gridCustomers_CellClick;
        }
 public ActionResult Create(Customer customer)
 {
     try
     {
         customerRepository.Add(customer);
         customerRepository.Save();
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Пример #17
0
 public ActionResult Filters()
 {
     var entities = new NorthwindEntities(NorthwindServiceUrl);
     var customers =
         new Customer[] { null }.Union(
                                     entities.Orders.Expand(o => o.Customer)
                                             .ToArray()
                                             .Select(o => o.Customer)
                                             .Distinct());
     return View(new FiltersModel
                     {
                         Customers = customers
                     });
 }
Пример #18
0
        private void Seed()
        {
            var gosho = new Customer("George");
            gosho.Purchases.Add(new Purchase("Corkscrew", 20));
            gosho.Purchases.Add(new Purchase("Audi A6", 3000.00));

            var peyo = new Customer("Peyo");
            peyo.Purchases.Add(new Purchase("Sheets", 415.50));

            var tania = new Customer("Tania");
            tania.Purchases.Add(new Purchase("Ropes", 99.90));
            tania.Purchases.Add(new Purchase("Fifty Shades of Gray", 129.80));
            tania.Purchases.Add(new Purchase("Intimate Nerve Stimulant", 455.90));
            tania.Discount = 3.3;

            this.customers.Add(gosho);
            this.customers.Add(peyo);
            this.customers.Add(tania);
        }
Пример #19
0
        void DeleteBizObject()
        {
            Models.Customer CustomerToRemove = TaxiDbContext.Instance.Users.Find(int.Parse(gridCustomers.CurrentRow.Cells["Id"].Value.ToString())) as Models.Customer;
            DialogResult    dr = MessageBoxRTL.Ask("آیا از حذف مشتری اطمینان دارید؟", string.Empty);

            if (dr == DialogResult.OK)
            {
                try
                {
                    //TaxiDbContext.Instance.Users.Remove(CustomerToRemove);
                    CustomerToRemove.IsDeleted = true;
                    TaxiDbContext.Instance.SaveChanges();
                    MessageBoxRTL.Info(".مشتری با موفقیت حذف شد", string.Empty);
                    UpdateGrid();
                    BizObject = null;
                }
                catch
                {
                    MessageBoxRTL.Error("حذف مشتری با خطا روبرو شد", string.Empty);
                }
            }
        }
Пример #20
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     BizObject = null;
 }
Пример #21
0
 private static void SaveCustomerEditsToDatabaseContext(ERPContext context, Customer editingCustomer, Customer editedCustomer)
 {
     editingCustomer = context.Customers.Single(customer => customer.ID.Equals(editingCustomer.ID));
     DeepCopyCustomerProperties(editedCustomer, ref editingCustomer);
     context.SaveChanges();
 }
 public void DeleteCustomer(CustomerEditViewData data)
 {        
                 Customer cust = new Customer()
                 {
             CustomerID = data.CustomerID,
             FirstName = data.FirstName,
             LastName = data.LastName,
             Address = data.Address,
             City = data.City,
             ZipCode = data.ZipCode,
             Country = data.Country,
             Email = data.Email,
             TelephoneNumber = data.TelephoneNumber,
             MobileNumber = data.MobileNumber,
             CreditCardNumber = data.CreditCardNumber,
             ExpirationDate = data.ExpirationDate,  
                 };
     cusRep.DeleteCustomer(cust);
     context_db.SaveChanges();
     Messenger.NotifyColleagues(MessageTypes.MSG_CUSTOMER_DELETED, data);
 }
 public void InsertCustomer(CustomerInsertViewData data)
 {
     Customer cust = new Customer()
     {
         FirstName = data.FirstName,
         LastName = data.LastName,
         City = data.City,
         MobileNumber = data.MobileNumber,
     };
     cusRep.InsertAction(cust);
     context_db.SaveChanges();
     Messenger.NotifyColleagues(MessageTypes.MSG_CUSTOMER_INSERTED, data);
 }
Пример #24
0
        protected void btnCheckOut_Click(object sender, EventArgs e)
        {
            CustomerModel cm = new CustomerModel();
            List<Cart> carts = (List<Cart>) Session["cart"];
            string newId = GenerateOrderKey();
            lblError.Text = newId;
            Customer customer = new Customer()
            {
                OrderID = newId,
                FirstName = "David",
                LastName = "Ramvall",
                Email = "*****@*****.**",
                PhoneNumber = 0723332993,
                Address = "Shaktsgatan 20",
                ZipCode = 12345,
                City = "Bjuv",
                PayMethod = "Faktura",
                ChipmentMethod = "ica"
            };
            lblError.Text = cm.InsertCustomer(customer);
            //RankAdd();
            lblError.Text += " , " + InsertCarts(carts, cm.GetCustomerID(newId));

            //Response.Redirect("OrderConfirmationPage");
        }
 public void Visit(Customer customer)
 {
     customer.Purchases.Add(new Purchase("SteamOp", 0.0));
 }
Пример #26
0
 public Customer(Keys.ICustomer key, Models.Customer element)
 {
     Key     = key;
     Element = element;
 }
 public void Visit(Customer customer)
 {
     customer.Discount += 5;
 }
 public IActionResult Index(Models.Customer customer)
 {
     return(View("Customer"));
 }