Example #1
0
 public bool InsertCustomer(mContact pContact)
 {
     try
     {
         tbl_customer vContact = new tbl_customer();
         var          query    = from b in Db.tbl_customer
                                 orderby b.user_id descending
                                 select b;
         vContact = query.FirstOrDefault();
         tbl_customer n = new tbl_customer();
         n.user_email   = pContact.user_email;
         n.user_name    = pContact.user_name;
         n.user_subject = pContact.user_subject;
         n.user_text    = pContact.user_text;
         n.user_phone   = pContact.user_phone;
         n.user_id      = vContact.user_id + 1;
         n.user_date    = DateTime.Now.Date.ToString();
         Db.tbl_customer.Add(n);
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #2
0
        public ActionResult Login(FormCollection collection, tbl_customer cus)
        {
            var username = collection["username"];
            var password = collection["password"];

            //if (string.IsNullOrEmpty(username))
            //{
            //    ViewData["loi1"] = "Không Được Bỏ Trống Username";
            //}else if (string.IsNullOrEmpty(password))
            //{
            //    ViewData["loi2"] = "Không Được Bỏ Trống Password";
            //}
            //else
            //{
            cus = data.tbl_customers.SingleOrDefault(c => (c.username_customer == username ||
                                                           c.email_customer == username) &&
                                                     c.password_customer == password);
            if (cus == null)
            {
                //ViewBag.Thongbao = "Tài Khoản Hoặc Mật Khẩu Không Chính Xác !";
            }
            else
            {
                Session["customer"]    = cus;
                Session["id_customer"] = cus.id_customer;
                return(RedirectToAction("Index", "BugStore"));
            }



            return(View());
            //}
        }
        public ActionResult UpdateCustomer(tbl_customer custUpdate)
        {
            db.Database.ExecuteSqlCommand("UPDATE cmps411.tbl_customer SET customerCode={0},name={1},address={2}, city={3}, state={4}, zipCode={5} WHERE id={6}",
                                          custUpdate.customerCode, custUpdate.name, custUpdate.address, custUpdate.city, custUpdate.state, custUpdate.zipCode, custUpdate.id);

            return(RedirectToAction("Index"));
        }
Example #4
0
        public IHttpActionResult Posttbl_customer(tbl_customer tbl_customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tbl_customer.Add(tbl_customer);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (tbl_customerExists(tbl_customer.idCard))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = tbl_customer.idCard }, tbl_customer));
        }
Example #5
0
        public async Task <bool> UpdateCustomer(tbl_customer model)
        {
            try
            {
                using (var uow = _unitOfWorkFactory.Create())
                {
                    var customer = await FindByIdCustomer(model.autonum);

                    if (customer != null)
                    {
                        uow.CustomerRepository.Update(model);
                        await uow.SaveChangesAsync();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #6
0
        public IHttpActionResult Puttbl_customer(string id, tbl_customer tbl_customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbl_customer.idCard)
            {
                return(BadRequest());
            }

            db.Entry(tbl_customer).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tbl_customerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #7
0
        public async Task <bool> SaveCustomer(tbl_customer model)
        {
            try
            {
                using (var uow = _unitOfWorkFactory.Create())
                {
                    var customer = await FindByFirstnameLastnameCustomer(model.first_name, model.last_name);

                    if (customer == null)
                    {
                        uow.CustomerRepository.Insert(model);
                        await uow.SaveChangesAsync();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #8
0
        public async Task <JsonResult> SaveCustomer(tbl_customer list)
        {
            try
            {
                tbl_customer model = null;

                bool   success = false;
                string message = "";

                if (string.IsNullOrEmpty(list.autonum.ToString()) || list.autonum.ToString() == "0")
                {
                    model             = new tbl_customer();
                    model.first_name  = list.first_name;
                    model.last_name   = list.last_name;
                    model.middle_name = list.middle_name;
                    model.st_address  = list.st_address;
                    model.mobile_no   = list.mobile_no;

                    var result = await _customerService.SaveCustomer(model);

                    success = result;
                    if (result)
                    {
                        message = "Successfully saved.";
                    }
                    else
                    {
                        message = "Error saving data. Duplicate entry.";
                    }
                }
                else
                {
                    model = await _customerService.FindByIdCustomer(list.autonum);

                    model.first_name  = list.first_name;
                    model.last_name   = list.last_name;
                    model.middle_name = list.middle_name;
                    model.st_address  = list.st_address;
                    model.mobile_no   = list.mobile_no;

                    var result = await _customerService.UpdateCustomer(model);

                    success = result;
                    if (result)
                    {
                        message = "Successfully updated.";
                    }
                    else
                    {
                        message = "Error saving data. Please contact administrator.";
                    }
                }

                return(Json(new { success = success, message = message }));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public int DeleteCustomer(int orderid)
        {
            tbl_customer tc = _db.tbl_customer.Where(c => c.CId == orderid).FirstOrDefault();

            _db.tbl_customer.Remove(tc);
            return(_db.SaveChanges());
        }
Example #10
0
        public void btnComplete_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("You clicked Complete Button");
            int id = Convert.ToInt32(lblId.Text);

            CustomerDetails cd1 = new CustomerDetails();
            tbl_customer    cd  = _db.tbl_customer.Where(c => c.CId == id).FirstOrDefault();

            cd1.CId          = cd.CId;
            cd1.OrderNo      = cd.OrderNo;
            cd1.CustomerName = cd.CustomerName;
            cd1.CustomerType = cd.CustomerType;
            cd1.WaiterId     = cd.WaiterId;
            cd1.TableId      = cd.TableId;
            cd1.Completed    = true.ToString();
            cd1.Total        = cd.Total;
            cd1.OrderDate    = cd.OrderDate;
            int i = blc.UpdateCustomer(cd1);


            if (i > 0)
            {
                OngoingOrder od = new OngoingOrder();
                MessageBox.Show("Order Completed Successfully", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                od.populateOngoingOrder();
            }
        }
        public ActionResult DeleteCustomer(tbl_customer custDelete)
        {
            tbl_customer tbl_customer = db.tbl_customer.Find(custDelete.id);

            db.tbl_customer.Remove(tbl_customer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult AddCustomer(tbl_customer customerAdd)
        {
            db.Database.ExecuteSqlCommand("Insert into cmps411.tbl_customer Values({0},{1},{2}, {3}, {4}, {5})",
                                          customerAdd.customerCode, customerAdd.name, customerAdd.address, customerAdd.city, customerAdd.state, customerAdd.zipCode);

            return(new EmptyResult());
            //return RedirectToAction("SalesLanding", "Index");
        }
Example #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            tbl_customer tbl_customer = db.tbl_customer.Find(id);

            db.tbl_customer.Remove(tbl_customer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #14
0
 public void EditTheCustomer(tbl_customer cust)
 {
     using (var db = new KnockAroundDBContext())
     {
         //var editcust = db.Customer.Add(cust);
         db.Entry(cust).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #15
0
 public tbl_customer CreateNewCustomer(tbl_customer cust)
 {
     using (var db = new KnockAroundDBContext())
     {
         var newcust = db.Customer.Add(cust);
         db.SaveChanges();
         return(newcust);
     }
 }
        public ActionResult Edit(tbl_customer customerRow)
        {
            if (ModelState.IsValid)
            {
                dbmodel.EditTheCustomer(customerRow);
                return(RedirectToAction("Customer"));
            }

            return(View(customerRow));
        }
        public ActionResult CreateCustomer(tbl_customer customerRow)
        {
            if (ModelState.IsValid)
            {
                dbmodel.CreateNewCustomer(customerRow);
                return(RedirectToAction("customerRow"));
            }

            return(View(customerRow));
        }
Example #18
0
 public ActionResult Edit([Bind(Include = "customer_id,applicant_name,email,present_address,parmanent_address,mobile_number,father_name,mother_name,user_type,photo,birth_date,religion,year")] tbl_customer tbl_customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_customer));
 }
Example #19
0
 public ActionResult Edit([Bind(Include = "customerCode,name,address,city,state,zipCode,id")] tbl_customer tbl_customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_customer));
 }
Example #20
0
 public ActionResult Put([FromBody] tbl_customer entity)
 {
     if (_customerService.UpdateCustomer(entity))
     {
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
Example #21
0
        public IHttpActionResult Gettbl_customer(string id)
        {
            tbl_customer tbl_customer = db.tbl_customer.Find(id);

            if (tbl_customer == null)
            {
                return(NotFound());
            }

            return(Ok(tbl_customer));
        }
Example #22
0
        public ActionResult Create([Bind(Include = "customerCode,name,address,city,state,zipCode,id")] tbl_customer tbl_customer)
        {
            if (ModelState.IsValid)
            {
                db.tbl_customer.Add(tbl_customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_customer));
        }
        public ActionResult CustomerDetail(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            tbl_customer custdetail = dbmodel.CustomerDetails(id);

            return(View(custdetail));
        }
 public bool RegisterCustomer(tbl_customer entity)
 {
     try
     {
         _context.tbl_customer.Add(entity);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #25
0
        public IHttpActionResult Deletetbl_customer(string id)
        {
            tbl_customer tbl_customer = db.tbl_customer.Find(id);

            if (tbl_customer == null)
            {
                return(NotFound());
            }

            db.tbl_customer.Remove(tbl_customer);
            db.SaveChanges();

            return(Ok(tbl_customer));
        }
Example #26
0
        // GET: /Customer/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_customer tbl_customer = db.tbl_customer.Find(id);

            if (tbl_customer == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_customer));
        }
        public int AddCustomer(CustomerDetails cd)
        {
            tbl_customer tc = new tbl_customer();

            tc.OrderNo      = cd.OrderNo;
            tc.CustomerName = cd.CustomerName;
            tc.CustomerType = cd.CustomerType;
            tc.WaiterId     = cd.WaiterId;
            tc.TableId      = cd.TableId;
            tc.Completed    = Convert.ToBoolean(cd.Completed);
            tc.Total        = cd.Total;
            tc.OrderDate    = cd.OrderDate;
            _db.tbl_customer.Add(tc);
            return(_db.SaveChanges());
        }
        public int UpdateCustomer(CustomerDetails cd)
        {
            tbl_customer tc = _db.tbl_customer.Where(c => c.CId == cd.CId).FirstOrDefault();

            //tc.CId = cd.CId;
            tc.OrderNo      = cd.OrderNo;
            tc.CustomerName = cd.CustomerName;
            tc.CustomerType = cd.CustomerType;
            tc.WaiterId     = cd.WaiterId;
            tc.TableId      = cd.TableId;
            tc.Completed    = Convert.ToBoolean(cd.Completed);
            tc.Total        = cd.Total;
            tc.OrderDate    = cd.OrderDate;
            return(_db.SaveChanges());
        }
 public bool UpdateCustomer(tbl_customer entity)
 {
     try
     {
         var data = _context.tbl_customer.Where(x => x.idcustomer == entity.idcustomer).FirstOrDefault();
         data.businessname = entity.businessname;
         data.ruc          = entity.ruc;
         data.contactname  = entity.contactname;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public ActionResult UpdateCustomer(tbl_customer custUpdate)
        {
            using (allpax_sale_minerEntities entities = new allpax_sale_minerEntities())
            {
                tbl_customer updatedCustomer = (from c in entities.tbl_customer
                                                where c.id == custUpdate.id
                                                select c).FirstOrDefault();
                updatedCustomer.customerCode = custUpdate.customerCode;
                updatedCustomer.name         = custUpdate.name;
                updatedCustomer.address      = custUpdate.address;
                updatedCustomer.city         = custUpdate.city;
                updatedCustomer.state        = custUpdate.state;
                updatedCustomer.zipCode      = custUpdate.zipCode;

                entities.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }