Пример #1
0
 //hien thi form them nguyen lieu
 public ActionResult formsuanguyenlieu(int id)
 {
     Models.NguyenLieu x = dc.NguyenLieux.Find(id);
     if (x != null)
     {
         return(View(x));
     }
     return(RedirectToAction("Lstnguyenlieu"));
 }
Пример #2
0
 //action sua thong tin nguyen lieu
 public ActionResult actsuanguyenlieu(Models.NguyenLieu nguyenlieu)
 {
     if (ModelState.IsValid)
     {
         Models.NguyenLieu x = dc.NguyenLieux.Find(nguyenlieu.nguyenlieu_id);
         if (x != null)
         {
             x.nguyenlieu_ten = nguyenlieu.nguyenlieu_ten;
             x.nguyenlieu_dvt = nguyenlieu.nguyenlieu_dvt;
             dc.SaveChanges();
             return(RedirectToAction("Lstnguyenlieu"));
         }
     }
     return(View("Lstnguyenlieu"));
 }
Пример #3
0
 public ActionResult actthemnguyenlieu(Models.NguyenLieu nguyenlieu)
 {
     Models.NguyenLieu x = dc.NguyenLieux.Find(nguyenlieu.nguyenlieu_id);
     if (x == null)
     {
         if (nguyenlieu.nguyenlieu_id == 0)
         {
             nguyenlieu.nguyenlieu_id = 1;
         }
         dc.NguyenLieux.Add(nguyenlieu);
         dc.SaveChanges();
         return(RedirectToAction("LstNguyenlieu"));
     }
     return(View("formthemnguyenlieu"));
 }
Пример #4
0
        public JsonResult GetListMaterial()
        {
            List <Models.NguyenLieu> ListMaterial = new List <Models.NguyenLieu>();
            Database  db = new Database();
            DataTable dt = db.Query("select * from NguyenLieu ;");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Models.NguyenLieu Material = new Models.NguyenLieu();
                Material.MaNguyenLieu  = dt.Rows[i]["MaNguyenLieu"].ToString();
                Material.TenNguyenLieu = dt.Rows[i]["TenNguyenLieu"].ToString();
                ListMaterial.Add(Material);
            }
            return(Json(ListMaterial));
        }
Пример #5
0
        public ActionResult actXoaNguyenLieu(int id)
        {
            Models.NguyenLieu x = dc.NguyenLieux.Find(id);
            //sqlkiemtra
            var kt           = new Models.db_totnghiepEntities();
            var ktnguyenlieu = kt.Khoes.SqlQuery("Select nguyenlieu_id from NguyenLieu where nguyenlieu_id=@id", new SqlParameter("@id", id)).FirstOrDefault();

            if (ktnguyenlieu == null)
            {
                if (x != null)
                {
                    dc.NguyenLieux.Remove(x);
                    dc.SaveChanges();
                    return(Redirect("/Admin/admin/Lstnguyenlieu"));
                }
            }
            return(Redirect("/Admin/admin/Lstnguyenlieu"));
        }
        public JsonResult MaterialList()
        {
            List <Models.NguyenLieu> MaterialList = new List <Models.NguyenLieu>();
            Database  db = new Database();
            DataTable dt = db.Query("select * from NguyenLieu ;");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Models.NguyenLieu Material = new Models.NguyenLieu();
                Material.MaNguyenLieu  = dt.Rows[i]["MaNguyenLieu"].ToString();
                Material.TenNguyenLieu = dt.Rows[i]["TenNguyenLieu"].ToString();
                Material.SoLuong       = dt.Rows[i]["SoLuong"].ToString();
                Material.GhiChu        = dt.Rows[i]["GhiChu"].ToString();
                MaterialList.Add(Material);
            }

            return(Json(MaterialList));
        }
        public void AddMaterial(Models.NguyenLieu a)
        {
            Database db = new Database();

            db.Insert("insert into NguyenLieu values (N'" + a.TenNguyenLieu + "', N'" + a.GhiChu + "'," + a.SoLuong + ");");
        }