Example #1
0
        public ActionResult kham(int id, string [] dsthuoc, string [] soluong, string [] lieudung, string ketquakham)
        {
            ServiceReference1.toathuocEntity t = new ServiceReference1.toathuocEntity();

            t.KetQuaKhamBenh = ketquakham;
            t.MaPhieuKham    = id;
            ur.AddToaThuoc(t);
            var a = ur.getthelasttoa();

            if (dsthuoc == null)
            {
                ur.trangthaiphieu(id);
                return(RedirectToAction("Index"));
            }
            for (int i = 0; i < dsthuoc.Length; i++)
            {
                for (int j = 0; j < dsthuoc.Length; j++)
                {
                    if (dsthuoc[i] == dsthuoc[j] && i != j)
                    {
                        TempData["trung"] = "Thêm không đcược vì trùng mã thuốc";
                        return(RedirectToAction("kham/" + id.ToString()));
                    }
                }
                ViewBag.trung = "";
                ServiceReference1.chitiettoathuocEntity ct = new ServiceReference1.chitiettoathuocEntity();
                ct.LieuDung   = lieudung[i];
                ct.MaThuoc    = dsthuoc[i];
                ct.SoLuong    = float.Parse(soluong[i]);
                ct.MaToaThuoc = (Int32)a;
                ur.AddChiTietToaThuoc(ct);
            }
            ur.trangthaiphieu(id);
            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult Edit(int id, string[] dsthuoc, string[] soluong, string[] lieudung, string ketquakham)
        {
            ServiceReference1.toathuocEntity t = new ServiceReference1.toathuocEntity();
            var a = ur.getthelasttoabyid(id);

            t.MaToaThuoc     = a;
            t.KetQuaKhamBenh = ketquakham;
            if (ModelState.IsValid)
            {
                ur.Updatetoathuoc(t);
                ur.Deletechitiettoathuoc(a);
                if (dsthuoc == null)
                {
                    return(RedirectToAction("Index"));
                }
                for (int i = 0; i < dsthuoc.Length; i++)
                {
                    ServiceReference1.chitiettoathuocEntity ct = new ServiceReference1.chitiettoathuocEntity();
                    ct.LieuDung   = lieudung[i];
                    ct.MaThuoc    = dsthuoc[i];
                    ct.SoLuong    = float.Parse(soluong[i]);
                    ct.MaToaThuoc = (Int32)a;
                    ur.AddChiTietToaThuoc(ct);
                }
                return(RedirectToAction("Index"));
            }
            return(View());
        }