Example #1
0
 public void CopyToCustomer(Customer c)
 {
     c.number = Number;
     c.name = Name;
     c.address = Address;
     c.mobile = Mobile;
 }
Example #2
0
 public OrderClothesUI(Order _order,Bag _bag,Customer _customer,Clothes _chonseClothes)
 {
     this.order = _order;
     this.bag = _bag;
     this.customer = _customer;
     this.chonseClothes = _chonseClothes;
 }
Example #3
0
 public void CopyFromCustomer(Customer c)
 {
     Number = c.number;
     Name = c.name;
     Address = c.address;
     Mobile = c.mobile;
 }
 public static bool IsCustomerContentSame(Customer a, Customer b)
 {
     return a.number == b.number &&
            a.name == b.name &&
            a.address == b.address &&
            a.mobile == b.mobile;
 }
Example #5
0
        // Hàm khởi tạo sử dụng để thêm mới đơn đặt hàng
        public Order(Bag _bag, Customer _customer, string _date)
        {
            this.bag = _bag;
            this.customer = _customer;
            this.date = _date;

            ConnectDB db = new ConnectDB();

            //Lấy ID của khách hàng vừa tạo
            string customerID = db.GetData("Select Top 1 ID from [dbo].[Customer] order by ID desc", "ID", "");
            // Sử dụng ID vừa lấy, thêm dữ liệu Order vào CSDL
            SqlParameter[] b = new SqlParameter[4];
            b[0] = new SqlParameter("@CustomerID", customerID);
            b[1] = new SqlParameter("@TotalPrice", bag.totalPrice);
            b[2] = new SqlParameter("@Date", DateTime.Now.ToString("MM/dd/yyyy"));
            b[3] = new SqlParameter("@Status", "1");
            db.ExecuteCommand("Order_Insert", b);

            // Lấy ID của Order vừa thêm vào bên trên
            string orderID = db.GetData("Select Top 1 ID from [dbo].[Order] order by ID desc", "ID", "");
            if (orderID == null) orderID = "1";

            // Sử dụng ID vừa lấy, thêm dữ liệu vào bảng OrderDetail
            SqlParameter[] a = new SqlParameter[3];
            foreach (Clothes item in _bag.listClothes)
            {
                a[0] = new SqlParameter("@OrderID", orderID);
                a[1] = new SqlParameter("@ClothesID", item.ID);
                a[2] = new SqlParameter("@Quantity", item.Quantity);
                db.ExecuteCommand("OrderDetail_Insert", a);
            }
        }
Example #6
0
 public OrderControl(Order _order,Bag _bag,Customer _customer,Cloth _chonseClothes)
 {
     this.order = _order;
     this.bag = _bag;
     this.customer = _customer;
     this.chonseCloth = _chonseClothes;
 }
 private void UpdateCustomer(EditableCustomer target,Customer customer)
 {
     customer.FirstName = target.FirstName;
     customer.LastName = target.LastName;
     customer.Phone = target.Phone;
     customer.Email = target.Email;
 }
 public void SetCustomer(Customer customer)
 {
     _editingCustomer = customer;
     Customer = new EditableCustomer();
     CopyCustomer(customer, Customer);
     if (Customer != null) Customer.ErrorsChanged -= RaiseCanExecuteChanged;
     Customer.ErrorsChanged += RaiseCanExecuteChanged;
 }
 private void AddOperation()
 {
     if (!CheckCustomerRecord(false) || !IsNameValid() || !IsAddressValid() || !IsMobileValid()) return;
     var custRecord = new Customer();
     _c.CopyToCustomer(custRecord);
     _dbOps.AddCustomer(custRecord);
     _c.Message = CustomerAdded;
 }
Example #10
0
        private void OnGetData( object sender, RoutedEventArgs e )
        {
            Customer.AddProperty("count", typeof(int));
            Customer.AddProperty("name", typeof(string));

            Customer cust = new Customer(counter + 1);
            cust["count"] = counter;
            cust["name"] = "test";
            Customers.Add(cust);
        }
        public async Task<Customer> UpdateCustomerAsync(Customer customer)
        {
            if (!_context.Customers.Local.Any(c => c.Id == customer.Id))
            {
                _context.Customers.Attach(customer);
            }
            _context.Entry(customer).State = EntityState.Modified;
            await _context.SaveChangesAsync();
            return customer;

        }
 public void CopyCustomer(Customer customer, EditableCustomer target)
 {
     target.Id = customer.Id;
     if (EditMode)
     {
         target.FirstName = customer.FirstName;
         target.LastName = customer.LastName;
         target.Phone = customer.Phone;
         target.Email = customer.Email;
     }
 }
Example #13
0
 public void CheckThatNumberUnique()
 {
     var c = CreateNewCustomer();
     var duplicateCustomer = new Customer()
     {
         number = c.number,
         name = Name1 + "a",
         address = Address1,
         mobile = Mobile1
     };
     DbCtx.Customers.Add(c);
     DbCtx.Customers.Add(duplicateCustomer);
     DbCtx.SaveChanges();
 }
Example #14
0
        public static void Main()
        {
            var newCustomer = new Customer()
            {
                CustomerID = "XASDa",
                ContactName = "Pesho",
                CompanyName = "Telerik"
            };

            DataAccess.InsertCustomer(newCustomer);
            Console.WriteLine("Customer inserted!");
            DataAccess.ChangeCustomerContactName(newCustomer.CustomerID, "Ivan");
            Console.WriteLine("Customer contact Name changed!");
            DataAccess.DeleteCustomer(newCustomer.CustomerID);
            Console.WriteLine("Customer deleted!");

            Console.WriteLine(new string('-', 50));
            var customers = DataAccess.FindCustomersWithOrdersInYearAndCountry(1997, "Canada");

            // Only for test, do not do it N+1 problem.
            customers
                .ForEach(c =>
                {
                    Console.WriteLine($"Contact Name: {c.ContactName}," +
                                      $" From: {c.Country}," +
                                      $" Has order in: {c.Orders.FirstOrDefault(o => o.OrderDate.Value.Year == 1997).OrderDate.Value.Year}");
                });

            customers = DataAccess.FindCustomersWithOrdersInYearAndCountryWithDbCommand(1997, "Canada");

            Console.WriteLine(new string('-', 50));
            customers
                .ForEach(c =>
                {
                    Console.WriteLine($"Contact Name: {c.ContactName}," +
                                      $" From: {c.Country},");
                });

            Console.WriteLine(new string('-', 50));

            var region = "RJ";
            var startDate = new DateTime(1996, 6, 3);
            var endDate = new DateTime(1997, 6, 3);

            var filterdOrders = DataAccess.FindSales(region, startDate, endDate);

            filterdOrders.ForEach(o => Console.WriteLine($"OrderId: {o.OrderID}," +
                                                         $" Region: {o.ShipRegion}," +
                                                         $" Order date: {o.OrderDate}"));
        }
        public void Compare_Equal_Customers()
        {
            var customerA = new Customer
            {
                Id = 0,
                FirstName = "Adelia",
                LastName = "Kessler",
                Address = new Address
                    {
                        Street = "16256 Reichel Plains",
                        City = "Ryanbury",
                        State = "VA",
                        Zip = "58851"
                    }
            };

            var customerB = new Customer
            {
                Id = 0,
                FirstName = "Adelia",
                LastName = "Kessler",
                Address = new Address
                    {
                        Street = "16256 Reichel Plains",
                        City = "Ryanbury",
                        State = "VA",
                        Zip = "58851"
                    }
            };

            var hash1 = customerA.ToMd5Hash();
            var hash2 = customerB.ToMd5Hash();

            Assert.AreEqual(hash1, hash2);
            Assert.AreEqual("21E1C0AA0002E52DE403735EC0C19E94", hash1);
            Assert.AreEqual("21E1C0AA0002E52DE403735EC0C19E94", hash2);
        }
        public void Compare_UnEqual_Customers()
        {
            var customerA = new Customer
            {
                Id = 0,
                FirstName = "Adelia",
                LastName = "Kessler",
                Address = new Address
                    {
                        Street = "16256 Reichel Plains",
                        City = "Ryanbury",
                        State = "VA",
                        Zip = "58851"
                    }
            };

            var customerB = new Customer
            {
                Id = 1,
                FirstName = "Melissa",
                LastName = "Labadie",
                Address = new Address
                    {
                        Street = "4751 Johan Landing",
                        City = "East Bettye",
                        State = "SD",
                        Zip = "54538"
                    }
            };

            var hash1 = customerA.ToMd5Hash();
            var hash2 = customerB.ToMd5Hash();

            Assert.AreNotEqual(hash1, hash2);
            Assert.AreEqual("21E1C0AA0002E52DE403735EC0C19E94", hash1);
            Assert.AreEqual("377D1122C74D414DE7ECC71932E94367", hash2);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCustomers(Customer customer)
 {
     base.AddObject("Customers", customer);
 }
 private void NavToAdd(Customer customer)
 {
     _addEditCustomerViewModel.EditMode = false;
     _addEditCustomerViewModel.SetCustomer(customer);
     CurrentViewModel = _addEditCustomerViewModel;
 }
 private void NavToEdit(Customer customer)
 {
     _addEditCustomerViewModel.EditMode = true;
     _addEditCustomerViewModel.SetCustomer(customer);
     CurrentViewModel = _addEditCustomerViewModel;
 }
 private void AddThisRecord(Customer c)
 {
     Console.WriteLine("adding {0}", c);
     _sut.Perform(() => _sut.Current.Customers.Add(c));
 }
        public void Customer_To_MD5_Hash()
        {
            var customer = new Customer
                {
                    Id = 0,
                    FirstName = "Adelia",
                    LastName = "Kessler",
                    Address = new Address
                        {
                            Street = "16256 Reichel Plains",
                            City = "Ryanbury",
                            State = "VA",
                            Zip = "58851"
                        }
                };

            var hash1 = customer.ToMd5Hash();

            customer.FirstName = "Adeliaa";

            var hash2 = customer.ToMd5Hash();

            Assert.AreEqual("21E1C0AA0002E52DE403735EC0C19E94", hash1);
            Assert.AreEqual("356264B04B09A4DCDC009746D2185A66", hash2);
        }
Example #22
0
 partial void DeleteCustomer(Customer instance);
 public void AddCustomer(Customer c)
 {
 }
Example #24
0
 partial void InsertCustomer(Customer instance);
Example #25
0
        protected override void Seed(LocalStoreContext context)
        {
            Customer customer1 = new Customer()
            {
                CreditCardNumber = "1234567",
                Email = "*****@*****.**",
                Name = "User"
            };

            Customer customer2 = new Customer()
            {
                CreditCardNumber = "0123456",
                Email = "*****@*****.**",
                Name = "User2"
            };

            Customer customer3 = new Customer()
            {
                CreditCardNumber = "11111",
                Email = "*****@*****.**",
                Name = "User3"
            };

            Customer customer4 = new Customer()
            {
                CreditCardNumber = "4444",
                Email = "*****@*****.**",
                Name = "User4"
            };

            Customer customer5 = new Customer()
            {
                CreditCardNumber = "5555",
                Email = "*****@*****.**",
                Name = "User5"
            };
            context.Customers.Add(customer1);
            context.Customers.Add(customer2);
            context.Customers.Add(customer3);
            context.Customers.Add(customer4);
            context.Customers.Add(customer5);

            Product product1 = new Product()
            {
                ProductName = "Mlqko",
                Price = 10.00m,
                Quantity = 1
            };

            Product product2 = new Product()
            {
                ProductName = "Qica",
                Price = 12.00m,
                Quantity = 12
            };

            Product product3 = new Product()
            {
                ProductName = "Sol",
                Price = 110.00m,
                Quantity = 1
            };

            Product product4 = new Product()
            {
                ProductName = "Qgoda",
                Price = 0.09m,
                Quantity = 11232
            };

            Product product5 = new Product()
            {
                ProductName = "Krusha",
                Price = 9.99m,
                Quantity = 1
            };

            context.Products.Add(product1);
            context.Products.Add(product2);
            context.Products.Add(product3);
            context.Products.Add(product4);
            context.Products.Add(product5);

            StoreLocation location1 = new StoreLocation()
            {
                Location = "Carefurr"
            };

            StoreLocation location2 = new StoreLocation()
            {
                Location = "Kaufland"
            };

            StoreLocation location3 = new StoreLocation()
            {
                Location = "Pazar"
            };

            StoreLocation location4 = new StoreLocation()
            {
                Location = "Triumf"
            };

            StoreLocation location5 = new StoreLocation()
            {
                Location= "Banq"
            };

            context.StoreLocations.Add(location1);
            context.StoreLocations.Add(location2);
            context.StoreLocations.Add(location3);
            context.StoreLocations.Add(location4);
            context.StoreLocations.Add(location5);


            Sale sale1 = new Sale()
            {
                Customer = customer1,
                Date = new DateTime(2017, 03, 03),
                Product = product1,
                StoreLocation = location1
            };

            Sale sale2 = new Sale()
            {
                Customer = customer1,
                Date = new DateTime(2017, 03, 03),
                Product = product2,
                StoreLocation = location1
            };

            Sale sale3 = new Sale()
            {
                Customer = customer2,
                Date = new DateTime(2016, 03, 03),
                Product = product1,
                StoreLocation = location2
            };

            Sale sale4 = new Sale()
            {
                Customer = customer2,
                Date = new DateTime(2016, 03, 03),
                Product = product2,
                StoreLocation = location2
            };

            Sale sale5 = new Sale()
            {
                Customer = customer1,
                Date = new DateTime(2016, 03, 03),
                Product = product3,
                StoreLocation = location1
            };

            context.Sales.Add(sale1);
            context.Sales.Add(sale2);
            context.Sales.Add(sale3);
            context.Sales.Add(sale4);
            context.Sales.Add(sale5);

            context.SaveChanges();
            base.Seed(context);
        }
 /// <summary>
 /// Create a new Customer object.
 /// </summary>
 /// <param name="customerId">Initial value of the CustomerId property.</param>
 /// <param name="customerName">Initial value of the CustomerName property.</param>
 /// <param name="discountGroupId">Initial value of the DiscountGroupId property.</param>
 public static Customer CreateCustomer(global::System.Int32 customerId, global::System.String customerName, global::System.Int32 discountGroupId)
 {
     Customer customer = new Customer();
     customer.CustomerId = customerId;
     customer.CustomerName = customerName;
     customer.DiscountGroupId = discountGroupId;
     return customer;
 }
Example #27
0
 public Customer FindCustomer(string usename, string password)
 {
     ConnectDB db = new ConnectDB();
     Customer customer = new Customer();
     string query = "select * from Customer where UserName like N'%" + usename + "%' and [Password] like N'%" + password + "%'";
     DataTable dt = null;
     dt = db.ReturnDataTable_NonParameter(query);
     if (dt == null) return null;
     DataRow dr = dt.Rows[0];
     customer.id = dr["ID"].ToString();
     customer.name = dr["Name"].ToString();
     customer.email = dr["Email"].ToString();
     customer.address = dr["Address"].ToString();
     customer.phoneNumber = dr["PhoneNumber"].ToString();
     customer.userName = dr["UserName"].ToString();
     customer.passWord = dr["Password"].ToString();
     customer.rule = dr["Rule"].ToString();
     return customer;
 }
Example #28
0
 partial void UpdateCustomer(Customer instance);
 public async Task<Customer> AddCustomerAsync(Customer customer)
 {
     _context.Customers.Add(customer);
     await _context.SaveChangesAsync();
     return customer;
 }
Example #30
0
 // Hàm tạo đơn hàng 
 public void createOrder(string _name,string _email,string _address,string _phonenumber)
 {
     string date = "";
     customer = new Customer(_name, _email, _address, _phonenumber);
     order = new Order(bag, customer, date);
 }
 private void OnEdit(Customer customer)
 {
     EditCustomerRequested(customer);
 }