예제 #1
0
        public ActionResult Create([Bind(Include = "MaSP,TenSP,SoLuong,DonGia,MoTa,GiaKM,URLAnh,MaLoaiSP,MaKM")] SanPham sanPham, HttpPostedFileBase picture)
        {
            if (ModelState.IsValid)
            {
                if (!UploadImage(picture, sanPham))
                {
                    ModelState.AddModelError("", @"Hãy chọn ảnh");
                    ViewBag.MaKM     = new SelectList(db.BangKhuyenMais, "MaKM", "MaKM", sanPham.MaKM);
                    ViewBag.MaLoaiSP = new SelectList(db.LoaiSPs, "MaLoaiSP", "TenLoai", sanPham.MaLoaiSP);
                    return(View(sanPham));
                }
                sanPham.MaSP = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds.ToString();
                while (sanPham.MaSP.Length > 10)
                {
                    sanPham.MaSP = sanPham.MaSP.Substring(1, sanPham.MaSP.Length - 2);
                }
                CheckSP(sanPham);
                db.SanPhams.Add(sanPham);

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaKM     = new SelectList(db.BangKhuyenMais, "MaKM", "MaKM", sanPham.MaKM);
            ViewBag.MaLoaiSP = new SelectList(db.LoaiSPs, "MaLoaiSP", "TenLoai", sanPham.MaLoaiSP);
            return(View(sanPham));
        }
        public ActionResult CreateForNhaCC(PhieuNhap model, IEnumerable <CTPhieuNhap> ctPhieuNhaps)
        {
            try
            {
                var maPN = getMaPhieuNhap();
                model.MaPN     = maPN;
                model.NgayNhap = DateTime.Now;
                _db.PhieuNhaps.Add(model);
                if (ctPhieuNhaps.Count() <= 0)
                {
                    ModelState.AddModelError("", @"Hãy chọn sản phẩm ");
                    return(View(model));
                }
                foreach (var item in ctPhieuNhaps)
                {
                    item.MaPN = maPN;
                    var product = _db.SanPhams.Find(item.MaSP);
                    if (product != null)
                    {
                        product.SoLuong += item.SoLuong;
                    }
                }
                _db.CTPhieuNhaps.AddRange(ctPhieuNhaps);
                _db.SaveChanges();
                //return Json(true, JsonRequestBehavior.AllowGet);
                return(RedirectToAction("Index"));
            }
            catch
            {
                ViewBag.SanPhams    = _db.SanPhams.ToList();
                ViewBag.NhaCungCaps = _db.NhaCCs.ToList();

                return(View(model));
            }
        }
예제 #3
0
        public IHttpActionResult PutDepartamento(int id, Departamento departamento)
        {
            if (id != departamento.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #4
0
        public IHttpActionResult PutUser(int id, User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.User_ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutParentTask(int id, ParentTask parentTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != parentTask.Parent_ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutQualification(int id, Qualification qualification)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != qualification.Index)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #7
0
        public IHttpActionResult PutCustomer(int id, Customer customer)
        {
            if (id != customer.CustID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #8
0
        public IHttpActionResult PutLocacao(int id, Locacao locacao)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != locacao.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #9
0
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (id != product.ProductID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #10
0
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            if (id != employee.EmployeeID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #11
0
        public IHttpActionResult PutItem(int id, Item item)
        {
            if (id != item.ItemId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #12
0
        public IHttpActionResult Putdog(int id, dog dog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dog.dogsID)
            {
                return(BadRequest());
            }

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

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

            return(Ok(HttpStatusCode.NoContent));
        }
예제 #13
0
 public ActionResult Edit([Bind(Include = "AppointmentID,EmployeeID,EmployeeName,CustomerID,Address,Eircode,Start,End,Description")] servicehistory servicehistory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(servicehistory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(servicehistory));
 }
예제 #14
0
        public ActionResult Create([Bind(Include = "MaKM,TienKM,TiLeKM")] BangKhuyenMai bangKhuyenMai)
        {
            if (ModelState.IsValid)
            {
                db.BangKhuyenMais.Add(bangKhuyenMai);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bangKhuyenMai));
        }
        public ActionResult Create([Bind(Include = "MaNCC,Ten,DiaChi,SDT,Email")] NhaCC nhaCC)
        {
            if (ModelState.IsValid)
            {
                db.NhaCCs.Add(nhaCC);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nhaCC));
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "Id,Nombre,Apellido,Cedula,Foto,Direccion,Telefono,Sexo,Edad,Fecha_Nacimiento,Afiliados,Membresia,Lugar_Trabajo,Direc_Oficina,Tel_Oficina,Estatus,Fecha_Ingreso,Fecha_Salida")] Socios socios)
        {
            if (ModelState.IsValid)
            {
                db.Socios.Add(socios);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(socios));
        }
        public ActionResult Create([Bind(Include = "MaLoaiSP,TenLoai,MoTa,URLAnh")] LoaiSP loaiSP)
        {
            if (ModelState.IsValid)
            {
                db.LoaiSPs.Add(loaiSP);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(loaiSP));
        }
        public ActionResult Create([Bind(Include = "MaND,SDT,GioiTinh,Tuoi,DiaChi,UserName,Email,Pass,MaLoaiND,TenND")] NguoiDung nguoiDung)
        {
            if (ModelState.IsValid)
            {
                db.NguoiDungs.Add(nguoiDung);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaLoaiND = new SelectList(db.LoaiNDs, "MaLoaiND", "TenLoai", nguoiDung.MaLoaiND);
            return(View(nguoiDung));
        }
 public bool Insert(BangKhuyenMai entity)
 {
     if (!string.IsNullOrEmpty(entity.MaKM))
     {
         db.BangKhuyenMais.Add(entity);
         db.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public bool Insert(NhaCC entity)
 {
     if (!string.IsNullOrEmpty(entity.MaNCC))
     {
         db.NhaCCs.Add(entity);
         db.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #21
0
 public bool Insert(LoaiSP entity)
 {
     if (!string.IsNullOrEmpty(entity.MaLoaiSP))
     {
         db.LoaiSPs.Add(entity);
         db.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #22
0
 public bool Insert(SanPham entity)
 {
     if (!string.IsNullOrEmpty(entity.MaSP))
     {
         db.SanPhams.Add(entity);
         db.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #23
0
        public ActionResult Create([Bind(Include = "MaSP,TenSP,SoLuong,DonGia,MoTa,GiaKM,URLAnh,MaLoaiSP,MaKM")] SanPham sanPham)
        {
            if (ModelState.IsValid)
            {
                db.SanPhams.Add(sanPham);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaKM     = new SelectList(db.BangKhuyenMais, "MaKM", "MaKM", sanPham.MaKM);
            ViewBag.MaLoaiSP = new SelectList(db.LoaiSPs, "MaLoaiSP", "TenLoai", sanPham.MaLoaiSP);
            return(View(sanPham));
        }
        public ActionResult Create([Bind(Include = "Id,firstName,lastName,email,contact,equipmentTypeId,brandId,model,serial,issues,recepId,dateIn,techReport,techId,dateRepaired,statusId,dateCollected,jobNumber")] Jobs jobs)
        {
            if (ModelState.IsValid)
            {
                db.Jobs.Add(jobs);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.brandId         = new SelectList(db.Brand, "Id", "brandName", jobs.brandId);
            ViewBag.equipmentTypeId = new SelectList(db.equiptmentType, "Id", "equiptmentName", jobs.equipmentTypeId);
            ViewBag.statusId        = new SelectList(db.status, "Id", "statusName", jobs.statusId);
            return(View(jobs));
        }
예제 #25
0
        public ActionResult Index(UserRegister user)
        {
            UDbTable model = new UDbTable
            {
                Username = user.Username,
                Password = user.Password,
                Email    = user.Email
            };

            model.LastLogin = DateTime.Now;
            if (ModelState.IsValid)
            {
                using (DBModels db = new DBModels())
                {
                    if (db.UDbTables.Any(x => x.Username == model.Username))
                    {
                        return(View("Index"));
                    }
                    else
                    {
                        db.UDbTables.Add(model);
                        db.SaveChanges();
                    }
                }


                return(RedirectToAction("Stream", "Home", user));
            }
            return(View("Index"));
        }
        public ActionResult Create([Bind(Include = "MaLoaiSP,TenLoai,MoTa,URLAnh")] LoaiSP loaiSP)
        {
            if (ModelState.IsValid)
            {
                loaiSP.MaLoaiSP = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds.ToString();
                while (loaiSP.MaLoaiSP.Contains("."))
                {
                    loaiSP.MaLoaiSP = loaiSP.MaLoaiSP.Substring(1, loaiSP.MaLoaiSP.Length - 2);
                }
                db.LoaiSPs.Add(loaiSP);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(loaiSP));
        }
예제 #27
0
        public JsonResult GetEvents()
        {
            //Populate the calendar

            using (Models.DBModels dbModel = new DBModels()) {
                var events = dbModel.events.ToList();

                //If event date is in the past change event colour to orange
                foreach (var myevent in events)
                {
                    long systime   = long.Parse(DateTime.Now.ToString("yyyyMMddHHmmss"));
                    long starttime = long.Parse(myevent.Start.ToString("yyyyMMddHHmmss"));

                    if (systime > starttime)
                    {
                        myevent.ThemeColor = "orange";
                    }

                    dbModel.SaveChanges();
                }

                return(new JsonResult {
                    Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
        public ActionResult Create(StudentTB studentTB)
        {
            try
            {
                using (DBModels dBModels = new DBModels())
                {
                    dBModels.StudentTBs.Add(studentTB);


                    if (ModelState.IsValid)
                    {
                        dBModels.SaveChanges();
                        return(RedirectToAction("Loginpage", "Student"));
                    }
                    else
                    {
                        return(new JsonResult {
                            Data = "Student not Registered"
                        });
                    }
                }

                //return RedirectToAction("Loginpage", "Student");
            }
            catch
            {
                return(View());
            }
        }
        public void ThemLoaiSP(LoaiSP lsp)
        {
            db.LoaiSPs.Add(lsp);
            db.SaveChanges();
            //var loaisanpham = new LoaiSP()
            //{
            //    MaLoaiSP = lsp.MaLoaiSP,
            //    TenLoai = lsp.TenLoai
            //    //MoTa = lsp.MoTa,
            //    //URLAnh = lsp.URLAnh

            //};
            //db.LoaiSPs.Add(loaisanpham);
            //db.SaveChanges();
            //return loaisanpham;
        }
        public ActionResult Create([Bind(Include = "MaNCC,Ten,DiaChi,SDT,Email")] NhaCC nhaCC)
        {
            if (ModelState.IsValid)
            {
                nhaCC.MaNCC = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds.ToString();
                while (nhaCC.MaNCC.Contains("."))
                {
                    nhaCC.MaNCC = nhaCC.MaNCC.Substring(1, nhaCC.MaNCC.Length - 2);
                }
                db.NhaCCs.Add(nhaCC);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nhaCC));
        }