Esempio n. 1
0
        public void xoaChiTiet_PhieuGiao(string mahd, string masp)
        {
            CHITIETPHIEUGIAO hd = qlch.CHITIETPHIEUGIAOs.Where(d => d.MACTPHIEUGIAO == mahd && d.MASP == masp).FirstOrDefault();

            qlch.CHITIETPHIEUGIAOs.DeleteOnSubmit(hd);
            qlch.SubmitChanges();
        }
Esempio n. 2
0
        public void suaChiTiet_PhieuGiao(string mahd, string masp, int soluong, decimal thanhtien, string chuthich)
        {
            CHITIETPHIEUGIAO hd = qlch.CHITIETPHIEUGIAOs.Where(d => d.MACTPHIEUGIAO == mahd && d.MASP == masp).FirstOrDefault();

            hd.MACTPHIEUGIAO = mahd;
            hd.MASP          = masp;
            hd.SOLUONG       = soluong;
            hd.THANHTIEN     = thanhtien;
            hd.CHUTHICH      = chuthich;
            qlch.SubmitChanges();
        }
Esempio n. 3
0
        public void ThemChiTiet_PhieuGiao(string mapg, string masp, decimal dongia,
                                          int soluong, decimal thanhtien, string chuthich)
        {
            CHITIETPHIEUGIAO hd = new CHITIETPHIEUGIAO();

            hd.MACTPHIEUGIAO = mapg;
            hd.MASP          = masp;
            hd.DONGIA        = dongia;
            hd.SOLUONG       = soluong;
            hd.THANHTIEN     = thanhtien;
            hd.CHUTHICH      = chuthich;
            qlch.CHITIETPHIEUGIAOs.InsertOnSubmit(hd);
            qlch.SubmitChanges();
        }
Esempio n. 4
0
        public ActionResult phieugiao(List <PHIEUGIAO> phieugiao, FormCollection form)
        {
            if (Convert.ToInt16(form["soluong"]) < 0)
            {
                ModelState.AddModelError("", "Số lượng thiết bị giao phải là một số nguyên dương");
            }
            else
            {
                try
                {
                    DateTime ngay       = Convert.ToDateTime(form["ngaygiao"]);
                    int      soluong    = Convert.ToInt16(form["soluong"]);
                    string   mathietbi  = form["mathietbi"];
                    string   tenthietbi = form["tenthietbi"];

                    string[] key  = mathietbi.Split(',');
                    string[] name = tenthietbi.Split(',');

                    PHIEUGIAO pg = new PHIEUGIAO();
                    pg.ngaygiao       = ngay;
                    pg.daky           = 1;
                    pg.tinhtrang      = "1";
                    pg.maphongquantri = Convert.ToInt16(form["maphongquantri"]);
                    pg.madonvi        = Convert.ToInt16(form["madonvi"]);

                    db.PHIEUGIAOs.Add(pg);
                    db.SaveChanges();
                    CHITIETPHIEUGIAO ct = new CHITIETPHIEUGIAO();
                    for (int i = 0; i < key.Length; i++)
                    {
                        ct.mathietbi   = Convert.ToInt16(key[i]);
                        ct.soluong     = Convert.ToInt32(soluong);
                        ct.maphieugiao = pg.maphieugiao;
                        db.CHITIETPHIEUGIAOs.Add(ct);
                    }

                    var model11 = db.THIETBIs.Find(ct.mathietbi);
                    if (soluong > model11.soluong)
                    {
                        ModelState.AddModelError(" ", "Số lượng thiết bị giao không được lớn hơn số lượng thiết bị hiện có trong kho!!!");
                    }
                    else
                    {
                        model11.soluong -= soluong;

                        db.SaveChanges();
                        ModelState.AddModelError(" ", "Giao Thành Công!!!");
                    }
                }
                catch
                {
                    ModelState.AddModelError("", "Giao Thất Bại!!!");
                }
            }
            ViewData["maphongquantri"] = new SelectList(db.PHONGQUANTRIs, "maphongquantri", "tenphongquantri");
            ViewData["madonvi"]        = new SelectList(db.DONVIs, "madonvi", "tendonvi");
            ViewData["manhacungcap"]   = new SelectList(db.NHACUNGCAPs, "manhacungcap", "tennhacungcap");
            ViewBag.ThietBi            = db.THIETBIs.ToList();

            var model = db.PHIEUGIAOs.ToList();

            return(View("PhieuGiao", model));
        }