Exemplo n.º 1
0
        // GET: /Tuyen/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tuyenkhachhang    tuyenkhachhang    = db.Tuyenkhachhangs.Find(id);
            Tuyentheonhanvien tuyenTheoNhanVien = db.Tuyentheonhanviens.FirstOrDefault(p => p.TuyenKHID == id);

            if (tuyenTheoNhanVien != null)
            {
                ViewBag.selectedNhanVien = tuyenTheoNhanVien.NhanVienID;
                ViewBag._nhanVien        = db.Nhanviens.Where(p => p.IsDelete == false || p.IsDelete == null).ToList();
            }
            //nếu ko có thì load tất cả ra
            else
            {
                ViewBag._nhanVien = db.Nhanviens.Where(p => p.IsDelete == false || p.IsDelete == null).ToList();
            }
            if (tuyenkhachhang == null)
            {
                return(HttpNotFound());
            }
            return(View(tuyenkhachhang));
        }
Exemplo n.º 2
0
        // GET: /Tuyen/Details/5
        public ActionResult Details(int?id)
        {
            Tuyenkhachhang tuyenkhachhang         = db.Tuyenkhachhangs.Find(id);
            int            loggedInUserDepartment = getPhongBanNguoiDung();

            if (tuyenkhachhang == null || id == null)
            {
                return(HttpNotFound());
            }

            var tuyenTheoNhanVien = (from i in db.Tuyentheonhanviens
                                     join r in db.Nhanviens on i.NhanVienID equals r.NhanvienID
                                     where i.TuyenKHID == id && r.PhongbanID == loggedInUserDepartment
                                     select new
            {
                NhanVienID = i.NhanVienID,
            }).FirstOrDefault();

            if (tuyenTheoNhanVien != null)
            {
                ViewBag.nhanVien = db.Nhanviens.Where(p => p.NhanvienID == tuyenTheoNhanVien.NhanVienID).First();
            }
            //nếu ko có thì load ds nhân viên có trong hệ thống ra
            else
            {
                ViewBag.nhanVien = null;
            }

            return(View(tuyenkhachhang));
        }
Exemplo n.º 3
0
        //
        // GET: /ThuNgan/
        //hien thi ra danh sach khach hang ma hoa don có trang thai in =1(đã in)
        public ActionResult DanhSachKhachHangDaInXongHoaDon()
        {
            var hoadon = db.Hoadonnuocs.Where(p => p.Trangthaiin == true);
            List <Tuyenkhachhang> lstTuyen = new List <Tuyenkhachhang>();

            foreach (var hdnuoc in db.Hoadonnuocs.OrderBy(p => p.HoadonnuocID).ToList())
            {
                Tuyenkhachhang t = hdnuoc.Khachhang.Tuyenkhachhang;
                if (hdnuoc.Trangthaiin == true && lstTuyen.FindIndex(x => x.TuyenKHID == t.TuyenKHID) == -1)
                {
                    lstTuyen.Add(t);
                }
            }
            if (Request.QueryString["id"] == null)
            {
                ViewBag.hoadon = hoadon.ToList();
            }
            else
            {
                List <Hoadonnuoc> lstHoadon = new List <Hoadonnuoc>();
                foreach (var hdnuoc in db.Hoadonnuocs.OrderBy(p => p.HoadonnuocID).ToList())
                {
                    if (hdnuoc.Khachhang.Tuyenkhachhang.TuyenKHID == int.Parse(Request.QueryString["id"]))
                    {
                        lstHoadon.Add(hdnuoc);
                    }
                }
                ViewBag.hoadon = lstHoadon;
            }
            ViewBag.tuyen = lstTuyen;
            return(View());
        }
Exemplo n.º 4
0
        public String getTTTuyen(int TuyenKHID)
        {
            Tuyenkhachhang tuyen = _db.Tuyenkhachhangs.Find(TuyenKHID);

            if (tuyen != null)
            {
                return(tuyen.Matuyen + " - " + tuyen.Ten);
            }
            return("");
        }
Exemplo n.º 5
0
        public string getMaTuyenById(int TuyenKHID)
        {
            Tuyenkhachhang tuyen = _db.Tuyenkhachhangs.Find(TuyenKHID);

            if (tuyen != null)
            {
                return(tuyen.Matuyen);
            }
            return("");
        }
Exemplo n.º 6
0
        public String translateTuyenIDToMaTuyen(String tuyenIdsInput)
        {
            String maTuyens = "";

            String[] maTuyensAsArray = tuyenIdsInput.Split(',');
            foreach (var item in maTuyensAsArray)
            {
                int            tuyenId = Convert.ToInt32(item);
                Tuyenkhachhang tuyen   = _db.Tuyenkhachhangs.Find(tuyenId);
                if (tuyen != null)
                {
                    maTuyens += tuyen.Matuyen + ",";
                }
            }
            return(maTuyens.Trim(','));
        }
Exemplo n.º 7
0
        public ActionResult PrintFromTo(FormCollection form, int?quan, int TuyenID, int month, int year)
        {
            setPrintCircumstance((int)PrintModeEnum.PRINT_FROM_RECEIPT_TO_RECEIPT);
            int            count        = db.Lichsuhoadons.Count(p => p.TuyenKHID == TuyenID && p.ThangHoaDon == month && p.NamHoaDon == year);
            Tuyenkhachhang tuyenKH      = db.Tuyenkhachhangs.Find(TuyenID);
            int            fromSoHoaDon = String.IsNullOrEmpty(form["from"]) ? 1 : Convert.ToInt16(form["from"]);
            int            toSoHoaDon   = String.IsNullOrEmpty(form["to"]) ? count : Convert.ToInt16(form["to"]);

            updateFromReceiptToReceipt(quan, TuyenID.ToString(), month, year, fromSoHoaDon, toSoHoaDon);

            List <LichSuHoaDon> danhSachHoaDons = GetDanhSachHoaDons(TuyenID, month, year);

            if (toSoHoaDon >= danhSachHoaDons.Count)
            {
                toSoHoaDon = danhSachHoaDons.Count();
            }

            String formPrintMachine = form["printMachine"];
            Stream str = null;

            if (formPrintMachine == "LQ2190")
            {
                Factory.ReportLP2190 report = new Factory.ReportLP2190();
                str = report.generateReportPrintFromTo(fromSoHoaDon, toSoHoaDon, TuyenID, month, year, tuyenKH);
            }
            else if (formPrintMachine == "LX2170")
            {
                Factory.ReportLX2170 report = new Factory.ReportLX2170();
                str = report.generateReportPrintFromTo(fromSoHoaDon, toSoHoaDon, TuyenID, month, year, tuyenKH);
            }
            else
            {
                Factory.ReportTallyGenicom report = new Factory.ReportTallyGenicom();
                str = report.generateReportPrintFromTo(fromSoHoaDon, toSoHoaDon, TuyenID, month, year, tuyenKH);
            }

            return(File(str, "application/pdf"));
        }
Exemplo n.º 8
0
 public ActionResult Create([Bind(Include = "Matuyen,TuyenKHID,ToID,CumdancuID,Ten,Diachi,IsDelete")] Tuyenkhachhang tuyenkhachhang)
 {
     tuyenkhachhang.IsDelete = false;
     if (ModelState.IsValid)
     {
         //kiểm tra trong tuyến trước
         Tuyenkhachhang existingTuyen = db.Tuyenkhachhangs.FirstOrDefault(p => p.Matuyen == tuyenkhachhang.Matuyen && p.IsDelete == false);
         if (existingTuyen == null)
         {
             db.Tuyenkhachhangs.Add(tuyenkhachhang);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.hasTuyen = true;
         }
     }
     ViewData["nhanVien"] = db.Nhanviens.Where(p => p.IsDelete == false || p.IsDelete == null).ToList();
     ViewBag.CumdancuID   = new SelectList(db.Cumdancus.Where(p => p.IsDelete == false), "CumdancuID", "Ten");
     ViewBag.ToID         = new SelectList(db.Toes, "ToID", "Ten", tuyenkhachhang.ToID);
     return(View(tuyenkhachhang));
 }
Exemplo n.º 9
0
        public ActionResult Edit([Bind(Include = "Matuyen,TuyenKHID,ToID,CumdancuID,Ten,Diachi,IsDelete")] Tuyenkhachhang tuyenkhachhang)
        {
            HoaDonHaDongEntities _db   = new HoaDonHaDongEntities();
            Tuyenkhachhang       tuyen = _db.Tuyenkhachhangs.Find(tuyenkhachhang.TuyenKHID);

            if (ModelState.IsValid)
            {
                Tuyenkhachhang existingTuyen = db.Tuyenkhachhangs.AsNoTracking().FirstOrDefault(p => p.Matuyen == tuyenkhachhang.Matuyen && p.IsDelete == false);
                if (existingTuyen == null || tuyen.Matuyen == tuyenkhachhang.Matuyen)
                {
                    db.Tuyenkhachhangs.AsNoTracking();
                    db.Tuyenkhachhangs.Attach(tuyenkhachhang);
                    db.Entry(tuyenkhachhang).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.hasTuyen = "Mã tuyến đã tồn tại trong cơ sở dữ liệu";
                }
            }

            return(View(tuyenkhachhang));
        }
Exemplo n.º 10
0
        public Stream generateReportPrintFromTo(int fromSoHoaDon, int toSoHoaDon, int TuyenID, int month, int year, Tuyenkhachhang tuyenKH)
        {
            List <dynamic> ls = new List <dynamic>();

            for (int i = fromSoHoaDon; i <= toSoHoaDon; i++)
            {
                ControllerBase <HoaDonNuocHaDong.Models.InHoaDon.LichSuHoaDon> cb = new ControllerBase <HoaDonNuocHaDong.Models.InHoaDon.LichSuHoaDon>();
                HoaDonNuocHaDong.Models.InHoaDon.LichSuHoaDon source = cb.Query("InHoaDonFromTo",
                                                                                new SqlParameter("@d1", month),
                                                                                new SqlParameter("@d2", year),
                                                                                new SqlParameter("@d3", TuyenID),
                                                                                new SqlParameter("@matuyen", tuyenKH.Matuyen),
                                                                                new SqlParameter("@num", i)
                                                                                ).FirstOrDefault();
                ls.Add(source);
                //cập nhật trạng thái in cho hóa đơn được in từ số thứ tự (số hóa đơn) từ xx->yy
                int hoaDonID = source.HoaDonID;
                //cập nhật trạng thái in vào tất cả các hóa đơn
                printCtl.CapNhatTrangThaiIn(hoaDonID);
            }

            report.SetDataSource(ls);

            try
            {
                Stream str = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                str.Seek(0, SeekOrigin.Begin);
                return(str);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Exemplo n.º 11
0
        public Stream generateReportPrintFromToPreview(int fromSoHoaDon, int toSoHoaDon, int TuyenID, int month, int year, Tuyenkhachhang tuyenKH)
        {
            List <dynamic> ls = new List <dynamic>();

            for (int i = fromSoHoaDon; i <= toSoHoaDon; i++)
            {
                ControllerBase <HoaDonNuocHaDong.Models.InHoaDon.LichSuHoaDon> cb = new ControllerBase <HoaDonNuocHaDong.Models.InHoaDon.LichSuHoaDon>();
                HoaDonNuocHaDong.Models.InHoaDon.LichSuHoaDon hoaDon = cb.Query("InHoaDonFromTo",
                                                                                new SqlParameter("@d1", month),
                                                                                new SqlParameter("@d2", year),
                                                                                new SqlParameter("@d3", TuyenID),
                                                                                new SqlParameter("@matuyen", tuyenKH.Matuyen),
                                                                                new SqlParameter("@num", i)
                                                                                ).FirstOrDefault();
                ls.Add(hoaDon);
            }

            report.SetDataSource(ls);

            try
            {
                Stream str = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                str.Seek(0, SeekOrigin.Begin);
                return(str);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }