예제 #1
0
 public static int AddUpdateCustomer(Customer ob)
 {
     int customerid = 0;
     using (ABBEntities db = new ABBEntities())
     {
         if (ob.CustomerID>0)
         {
             Customer checkifexist = db.Customers.Where(u => u.CustomerID == ob.CustomerID).FirstOrDefault();
             if (checkifexist != null)
             {
                 checkifexist.CustomerID = ob.CustomerID;
                 checkifexist.CustomerFirstName = ob.CustomerFirstName;
                 checkifexist.CustomerLastName = ob.CustomerLastName;                      
                 checkifexist.PhoneNumber = ob.PhoneNumber;
                 checkifexist.Address = ob.Address;
                 checkifexist.City = ob.City;
                 checkifexist.St = ob.St;
                 checkifexist.Zip = ob.Zip;
                 checkifexist.Country = ob.Country;
              }
         }
         else
         {
             db.Customers.Add(ob);
         }
         int saved = db.SaveChanges();
         if(saved > 0)
         {
             customerid = ob.CustomerID;
         }
     }
     return customerid;
 }
예제 #2
0
        public void AddCustomerandSaleHeader()
        {
            FFREntities ffrDb = new FFREntities();

            Customer customer = new Customer();
            customer.FirstName = "Nick";
            customer.LastName = "Olsen";
            customer.City = "Parker";
            customer.State = "CO";
            customer.Zip = "80134";
            //Need to Add Street Name and Suite Fields
            customer.Address = customer.FirstName + " " + customer.LastName + "11321 Lovage Way " + customer.City + ", " + customer.State + " " + customer.Zip;
            customer.Phone = "3037181336";
            customer.Email = "*****@*****.**";

            ffrDb.Customers.Add(customer);
            ffrDb.SaveChanges();

            SalesHeader salesHeader = new SalesHeader();

            //salesHeader.CustomerId = 1;
            salesHeader.SalesStatus = "Open";
            salesHeader.OrderSalesBalance = 50;
            salesHeader.OrderTaxAmount = 5;
            salesHeader.OrderTotal = salesHeader.OrderSalesBalance + salesHeader.OrderTaxAmount;

            ffrDb.SalesHeaders.Add(salesHeader);
            ffrDb.SaveChanges();
        }
예제 #3
0
  public void CustomerAdd()
  {
      Customer TestCust = new Customer();
      TestCust.CustomerFirstName = "Kim";
      TestCust.CustomerLastName = "Smith";
      TestCust.PhoneNumber = "3304775555";
      CustomerProvider testProvider = new CustomerProvider();
      int myID=testProvider.AddUpdateCustomer(TestCust);
      Assert.IsNotNull(myID);
 }
예제 #4
0
 public void CustomerUpdate()
 {
     Customer TestCust = new Customer();
     TestCust.CustomerID = 1;
     TestCust.CustomerFirstName = "Neal";
     TestCust.CustomerLastName = "Irwin";
     TestCust.PhoneNumber = "1234325";
     TestCust.Country = "USA";
     TestCust.St = "OH";
     CustomerProvider testProvider = new CustomerProvider();
     int myID = testProvider.AddUpdateCustomer(TestCust);
     Assert.IsNotNull(myID);
 }
예제 #5
0
        public void CreateCustomerUsingRepository()
        {
            var customerRepo = new DataRepository<Customer>();

            Customer createCustomer = new Customer();
            createCustomer.FirstName = "Jackie";
            createCustomer.LastName = "Olsen";
            createCustomer.Address = "11320 Lovage Way";
            createCustomer.City = "Parker";
            createCustomer.State = "CO";
            createCustomer.Zip = "80134";
            createCustomer.Phone = "303-949-2695";
            createCustomer.Email = "*****@*****.**";

            customerRepo.Create(createCustomer);
        }
예제 #6
0
		public void TestMethod()
		{
			//setup test data
			Customer customer = new Customer()
			{
				Depot = new Depot()
			};

			_fakeContext.AddTestData(customer);

			//call the tested method
			int result = _customerComponent.FindDepotIdForCustoemr(customer.CustomerId);

			//verify expectancies
			Assert.AreNotEqual(0, result);
			Assert.AreEqual(customer.DepotId, result);
		}
 void LoadReport()
 {
     modeReport = 0;
     lbTotal.Text = "(VND) 0";
     if (cbmCustomers.SelectedValue != null)
     {
         int customerId = (int)cbmCustomers.SelectedValue;
         if (customerId != 0)
         {
             SetupColumnOneCustomer();
             modeReport = 1;
             textForPrint = "Từ ngày " + dtpFrom.Value.ToString(BHConstant.DATE_FORMAT) + " đến ngày " + dtpTo.Value.ToString(BHConstant.DATE_FORMAT); 
             customerPrint = ((Customer)cbmCustomers.SelectedItem);
             double total = 0.0;
             CustomerLogService customerLogService = new CustomerLogService();
             customerReports = customerLogService.GetReportsOfCustomer(customerId, dtpFrom.Value, 
                 dtpTo.Value.AddDays(1).Date, ref total);
             dgwStockEntranceList.DataSource = customerReports;
             lbTotal.Text = Global.formatVNDCurrencyText(total.ToString());
         }
         else
         {
             SetupColumnAllCustomers();
             double total = 0.0;
             textForPrint = "Từ ngày " + dtpFrom.Value.ToString(BHConstant.DATE_FORMAT) + " đến ngày " + dtpTo.Value.ToString(BHConstant.DATE_FORMAT);
             CustomerLogService customerLogService = new CustomerLogService();
             customersReports = customerLogService.GetReportsOfCustomers(dtpFrom.Value, dtpTo.Value.AddDays(1).Date, ref total);
             dgwStockEntranceList.DataSource = customersReports;
             setColorRow(4);
             lbTotal.Text = Global.formatVNDCurrencyText(total.ToString());
         }
     }
     else
     {
         MessageBox.Show("Không đủ thông tin để lập báo cáo!");
     }
 }
 public void loadDataForEditCustomer(int customerId)
 {
     this.Text = "Chỉnh sửa thông tin khách hàng";
     this.btnAdd.Text = "Cập nhật";            
     CustomerService customerService = new CustomerService();
     customer = customerService.GetCustomer(customerId);
     loadSomeData();
     if (customer != null)
     {
         txtDescription.Text = customer.Description;
         txtCode.Text = customer.CustCode;
         txtName.Text = customer.CustomerName;
         txtAddress.Text = customer.Address;
         txtBankAcc.Text = customer.BankAcc;
         txtBankName.Text = customer.BankName;
         txtContactPersonPhone.Text = customer.ContactPersonPhone;
         txtContactPersonEmail.Text = customer.ContactPersonEmail;
         txtContactPersonName.Text = customer.ContactPerson;
         txtEmail.Text = customer.Email;
         txtFax.Text = customer.Fax;
         txtPhoneNumber.Text = customer.Phone;
         txtFavoriteProduct.Text = customer.FavoriteProduct;
     }
 }
 partial void DeleteCustomer(Customer instance);
 partial void UpdateCustomer(Customer instance);
 partial void InsertCustomer(Customer instance);
		private void detach_Customers(Customer entity)
		{
			this.SendPropertyChanging();
			entity.Employee = null;
		}
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (validator1.Validate() && ValidateData())
     {
         if (customer != null && customer.Id > 0)
         {
             Employee emp = null;
             int old_saler_id = (int)customer.SalerId;
             if (cmbSaler.SelectedValue != null)
             {
                 emp = salers.Single(x => x.Id == (int)cmbSaler.SelectedValue);
                 customer.Employee = emp;
             }
             if (emp == null || emp.Id != old_saler_id)
             {
                 DialogResult dl = MessageBox.Show("Chuyến nhân viên của khách hàng và đồng ý chuyển hoa hồng cho nhân viên mới?", "Thông tin!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (dl == DialogResult.Yes)
                 {
                     EmployeeLogService els = new EmployeeLogService();
                     els.MoveEmployeeLogOfCustomer(customer.Id, old_saler_id, emp.Id);
                 }
             }
             customer.Description = txtDescription.Text;
             customer.CustCode = txtCode.Text;
             customer.Address = txtAddress.Text;
             customer.BankAcc = txtBankAcc.Text;
             customer.BankName = txtBankName.Text;
             customer.ContactPersonEmail = txtContactPersonEmail.Text;
             customer.ContactPerson = txtContactPersonName.Text;
             customer.ContactPersonPhone = txtContactPersonPhone.Text;
             customer.Email = txtEmail.Text;
             customer.Fax = txtFax.Text;
             customer.Phone = txtPhoneNumber.Text;
             customer.CustomerName = txtName.Text;
             customer.FavoriteProduct = txtFavoriteProduct.Text;
             CustomerService customerService = new CustomerService();
             bool result = customerService.UpdateCustomer(customer);
             if (result)
             {
                 MessageBox.Show("Khách hàng được cập nhật thành công");
                 if (this.CallFromUserControll != null && this.CallFromUserControll is CustomerList)
                 {
                     ((CustomerList)this.CallFromUserControll).loadCustomerList();
                 }
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             customer = new Customer
             {
                 Description = txtDescription.Text,
                 CustCode = txtCode.Text,
                 Address = txtAddress.Text,
                 BankAcc = txtBankAcc.Text,
                 BankName = txtBankName.Text,
                 ContactPerson = txtContactPersonName.Text,
                 ContactPersonEmail = txtContactPersonEmail.Text,
                 ContactPersonPhone = txtContactPersonPhone.Text,
                 Email = txtEmail.Text,
                 Fax = txtFax.Text,
                 Phone = txtPhoneNumber.Text,
                 CustomerName = txtName.Text,
                 SalerId = cmbSaler.SelectedValue != null ? (int?)cmbSaler.SelectedValue : (int?)null,
                 FavoriteProduct = txtFavoriteProduct.Text
             };
             CustomerService customerService = new CustomerService();
             bool result = customerService.AddCustomer(customer);
             if (result)
             {
                 MessageBox.Show("Khách hàng được tạo thành công");
                 if (this.CallFromUserControll != null && this.CallFromUserControll is CustomerList)
                 {
                     ((CustomerList)this.CallFromUserControll).loadCustomerList();
                 }
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
         preventClosing = true;
 }
예제 #14
0
 public static int AddUpdateCustomer(Customer ob)
 {
     return CustomerProvider.AddUpdateCustomer(ob);
 }
 /// <summary>
 /// Create a new Customer object.
 /// </summary>
 /// <param name="custId">Initial value of the CustId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="custCode">Initial value of the CustCode property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="phone">Initial value of the Phone property.</param>
 public static Customer CreateCustomer(global::System.Int32 custId, global::System.String name, global::System.String custCode, global::System.String address, global::System.String phone)
 {
     Customer customer = new Customer();
     customer.CustId = custId;
     customer.Name = name;
     customer.CustCode = custCode;
     customer.Address = address;
     customer.Phone = phone;
     return customer;
 }
 /// <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);
 }