Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人)
        {
            if (ModelState.IsValid)
            {
                db.客戶聯絡人.Add(客戶聯絡人);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(客戶聯絡人));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id,客戶名稱,統一編號,電話,傳真,地址,Email")] 客戶資料 客戶資料)
        {
            if (ModelState.IsValid)
            {
                db.客戶資料.Add(客戶資料);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(客戶資料));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "客戶名稱,contactCounts,bankCounts,Id")] VW_CustomerReport vW_CustomerReport)
        {
            if (ModelState.IsValid)
            {
                db.VW_CustomerReport.Add(vW_CustomerReport);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vW_CustomerReport));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "customerID,customerFirstName,customerLastName,customerPhoneNumber")] customer customer)
        {
            if (ModelState.IsValid)
            {
                db.customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Id,客戶Id,銀行名稱,銀行代碼,分行代碼,帳戶名稱,帳戶號碼")] 客戶銀行資訊 客戶銀行資訊)
        {
            if (ModelState.IsValid)
            {
                db.客戶銀行資訊.Add(客戶銀行資訊);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(客戶銀行資訊));
        }
Exemplo n.º 6
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "客戶名稱,銀行帳戶數量,聯絡人數量")] 客戶關聯清單 客戶關聯清單)
        {
            if (ModelState.IsValid)
            {
                db.客戶關聯清單.Add(客戶關聯清單);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(客戶關聯清單));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Id,客戶Id,銀行名稱,銀行代碼,分行代碼,帳戶名稱,帳戶號碼")] 客戶銀行資訊 客戶銀行資訊)
        {
            if (ModelState.IsValid)
            {
                db.客戶銀行資訊.Add(客戶銀行資訊);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶銀行資訊.客戶Id);
            return(View(客戶銀行資訊));
        }
Exemplo n.º 9
0
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.uid = new SelectList(db.Users, "Id", "Username", order.uid);
            return(View(order));
        }
        public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人)
        {
            if (ModelState.IsValid)
            {
                db.客戶聯絡人.Add(客戶聯絡人);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶聯絡人.客戶Id);
            return(View(客戶聯絡人));
        }
Exemplo n.º 11
0
 // 建立客戶資料
 public bool Create(tCustomer oCustomer)
 {
     try
     {
         _db.DbSetCusomter.Add(oCustomer);
         _db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public JsonResult SaveCustomer(CustomerViewModel customer)
        {
            using (var db = new CustomerEntities())
            {
                var cus = db.Customers.Find(customer.ID);
                if (cus != null)
                {
                    cus.Name    = customer.Name;
                    cus.Address = customer.Address;
                    cus.Phone   = customer.Phone;

                    if (db.SaveChanges() > 0)
                    {
                        return(Json(new { status = "success", response = cus }));
                    }
                    else
                    {
                        return(Json(new { status = "failed", reason = "could not save" }));
                    }
                }
                else
                {
                    return(Json(new { status = "failed", reason = "not found" }));
                }
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Create the customer.
 /// </summary>
 /// <param name="saveObject">The save object.</param>
 /// <returns></returns>
 public Customers CreateCustomer(Customers saveObject)
 {
     try
     {
         #region Save Customer User
         var customerToSave = _entityMapper.Map <Customers, BcTCustomer>(saveObject);
         var customerSaved  = _customerEntities.BcTCustomers.Add(customerToSave).Entity;
         _customerEntities.SaveChanges();
         #endregion
         return(_entityMapper.Map <BcTCustomer, Customers>(customerSaved));
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 14
0
        public ActionResult BatchUpdate(客戶聯絡人BatchUpdate[] items)
        {
            if (items != null && ModelState.IsValid)
            {
                foreach (var item in items)
                {
                    var cc = db.客戶聯絡人.Find(item.Id);
                    cc.職稱 = item.職稱;
                    cc.手機 = item.手機;
                    cc.電話 = item.電話;
                }
                db.SaveChanges();
                return(RedirectToAction("BatchUpdate"));
            }

            Get客戶聯絡人();
            return(View());
        }
Exemplo n.º 15
0
 public ActionResult ParcelDetails([Bind(Exclude = "ParcelID")] Parcel parcel)
 {
     if (ModelState.IsValid)
     {
         db.Parcels.Add(parcel);
         db.SaveChanges();
         return(RedirectToAction("ThankYou", new { id = parcel.CustomID }));
     }
     return(View(parcel));
 }
Exemplo n.º 16
0
        public string Add(CustomerInformation model)
        {
            CustomerEntities    db = new CustomerEntities();
            CustomerInformation cs = new CustomerInformation();

            cs.Name    = model.Name;
            cs.Surname = model.Surname;
            db.CustomerInformations.Add(cs);
            db.SaveChanges();
            return("1");
        }
Exemplo n.º 17
0
 public Customer Post(Customer customer)
 {
     using (CustomerEntities entities = new CustomerEntities())
     {
         entities.Customer.Add(new Customer()
         {
             Name = "Poopoo"
         });
         entities.SaveChanges();
         return(entities.Customer.FirstOrDefault());
     }
 }
Exemplo n.º 18
0
 public ActionResult CustomerDetails([Bind(Exclude = "CustomerID")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Customers.Add(customer);
         db.SaveChanges();
         return(RedirectToAction("ParcelDetails", "Parcel", new { id = customer.CustomerID }));
     }
     else
     {
         return(View(customer));
     }
 }
 public ActionResult Account(Customer customer)
 {
     if (ModelState.IsValid)
     {
         using (CustomerEntities cEntities = new CustomerEntities())
         {
             customer.customer_ID = Convert.ToInt32(Session["customerID"]);
             cEntities.Entry(customer).State = EntityState.Modified;
             cEntities.SaveChanges();
             return RedirectToAction("Account");
         }
     }
     return View();
 }
Exemplo n.º 20
0
        // PUT: api/Cust/5
        /// <summary>
        /// Updates the existing cutomer
        /// </summary>
        /// <param name="inputIDnumber"></param>
        /// <param name="inputFirstname"></param>
        /// <param name="inputlastname"></param>
        /// <param name="inputCell"></param>
        /// <param name="inputEmail"></param>
        /// <returns>Returns message</returns>
        public string Put(string inputIDnumber, string inputFirstname, string inputlastname, string inputCell, string inputEmail)
        {
            var cust = (from c in customerEntities.Customers where c.ID_Number == inputIDnumber select c).ToList().FirstOrDefault();

            cust.Email_Address = inputEmail;
            cust.First_Name    = inputFirstname;
            cust.Last_Name     = inputlastname;
            cust.Mobile_Number = inputCell;
            customerEntities.Customers.AddOrUpdate(cust);
            customerEntities.SaveChanges();
            return(new JavaScriptSerializer().Serialize(new
            {
                Message = "Customer Updated Successfully"
            }));
        }
Exemplo n.º 21
0
        public bool AddCustomer(string customer)
        {
            try
            {
                using (var db = new CustomerEntities())
                {
                    var newCustomer = db.Main_Dim_CustomerSet.Create();
                    newCustomer.Customer_name = customer;

                    db.Main_Dim_CustomerSet.Add(newCustomer);
                    db.SaveChanges();
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
 public ActionResult Register(Customer customer, CustomerAddress customerAddress, CustomerLogin customerLogin)
 {
     string viewChange = "";
     try
     {
         if (ModelState.IsValid)
         {
             //encrypt the password
             customerLogin.password = HashKey.GetHashKey(customerLogin.password);
             //inserting into customers table
             using (CustomerEntities cEntityy = new CustomerEntities())
             {
                 cEntityy.Customers.Add(customer);
                 cEntityy.SaveChanges();
             }
             using (CustomerAddressEntities caEntity = new CustomerAddressEntities())
             {
                 customerAddress.customer_ID = customer.customer_ID;
                 //inserting into customer address table
                 caEntity.CustomerAddresses.Add(customerAddress);
                 caEntity.SaveChanges();
             }
             using (CustomerLoginEntities clEntity = new CustomerLoginEntities())
             {
                 customerLogin.customer_ID = customer.customer_ID;
                 customerLogin.email = customer.email;
                 customerLogin.dateCreated = DateTime.Now;
                 //inserting into customer login table
                 clEntity.CustomerLogins.Add(customerLogin);
                 clEntity.SaveChanges();
                 return RedirectToAction("Index", "Customer");
             }
         }
         else
         {
             viewChange = "LoginRegister";
         }
     }
     catch(EntryPointNotFoundException ex){}
     catch (Exception ex) { viewChange = "LoginRegister"; }
     return View(viewChange);
 }
        public JsonResult AddCustomer(CustomerViewModel customer)
        {
            using (var db = new CustomerEntities())
            {
                var cust = new Customer()
                {
                    Name    = customer.Name,
                    Address = customer.Address,
                    Phone   = customer.Phone
                };

                db.Customers.Add(cust);
                if (db.SaveChanges() > 0)
                {
                    return(Json(new { status = "success", result = cust }));
                }
                else
                {
                    return(Json(new { status = "failed", reason = "could save to db" }));
                }
            }
        }
Exemplo n.º 24
0
 protected void btnAddNewCustomer_Click(object sender, EventArgs e)
 {
     try
     {
         asiakas customer = new asiakas();
         customer.astunnus  = txtID.Text;
         customer.asnimi    = txtName.Text;
         customer.yhteyshlo = txtContact.Text;
         customer.maa       = txtCountryCode.Text;
         customer.postinro  = txtPostalCode.Text;
         customer.postitmp  = txtPostOffice.Text;
         customer.ostot     = double.Parse(txtPurchases.Text);
         customer.asvuosi   = short.Parse(txtYear.Text);
         entities.asiakas.Add(customer);
         entities.SaveChanges();
         lblMessage.Text = "Customer added succesfully!";
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
 public JsonResult DeleteCustomer(int id)
 {
     using (var db = new CustomerEntities())
     {
         var cus = db.Customers.Find(id);
         if (cus != null)
         {
             db.Customers.Remove(cus);
             if (db.SaveChanges() > 0)
             {
                 return(Json(new { status = "success" }));
             }
             else
             {
                 return(Json(new { status = "failed" }));
             }
         }
         else
         {
             return(Json(new { status = "failed", reason = "not exists" }));
         }
     }
 }
Exemplo n.º 26
0
        // POST: api/Cust
        /// <summary>
        /// Posts the data that it receives from the Web App
        /// </summary>
        /// <param name="inputIDnumber"></param>
        /// <param name="inputFirstname"></param>
        /// <param name="inputlastname"></param>
        /// <param name="inputCell"></param>
        /// <param name="inputEmail"></param>
        /// <returns>Returns message</returns>
        public string Post(string inputIDnumber, string inputFirstname, string inputlastname, string inputCell, string inputEmail)
        {
            var cust = "";
            CustomerEntities customerEntities = new CustomerEntities();

            try
            {
                cust = (from c in customerEntities.Customers where c.ID_Number == inputIDnumber select c.ID_Number).FirstOrDefault();
            }
            catch (Exception e)
            {
                return(e.Message);
            }
            if (String.IsNullOrEmpty(cust))
            {
                Customer customer = new Customer();
                customer.ID_Number     = inputIDnumber;
                customer.First_Name    = inputFirstname;
                customer.Last_Name     = inputlastname;
                customer.Mobile_Number = inputCell;
                customer.Email_Address = inputEmail;
                customerEntities.Customers.Add(customer);
                customerEntities.SaveChanges();
                return(new JavaScriptSerializer().Serialize(new
                {
                    Message = "Customer Added Successfully"
                }));
            }
            else
            {
                return(new JavaScriptSerializer().Serialize(new
                {
                    Message = "Customer Already Exists"
                }));
            }
        }
Exemplo n.º 27
0
        public bool AddLogToMainTable(string ID, DateTime timestamp, string action)
        {
            try
            {
                using (var db = new CustomerEntities())
                {
                    var newlog = db.Main_Fact_LogsSet.Create();

                    newlog.UnitName = ID;
                    newlog.Timestamp = timestamp;
                    newlog.EventName = action;

                    db.Main_Fact_LogsSet.Add(newlog);
                    db.SaveChanges();

                    return true;
                }

            }
            catch (Exception ex)
            {
                return false;
            }
        }
Exemplo n.º 28
0
        public bool AddUnitToCustomerTable(string UnitID, string customer)
        {
            try
            {
                using (var dbCustomer = new CustomerEntities())
                {
                    var newBridgeUnit = dbCustomer.Main_Bridge_Customer_UnitSet.Create();
                    var newUnit = dbCustomer.Main_Dim_UnitSet.Create();
                    var cust = dbCustomer.Main_Dim_CustomerSet.Where(o => o.Customer_name.Equals(customer)).First();

                    newUnit.UnitID = UnitID;

                    newBridgeUnit.Main_Dim_UnitSet = newUnit;
                    newBridgeUnit.Main_Dim_CustomerSet = cust;

                    dbCustomer.Main_Bridge_Customer_UnitSet.Add(newBridgeUnit);
                    dbCustomer.SaveChanges();
                }

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }

            /*switch (customer)
            {
                case "RegionH":
                    try
                    {
                        using (var dbCustomer = new CustomerEntities())
                        {
                            var newBridgeUnit = dbCustomer.Main_Bridge_Customer_UnitSet.Create();
                            var newUnit = dbCustomer.Main_Dim_UnitSet.Create();
                            var cust = dbCustomer.Main_Dim_CustomerSet.Where(o => o.Customer_name.Equals(customer)).First();

                            newUnit.UnitID = UnitID;

                            newBridgeUnit.Main_Dim_UnitSet = newUnit;
                            newBridgeUnit.Main_Dim_CustomerSet = cust;

                            dbCustomer.Main_Bridge_Customer_UnitSet.Add(newBridgeUnit);
                            dbCustomer.SaveChanges();
                        }

                        return true;
                    }
                    catch (Exception ex)
                    {
                        return false;
                    }

                case "Lundbeck":
                    try
                    {
                        using (var db = new LundbeckEntities())
                        {
                            //CHANGE!!
                        }
                        return true;
                    }
                    catch (Exception ex)
                    {
                        return false;
                    }

                default:
                    return false;
            }*/
        }
Exemplo n.º 29
0
        public bool Adduser(string username, string password, string customer)
        {
            try
            {
                using (var db = new CustomerEntities())
                {
                    var newUser = db.Main_UsersSet.Create();
                    newUser.Username = username;
                    newUser.Password = password;
                    newUser.Customer = customer;

                    db.Main_UsersSet.Add(newUser);
                    db.SaveChanges();

                    return true;
                }
            }

            catch (Exception ex)
            {
                return false;
            }
        }