Пример #1
0
        public ActionResult Create([Bind(Include = "Id,客戶名稱,統一編號,電話,傳真,地址,Email")] CustomerData customerData)
        {
            if (ModelState.IsValid)
            {
                db.CustomerData.Add(customerData);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customerData));
        }
        public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] CustomerContact customerContact)
        {
            if (ModelState.IsValid)
            {
                db.CustomerContact.Add(customerContact);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.客戶Id = new SelectList(db.CustomerData, "Id", "客戶名稱", customerContact.客戶Id);
            return(View(customerContact));
        }
        public ActionResult Create([Bind(Include = "Id,客戶Id,銀行名稱,銀行代碼,分行代碼,帳戶名稱,帳戶號碼")] CustomerBankInfo customerBankInfo)
        {
            if (ModelState.IsValid)
            {
                db.CustomerBankInfo.Add(customerBankInfo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.客戶Id = new SelectList(db.CustomerData, "Id", "客戶名稱", customerBankInfo.客戶Id);
            return(View(customerBankInfo));
        }
Пример #4
0
        public Customer InsertCustomer(Customer _customer)
        {
            using (customerEntities entities = new customerEntities())
            {
                entities.Customers.Add(_customer);
                entities.SaveChanges();
            }

            return(_customer);
        }
Пример #5
0
 public void DeleteCustomer(Customer _customer)
 {
     using (customerEntities entities = new customerEntities())
     {
         Customer customer = (from c in entities.Customers
                              where c.CustomerId == _customer.CustomerId
                              select c).FirstOrDefault();
         entities.Customers.Remove(customer);
         entities.SaveChanges();
     }
 }
Пример #6
0
        public bool UpdateCustomer(Customer _customer)
        {
            using (customerEntities entities = new customerEntities())
            {
                Customer updatedCustomer = (from c in entities.Customers
                                            where c.CustomerId == _customer.CustomerId
                                            select c).FirstOrDefault();
                updatedCustomer.Name    = _customer.Name;
                updatedCustomer.Country = _customer.Country;
                entities.SaveChanges();
            }

            return(true);
        }