public void Create(Customer newCustomer)
        {
            // Call the DAL to create a new record.
            CustomerDAL customerDAL = new CustomerDAL();

            customerDAL.Create(newCustomer);
        }
예제 #2
0
        public int Create(User user)
        {
            var customerDAL = new CustomerDAL();
            var result      = customerDAL.Create(user);

            return(result);
        }
예제 #3
0
        public int Create(Person customer)
        {
            byte[] hashedBytes    = md5.ComputeHash(Encoding.ASCII.GetBytes(customer.Password));
            string hashedPassword = Encoding.ASCII.GetString(hashedBytes);

            customer.Password = hashedPassword;

            if (CustomerDAL.GetByEmail(customer.Email) != null)
            {
                return(-1);
            }

            return(CustomerDAL.Create(customer));
        }
예제 #4
0
        public ActionResult Index(CustomerViewModel model)
        {
            if (ModelState.IsValid)
            {
                Customer customer = new Customer();
                customer.CustomerName    = model.CustomerName;
                customer.CustomerAddress = model.CustomerAddress;
                customer.CustomerPhone   = Convert.ToInt32(model.CustomerPhone);
                customer.TinNumber       = Convert.ToInt32(model.TinNumber);
                customer.tax.TaxId       = model.TaxId;
                customer.CreatedBy       = "Admin";
                customer.CreatedOn       = DateTime.Now;

                customerDAL.Create(customer);
                TempData["SuccessMsg"] = "Customer Created Successfully";
                return(RedirectToAction("Index"));
            }

            var lstTax = taxDAL.ReadAllTaxes();

            model.lstTax = new List <TaxViewModel>();
            model.lstTax = lstTax.ConvertAll(x => new TaxViewModel
            {
                TaxId   = x.TaxId,
                TaxName = x.TaxName,
                Value   = x.Value
            });

            var lst = customerDAL.ReadAllCustomer();

            model.Customers = new List <CustomerViewModel>();
            model.Customers = lst.ConvertAll(x => new CustomerViewModel
            {
                CustomerId      = x.CustomerId,
                CustomerName    = x.CustomerName,
                CustomerAddress = x.CustomerAddress,
                CustomerPhone   = x.CustomerPhone,
                TinNumber       = x.TinNumber,
                TaxId           = x.tax.TaxId,
                TaxName         = x.tax.TaxName,
                TaxValue        = x.tax.Value
            });

            model.IsEdit = false;

            return(View(model));
        }
예제 #5
0
        public Customer Create(String firstName, String lastName, String custAddress, String phoneNumber)
        {
            try
            {
                CustomerDAL custDal = new CustomerDAL();
                Customer    newCust = custDal.Create(new Customer()
                {
                    FirstName = firstName, LastName = lastName, Address = custAddress, PhoneNumber = phoneNumber
                });

                return(newCust);
            }
            catch (NewCustomerException)
            {
                throw;
            }
        }
예제 #6
0
 public void Create()
 {
     try
     {
         newCustomer.Id = CustomerDAL.customerList.Count + 101;
         Console.Write("Enter the your First name: ");
         newCustomer.Firstname = Console.ReadLine();
         Console.Write("Enter the your Last name: ");
         newCustomer.Lastname = Console.ReadLine();
         DAL.Create(newCustomer);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
     }
 }
 public string Create(string name, int identity, string job, string position, string address, string email)
 {
     customer_dal.setCustomer(name, identity, job, position, address, email);
     if (name == "" || identity.ToString() == "" || job == "" || position == "" || address == "" || email == "")
     {
         return("Vui lòng nhập thông tin khách hàng");
     }
     else if (!checkExistCustomer())
     {
         customer_dal.Create();
         return("Thêm khách hàng thành công !");
     }
     else
     {
         return("Thông tin khách hàng bị trùng");
     }
 }
예제 #8
0
 public ICustomer Create(string id, string name, string sex, string phone, string address)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             ICustomer instance = CustomerDAL.Create(cmd, id, name, sex, phone, address);
             cmd.Commit();
             return(instance);
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建客户信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
예제 #9
0
 public void Create(string name, int identity, string job, string position, string address)
 {
     customer_dal.setCustomer(name, identity, job, position, address);
     customer_dal.Create();
 }
예제 #10
0
        public string Create(Customer newCustomer)
        {
            CustomerDAL customerDAL = new CustomerDAL();

            return(customerDAL.Create(newCustomer));
        }