public ActionResult ch_ThietLapThongSoChung(FormCollection f, HttpPostedFileBase fileUpload) { if (xulyChung.duocCapNhat(idOfPage, "7")) { string ndthongBao = ""; int kqLuu = 0; cauHinh chSua = new cauHinh(); qlCaPheEntities db = new qlCaPheEntities(); try { chSua = db.cauHinhs.First(); this.doDuLieuLenView(chSua); this.layDuLieuTuView(chSua, f, fileUpload); db.Entry(chSua).State = System.Data.Entity.EntityState.Modified; kqLuu = db.SaveChanges(); if (kqLuu > 0) { ndthongBao = "Cấu hình website thành công"; this.resetDuLieu(); xulyChung.ghiNhatKyDtb(4, ndthongBao); } } catch (Exception ex) { ndthongBao = ex.Message; xulyFile.ghiLoi("Class: CauHinhController - Function: ch_ThietLapThongSoChung_Post", ex.Message); this.resetDuLieu(); } ViewBag.ThongBao = createHTML.taoThongBaoLuu(ndthongBao); this.doDuLieuLenView(chSua); } return(View()); }
/// <summary> /// Hàm tạo giao diện trang cấu hình /// </summary> /// <returns>Object chứa thuộc tính cấu hình</returns> public ActionResult ThongTinLienHe() { cauHinh ch = new cauHinh(); try { ch = new qlCaPheEntities().cauHinhs.First(); if (ch != null) { //-----Gán dữ liệu vị trí quán cho bản đồ string data = "\"Id\": 1, \"tenQuan\": \"" + xulyDuLieu.traVeKyTuGoc(ch.tenQuan) + "\", \"diaChi\": \"" + xulyDuLieu.traVeKyTuGoc(ch.diaChi) + "\", \"sdt\": \"" + xulyDuLieu.traVeKyTuGoc(ch.hotLine) + "\", \"GeoLong\": \"" + xulyDuLieu.traVeKyTuGoc(ch.kinhDo) + "\", \"GeoLat\": \"" + xulyDuLieu.traVeKyTuGoc(ch.viDo) + "\""; //-----Thêm div chi tiết vị trí khi nhấn vào marker trên bản đồ string content = "content: \"<div class='infoDiv'><h2>\" + item.tenQuan + \"</h2>\" + \"<div><h4>Địa chỉ: \" + item.diaChi + \"</h4><h4>Điện thoại: \" + item.sdt + \"</h4></div></div>\"\n"; //-----Nhúng script chứa API key bản đồ ViewBag.ScriptAPI = createScriptAjax.taoScriptGoogleMapAPIKey(); //-----Nhúng script bản đồ vào giao diện ViewBag.ScriptMap = createScriptAjax.taoScriptNhungBanDo(xulyDuLieu.traVeKyTuGoc(ch.kinhDo), xulyDuLieu.traVeKyTuGoc(ch.viDo), data, content); return(View(ch)); } } catch (Exception ex) { xulyFile.ghiLoi("Class: PublicPageController - Function: DanhSachBaiViet", ex.Message); return(RedirectToAction("ServerError", "Home")); } return(RedirectToAction("PageNotFound")); }
/// <summary> /// Hàm tạo bill thanh toán cần in /// </summary> /// <param name="hoaDon">Hóa đơn cần hiển thị thông tin</param> /// <param name="cauHinh">Thông tin cấu hình của quán</param> /// <param name="tienMat">Số tiền khách đưa</param> /// <param name="tienTra">Số tiền trả lại cho khách</param> /// <returns></returns> private string scriptTaoHoaDon(hoaDonOrder hoaDon, cauHinh cauHinh, long tienMat, long tienTra) { string kq = ""; kq += " <div class=\"row text-center\">"; kq += " <h4>" + xulyDuLieu.traVeKyTuGoc(cauHinh.tenQuan) + "</h4>"; kq += " <label><i>Địa chỉ: " + xulyDuLieu.traVeKyTuGoc(cauHinh.diaChi) + "</i></label>"; kq += " <label><i>ĐT: " + xulyDuLieu.traVeKyTuGoc(cauHinh.hotLine) + "</i></label><br/>"; kq += " <label>*********************</label>"; kq += " </div>"; kq += " <div class=\"row\">"; kq += " <h4 class=\"text-center\">HÓA ĐƠN THANH TOÁN</h4>"; kq += " <p>Số TT: " + hoaDon.maHoaDon.ToString() + "</p>"; kq += " <p><b>Bàn: " + xulyDuLieu.traVeKyTuGoc(hoaDon.BanChoNgoi.tenBan) + "</b> - Ngày: " + hoaDon.ngayLap.ToString() + "</p>"; kq += " </div>"; kq += " <div class=\"row\">"; kq += " <table>"; kq += " <thead>"; kq += " <tr>"; kq += " <th width=\"40%\">Tên hàng</th>"; kq += " <th width=\"20%\">Đơn giá</th>"; kq += " <th width=\"20%\">T.Tiền</th>"; kq += " </tr>"; kq += " </thead>"; kq += " <tbody>"; foreach (ctHoaDonOrder ct in hoaDon.ctHoaDonOrders.ToList()) { kq += " <tr>"; kq += " <td>" + xulyDuLieu.traVeKyTuGoc(ct.sanPham.tenSanPham) + " (x" + ct.soLuong.ToString() + ")</td>"; kq += " <td>" + xulyDuLieu.doiVND(ct.donGia) + "</td>"; kq += " <td>" + (ct.soLuong * ct.donGia).ToString() + "</td>"; kq += " </tr>"; } kq += " </tbody>"; kq += " </table>"; kq += " </div>"; kq += " <br/>"; kq += " <div class=\"font-16 bold\">"; kq += " <label>T.Cộng:</label>"; kq += " <label class=\"pull-right\">" + xulyDuLieu.doiVND(hoaDon.tongTien) + "</label>"; kq += " </div>"; kq += " <div class=\"font-18 bold\">"; kq += " <label>Tạm tính:</label>"; kq += " <label class=\"pull-right\">" + xulyDuLieu.doiVND(hoaDon.tamTinh) + "</label>"; kq += " </div>"; kq += " <div class=\"font-14 bold\">"; kq += " <label>Nhận tiền mặt:</label>"; kq += " <label class=\"pull-right\">" + tienMat + "</label>"; kq += " </div>"; kq += " <div class=\"font-14 bold\">"; kq += " <label>Tiền trả:</label>"; kq += " <label class=\"pull-right\">" + tienTra + "</label>"; kq += " </div>"; kq += " <div class=\"font-11 text-center\">"; kq += " <label>Cám ơn quý khách - hẹn gặp lại !!!</label>"; kq += " </div>"; return(kq); }
/// <summary> /// Hàm được Ajax gọi thực thi lấy danh sách các nguyên liệu cần kiểm và hiển thị lên modal /// </summary> /// <returns>Chuỗi html tạo nên content của modal</returns> public string AjaxLayDanhSachNguyenLieuCanKiem() { string kq = ""; try { qlCaPheEntities db = new qlCaPheEntities(); cauHinh cauHinh = db.cauHinhs.First(); kq += " <div class=\"row text-center\">"; kq += " <h4>" + xulyDuLieu.traVeKyTuGoc(cauHinh.tenQuan) + "</h4><label><i>Địa chỉ: " + xulyDuLieu.traVeKyTuGoc(cauHinh.diaChi) + "</i></label><label><i>ĐT: 0283182333</i></label><br><label>*********************</label>"; kq += " </div>"; kq += " <div class=\"row\">"; kq += " <h4 class=\"text-center\">DANH SÁCH NGUYÊN LIỆU CẦN KIỂM KÊ</h4><b class=\"pull-right\">Ngày " + DateTime.Now.ToString() + "</b>"; kq += " </div>"; kq += " <div class=\"row\">"; kq += " <div class=\"col-lg-12 col-md-12 table-responsive\">"; kq += " <table class=\"table table-bordered\">"; kq += " <thead>"; kq += " <tr><th width=\"5%\">#</th><th width=\"25%\">Nguyên liệu</th><th width=\"15%\">Số lượng</th><th width=\"15%\">Đơn vị tính</th><th width=\"25%\">Nguyên nhân hao hụt</th><th width=\"15%\">Ghi chú</th></tr>"; kq += " </thead>"; kq += " <tbody>"; int index = 1; //---------Lấy danh sách các nguyên liệu cần kiểm kho. Có trong nhập kho trong 1 tháng trước foreach (ctTonKho item in new bTonKho().layDanhSachTon()) { kq += " <tr>"; kq += " <td>" + index.ToString() + "</td>"; kq += " <td>" + xulyDuLieu.traVeKyTuGoc(item.nguyenLieu.tenNguyenLieu) + "</td>"; kq += " <td></td>"; kq += " <td>" + xulyDuLieu.traVeKyTuGoc(item.nguyenLieu.donViPhaChe) + "</td>"; kq += " <td></td>"; kq += " <td></td>"; kq += " </tr>"; index++; } kq += " </tbody>"; kq += " </table>"; kq += " </div>"; kq += " </div>"; kq += " <br>"; kq += " <div class=\"row\">"; taiKhoan tkLogin = (taiKhoan)Session["login"]; kq += " <div class=\"pull-right\"><b>Người kiểm</b><br /><br /><br /><b>" + xulyDuLieu.traVeKyTuGoc(tkLogin.thanhVien.hoTV) + " " + xulyDuLieu.traVeKyTuGoc(tkLogin.thanhVien.tenTV) + "</b>"; kq += " </div>"; kq += " </div>"; xulyChung.ghiNhatKyDtb(5, "Nguyên liệu tồn kho ngày \"" + DateTime.Now.ToString() + " \""); } catch (Exception ex) { xulyFile.ghiLoi("Class: TonKhoController - Function: AjaxLayDanhSachNguyenLieuCanKiem", ex.Message); } return kq; }
/// <summary> /// Hàm tạo vùng giao diện footer /// </summary> /// <returns></returns> public ActionResult Part_Footer() { cauHinh cauHinh = new cauHinh(); try { cauHinh = new qlCaPheEntities().cauHinhs.First(); } catch (Exception ex) { xulyFile.ghiLoi("Class: PublicPageController - Function: Part_Footer", ex.Message); Response.Redirect(xulyChung.layTenMien() + "Home/ServerError"); } return(PartialView(cauHinh)); }
/// <summary> /// Hàm thực hiện đổ dữ liệu có trong bảng cấu hình lên giao diện /// </summary> /// <param name="ch"></param> private void doDuLieuLenView(cauHinh ch) { ViewBag.txtTenQuan = xulyDuLieu.traVeKyTuGoc(ch.tenQuan); ViewBag.txtGioiThieu = xulyDuLieu.traVeKyTuGoc(ch.gioiThieu); ViewBag.txtDiaChi = xulyDuLieu.traVeKyTuGoc(ch.diaChi); ViewBag.txtHotline = xulyDuLieu.traVeKyTuGoc(ch.hotLine); ViewBag.txtEmail = xulyDuLieu.traVeKyTuGoc(ch.email); ViewBag.txtFacebook = xulyDuLieu.traVeKyTuGoc(ch.facebook); ViewBag.txtGooglePlus = xulyDuLieu.traVeKyTuGoc(ch.googlePlus); ViewBag.txtTwitter = xulyDuLieu.traVeKyTuGoc(ch.twitter); ViewBag.txtKinhDo = xulyDuLieu.traVeKyTuGoc(ch.kinhDo); ViewBag.txtViDo = xulyDuLieu.traVeKyTuGoc(ch.viDo); ViewBag.txtGhiChu = xulyDuLieu.traVeKyTuGoc(ch.ghiChu); if (ch.loGo != null) { ViewBag.Logo = xulyDuLieu.chuyenByteHinhThanhSrcImage(ch.loGo); } }
/// <summary> /// Hàm lấy dữ liệu tại form kế hoạch kiểm kho /// </summary> /// <param name="ch"></param> /// <param name="f"></param> private void layDuLieuTuViewKiemKe(cauHinh ch, FormCollection f) { string loi = ""; ch.batDauKiem = xulyDuLieu.doiChuoiSangDateTime(f["txtNgayBatDau"]); if (ch.batDauKiem < DateTime.Now.Date) { loi += "Ngày bắt đầu kiểm phải lớn hơn hoặc bằng ngày hiện tại"; } ch.ketThucKiem = xulyDuLieu.doiChuoiSangDateTime(f["txtNgayKetThuc"]); if (ch.ketThucKiem < DateTime.Now.Date) { loi += "Ngày kết thúc phải lớn hơn ngày hiện tại"; } if (loi.Length > 0) { throw new Exception(loi); } }
/// <summary> /// hàm thực hiện lấy dữ liệu từ giao diện và gán cho các thuộc tính có trong cauHinh /// </summary> /// <param name="ch"></param> /// <param name="f"></param> /// <param name="fileUpload"></param> private void layDuLieuTuView(cauHinh ch, FormCollection f, HttpPostedFileBase fileUpload) { string loi = ""; ch.tenQuan = xulyDuLieu.xulyKyTuHTML(f["txtTenQuan"]); if (ch.tenQuan.Length <= 0) { loi += "Vui lòng nhập tên quán <br/>"; } ch.gioiThieu = xulyDuLieu.xulyKyTuHTML(f["txtGioiThieu"]); if (ch.gioiThieu.Length <= 0) { loi += "Vui lòng nhập thông tin giới thiệu cho quán <br/>"; } ch.diaChi = xulyDuLieu.xulyKyTuHTML(f["txtDiaChi"]); if (ch.diaChi.Length <= 0) { loi += "Vui lòng nhập địa chỉ của quán <br/>"; } ch.hotLine = xulyDuLieu.xulyKyTuHTML(f["txtHotline"]); ch.email = xulyDuLieu.xulyKyTuHTML(f["txtEmail"]); ch.facebook = xulyDuLieu.xulyKyTuHTML(f["txtFacebook"]); ch.googlePlus = xulyDuLieu.xulyKyTuHTML(f["txtGooglePlus"]); ch.twitter = xulyDuLieu.xulyKyTuHTML(f["txtTwitter"]); ch.kinhDo = xulyDuLieu.xulyKyTuHTML(f["txtKinhDo"]); ch.viDo = xulyDuLieu.xulyKyTuHTML(f["txtViDo"]); ch.ghiChu = xulyDuLieu.xulyKyTuHTML(f["txtGhiChu"]); string pathHinh = f["pathHinh"]; //------Kiểm tra xem có chọn hình không. if (!pathHinh.Equals("")) //Nếu có chọn hình thì luu hình vào csdl { pathHinh = xulyMaHoa.Decrypt(pathHinh); //Giải mã lại chuỗi đường dẫn lưu hình ảnh trên đĩa đã được mã hóa trong ajax ch.loGo = xulyDuLieu.chuyenDoiHinhSangByteArray(pathHinh); //Lưu hình vào thuộc tính hinhAnh } if (loi.Length > 0) { throw new Exception(loi); } }
/// <summary> /// Hàm tạo giao diện thiết lập thông số chung /// </summary> /// <returns></returns> public ActionResult ch_ThietLapThongSoChung() { if (xulyChung.duocCapNhat(idOfPage, "7")) { try { this.resetDuLieu(); qlCaPheEntities db = new qlCaPheEntities(); cauHinh chSua = db.cauHinhs.First(); if (chSua != null) { this.doDuLieuLenView(chSua); this.taoDuLieuChoCbbTaiKhoan(db); xulyChung.ghiNhatKyDtb(1, "Thiết lập thông số chung"); } } catch (Exception ex) { xulyFile.ghiLoi("Class: CauHinhController - Function: ch_ThietLapThongSoChung_Get", ex.Message); } } return(View()); }
public ActionResult ch_LenLichKiemKe(FormCollection f) { if (xulyChung.duocCapNhat(idOfPage, "7")) { string ndthongBao = ""; int kqLuu = 0; cauHinh chSua = new cauHinh(); qlCaPheEntities db = new qlCaPheEntities(); try { chSua = db.cauHinhs.First(); this.layDuLieuTuViewKiemKe(chSua, f); db.Entry(chSua).State = System.Data.Entity.EntityState.Modified; kqLuu = db.SaveChanges(); if (kqLuu > 0) { //------Tạo thông báo đến thành viên kiểm kê kqLuu += this.taoThongBaoNhacNhoKiemKeDtb(db, f["cbbTaiKhoan"], chSua); if (kqLuu > 1) { ndthongBao = "Cấu hình kế hoạch kiểm kê thành công"; this.resetDuLieu(); xulyChung.ghiNhatKyDtb(4, ndthongBao); } } } catch (Exception ex) { ndthongBao = ex.Message; xulyFile.ghiLoi("Class: CauHinhController - Function: ch_ThietLapThongSoChung_Post", ex.Message); this.resetDuLieu(); } ViewBag.ThongBao = createHTML.taoThongBaoLuu(ndthongBao); this.doDuLieuLenView(chSua); } return(View("ch_ThietLapThongSoChung")); }
/// <summary> /// Hàm tạo thông báo nhắc nhở kiểm kê trong CSDL /// </summary> /// <param name="db"></param> /// <param name="tenTK">Tên tài khoản cần tạo thông báo</param> /// <param name="ch">Object cấu hình để lấy ngày bắt đầu và kết thúc</param> private int taoThongBaoNhacNhoKiemKeDtb(qlCaPheEntities db, string tenTK, cauHinh ch) { int kq = 0; try { if (tenTK.Length >= 5) { thongBao tbAdd = new thongBao(); tbAdd.ndThongBao = "Đến đợt kiểm kê kho hàng " + ch.batDauKiem.ToString() + " - " + ch.ketThucKiem.ToString(); tbAdd.taiKhoan = tenTK; tbAdd.ngayTao = DateTime.Now; tbAdd.daXem = false; tbAdd.ghiChu = "Thông báo kiểm kho"; db.thongBaos.Add(tbAdd); kq = db.SaveChanges(); } } catch (Exception ex) { xulyFile.ghiLoi("Class: CauHinhController - Function: taoThongBaoNhacNhoKiemKeDtb", ex.Message); } return(kq); }
/// <summary> /// Hàm tạo modal in hóa đơn sau khi đã thanh toán /// </summary> /// <param name="hoaDon"></param> /// <returns></returns> private string taoModalInBill(hoaDonOrder hoaDon, qlCaPheEntities db, FormCollection f) { string kq = ""; cauHinh cauHinh = db.cauHinhs.First(); long tienMat = xulyDuLieu.doiChuoiSangLong(f["txtTienMat"]), tienTra = xulyDuLieu.doiChuoiSangLong(f["txtTienTra"]); kq += "<div class=\"modal fade in\" id=\"modalInHoaDon\" tabindex=\"-1\" role=\"dialog\" style=\"display: block;\">"; kq += " <div class=\"modal-dialog modal-sm\" role=\"document\">"; kq += " <div class=\"modal-content\">"; kq += " <div class=\"modal-header bg-blue\">"; kq += " <h4 class=\"modal-title\" id=\"smallModalLabel\">IN HÓA ĐƠN</h4>"; kq += " </div>"; kq += " <div class=\"modal-body\" id=\"printBill\">"; kq += " <div class=\"row text-center\">"; kq += " <h4>" + xulyDuLieu.traVeKyTuGoc(cauHinh.tenQuan) + "</h4>"; kq += " <label><i>Địa chỉ: " + xulyDuLieu.traVeKyTuGoc(cauHinh.diaChi) + "</i></label>"; kq += " <label><i>ĐT: " + xulyDuLieu.traVeKyTuGoc(cauHinh.hotLine) + "</i></label><br/>"; kq += " <label>*********************</label>"; kq += " </div>"; kq += " <div class=\"row\">"; kq += " <h4 class=\"text-center\">HÓA ĐƠN THANH TOÁN</h4>"; kq += " <p>Số TT: " + hoaDon.maHoaDon.ToString() + "</p>"; kq += " <p><b>Bàn: " + xulyDuLieu.traVeKyTuGoc(hoaDon.BanChoNgoi.tenBan) + "</b> - Ngày: " + hoaDon.ngayLap.ToString() + "</p>"; kq += " </div>"; kq += " <div class=\"row\">"; kq += " <table>"; kq += " <thead>"; kq += " <tr>"; kq += " <th width=\"40%\">Tên hàng</th>"; kq += " <th width=\"20%\">Đơn giá</th>"; kq += " <th width=\"20%\">T.Tiền</th>"; kq += " </tr>"; kq += " </thead>"; kq += " <tbody>"; foreach (ctHoaDonOrder ct in hoaDon.ctHoaDonOrders.ToList()) { kq += " <tr>"; kq += " <td>" + xulyDuLieu.traVeKyTuGoc(ct.sanPham.tenSanPham) + " (x" + ct.soLuong.ToString() + ")</td>"; kq += " <td>" + xulyDuLieu.doiVND(ct.donGia).Replace("VNĐ", "") + "</td>"; kq += " <td>" + xulyDuLieu.doiVND((ct.soLuong * ct.donGia)).Replace("VNĐ", "") + "</td>"; kq += " </tr>"; } kq += " </tbody>"; kq += " </table>"; kq += " </div>"; kq += " <br/>"; kq += " <div class=\"font-16 bold\">"; kq += " <label>T.Cộng:</label>"; kq += " <label class=\"pull-right\">" + xulyDuLieu.doiVND(hoaDon.tongTien) + "</label>"; kq += " </div>"; kq += " <div class=\"font-18 bold\">"; kq += " <label>Tạm tính:</label>"; kq += " <label class=\"pull-right\">" + xulyDuLieu.doiVND(hoaDon.tamTinh) + "</label>"; kq += " </div>"; kq += " <div class=\"font-14 bold\">"; kq += " <label>Nhận tiền mặt:</label>"; kq += " <label class=\"pull-right\">" + xulyDuLieu.doiVND(tienMat) + "</label>"; kq += " </div>"; kq += " <div class=\"font-14 bold\">"; kq += " <label>Tiền trả:</label>"; kq += " <label class=\"pull-right\">" + xulyDuLieu.doiVND(tienTra) + "</label>"; kq += " </div>"; kq += " <div class=\"font-11 text-center\">"; kq += " <label>Cám ơn quý khách - hẹn gặp lại !!!</label>"; kq += " </div>"; kq += " </div>"; kq += " <div class=\"modal-footer\">"; kq += "<button id=\"print\" class=\"btn btn-primary waves-effect\" onclick=\"printContent('printBill');\" ><i class=\"material-icons\">print</i>In hóa đơn</button>"; kq += " <a href=\"/HoaDon/hd_TableHoaDonChoThanhToan\" class=\"btn btn-link waves-effect\">CLOSE</a>"; kq += " </div>"; kq += " </div>"; kq += " </div>"; kq += "</div>"; return(kq); }