protected virtual void PhieuGuiHangModelToPhieuGuiHang(PhieuGuiHang nvto, PhieuGuiHangModel nvfrom) { nvto.VanPhongNhanId = nvfrom.VanPhongNhan.Id; nvto.NguoiKiemTraHangId = nvfrom.NguoiKiemTraHangId; nvto.DaThuCuoc = nvfrom.DaThuCuoc; nvto.GhiChu = nvfrom.GhiChu; }
public virtual void InsertPhieuGuiHang(PhieuGuiHang item) { if (item == null) { throw new ArgumentNullException("Phiếu gửi hàng"); } _phieuguihangRepository.Insert(item); //lay tong phieu gui hang trong thang cua nha xe hien tai item = GetPhieuGuiById(item.Id); //add by lent: 24-12-2015 var intcount = _phieuguihangRepository.Table.Where(c => c.NhaXeId == item.NhaXeId && c.NgayTao.Month == item.NgayTao.Month && c.NgayTao.Year == item.NgayTao.Year).Count(); if (item.VanPhongGui == null) { item.VanPhongGui = _nhaxeService.GetVanPhongById(item.VanPhongGuiId); } if (item.VanPhongNhan == null) { item.VanPhongNhan = _nhaxeService.GetVanPhongById(item.VanPhongNhanId); } item.MaPhieu = string.Format("{2}{0}{1}", DateTime.Now.ToString("yy"), intcount.ToString().PadLeft(4, '0'), item.VanPhongGui.Ma); if (String.IsNullOrEmpty(item.DiemGui) && item.VanPhongGui != null) { item.DiemGui = item.VanPhongGui.TenVanPhong; } if (String.IsNullOrEmpty(item.DiemTra) && item.VanPhongNhan != null) { item.DiemTra = item.VanPhongNhan.TenVanPhong; } _phieuguihangRepository.Update(item); }
public virtual void UpdatePhieuGuiHang(PhieuGuiHang item) { if (item == null) { throw new ArgumentNullException("Phiếu gửi hàng"); } item.NgayUpdate = DateTime.Now; _phieuguihangRepository.Update(item); }
public static string ThongTinHanHoa(this PhieuGuiHang item) { string strthongtin = ""; foreach (var hh in item.HangHoas) { if (string.IsNullOrEmpty(strthongtin)) { strthongtin = hh.TenHangHoa; } else { strthongtin = strthongtin + " - " + hh.TenHangHoa; } } return(strthongtin); }
public ActionResult PhieuGuiHangTao(PhieuGuiHangModel model, bool continueEditing) { if (this.CheckNoAccessIntoNhaXe(_workContext, _permissionService, StandardPermissionProvider.CVHangHoaKiGui)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var phieugui = new PhieuGuiHang(); //them nguoi gui var nguoigui = CapNhatKhachHang(model.NguoiGui.HoTen, model.NguoiGui.SoDienThoai, model.NguoiGui.DiaChi, model.NguoiGui.Id); //them nguoi nhan var nguoinhan = CapNhatKhachHang(model.NguoiNhan.HoTen, model.NguoiNhan.SoDienThoai, model.NguoiNhan.DiaChi, model.NguoiNhan.Id); //them phieu gui hàng phieugui.NhaXeId = _workContext.NhaXeId; phieugui.NguoiGuiId = nguoigui.Id; phieugui.NguoiNhanId = nguoinhan.Id; phieugui.VanPhongGuiId = _workContext.CurrentVanPhong.Id; phieugui.NguoiTaoId = _workContext.CurrentNhanVien.Id; phieugui.TinhTrangVanChuyenId = (int)ENTinhTrangVanChuyen.ChuaVanChuyen; phieugui.NgayTao = DateTime.Now; phieugui.NgayUpdate = DateTime.Now; PhieuGuiHangModelToPhieuGuiHang(phieugui, model); if (model.DaThuCuoc) { phieugui.NgayThanhToan = model.NgayThanhToan; phieugui.NhanVienThuTienId = _workContext.CurrentNhanVien.Id; } _phieuguihangService.InsertPhieuGuiHang(phieugui); //them hàng hóa var hanghoa = new HangHoa(); HangHoaModelToHangHoa(model.HangHoa, hanghoa); hanghoa.GiaCuoc = hanghoa.GiaCuoc * 1000m; hanghoa.PhieuGuiHangId = phieugui.Id; _hanghoaService.InsertHangHoa(hanghoa); SuccessNotification("Thêm mới phiếu gửi hàng thành công"); return(continueEditing ? RedirectToAction("PhieuGuiSua", new { id = phieugui.Id }) : RedirectToAction("QLGuiHang")); } return(View(model)); }
public static PhieuGuiHangModel ToModel(this PhieuGuiHang nvfrom, ILocalizationService localizationService, IPriceFormatter priceFormatter, List <HangHoa> hanghoas = null, bool isChiTiet = false) { var nvto = new PhieuGuiHangModel(); nvto.Id = nvfrom.Id; nvto.MaPhieu = nvfrom.MaPhieu; //van phong gui nvto.VanPhongGui.Id = nvfrom.VanPhongGuiId; nvto.VanPhongGui.TenVanPhong = nvfrom.VanPhongGui.TenVanPhong; //van phong nhan nvto.VanPhongNhan.Id = nvfrom.VanPhongNhanId; nvto.VanPhongNhan.TenVanPhong = nvfrom.VanPhongNhan.TenVanPhong; //nguoi gui nvto.NguoiGui.Id = nvfrom.NguoiGuiId; nvto.NguoiGui.HoTen = nvfrom.NguoiGui.HoTen; nvto.NguoiGui.SoDienThoai = nvfrom.NguoiGui.DienThoai; nvto.NguoiGui.DiaChi = nvfrom.NguoiGui.DiaChiLienHe; //nguoi nhan nvto.NguoiNhan.Id = nvfrom.NguoiNhanId; nvto.NguoiNhan.HoTen = nvfrom.NguoiNhan.HoTen; nvto.NguoiNhan.SoDienThoai = nvfrom.NguoiNhan.DienThoai; nvto.NguoiNhan.DiaChi = nvfrom.NguoiNhan.DiaChiLienHe; nvto.NguoiKiemTraHangId = nvfrom.NguoiKiemTraHangId; if (nvfrom.NguoiKiemTraHang != null) { nvto.TenNguoiKiemTraHang = nvfrom.NguoiKiemTraHang.HoVaTen; } else { nvto.TenNguoiKiemTraHang = nvfrom.nguoitao.HoVaTen; } nvto.TinhTrangVanChuyen = nvfrom.TinhTrangVanChuyen.ToCVEnumText(localizationService); nvto.DaThuCuoc = nvfrom.DaThuCuoc; if (nvto.DaThuCuoc) { nvto.ThanhToan = "Đã thanh toán"; } else { nvto.ThanhToan = "Chưa thanh toán"; } nvto.NgayNhan = nvfrom.NgayUpdate; if (nvfrom.NhanVienThuTien != null) { nvto.NgayThanhToan = nvfrom.NgayThanhToan; nvto.NhanVienThuTienId = nvfrom.NhanVienThuTienId; } nvto.NgayTao = nvfrom.NgayTao; if (nvfrom.XeXuatBen != null) { nvto.NgayDi = nvfrom.XeXuatBen.NgayDi; nvto.TenXeXuatBen = string.Format("{0}-{1}-{2}-{3} ({4})", nvfrom.XeXuatBen.NguonVeInfo.ThoiGianDi.ToString("HH:mm"), nvfrom.XeXuatBen.NguonVeInfo.ThoiGianDen.ToString("HH:mm"), nvfrom.XeXuatBen.NgayDi.ToString("dd/MM/yyyy"), nvfrom.XeXuatBen.xevanchuyen.TenXe, nvfrom.XeXuatBen.xevanchuyen.BienSo); if (isChiTiet) { nvto.XeXuatBen = nvfrom.XeXuatBen; } } else { nvto.NgayDi = nvfrom.NgayTao; } nvto.XeXuatBenId = nvfrom.XeXuatBenId; nvto.GhiChu = nvfrom.GhiChu; nvto.TenNguoiKiemTraHang = nvfrom.NguoiKiemTraHang.ThongTin(); if (hanghoas != null) { nvto.HangHoaInfo = ""; nvto.SoLuongHang = hanghoas.Count(); if (nvto.SoLuongHang == 1) { nvto.HangHoa = hanghoas.First().ToModel(localizationService, priceFormatter); } //var items = _hanghoaService.GetAllHangHoaByPhieuGuiHangId(nvfrom.Id); decimal tonggiatrihanghoa = 0; decimal tongcuocphi = 0; decimal tongcannang = 0; decimal tongsoluong = 0; foreach (var _item in hanghoas) { if (string.IsNullOrEmpty(nvto.HangHoaInfo)) { nvto.HangHoaInfo = _item.TenHangHoa; } else { nvto.HangHoaInfo = nvto.HangHoaInfo + "," + _item.TenHangHoa; } var _model = _item.ToModel(localizationService, priceFormatter); tonggiatrihanghoa = tonggiatrihanghoa + _item.GiaTri * _item.SoLuong; tongcuocphi = tongcuocphi + _item.GiaCuoc; tongcannang = tongcannang + _item.CanNang; tongsoluong = tongsoluong + _item.SoLuong; if (isChiTiet) { nvto.ListHangHoaInPhieuGui.Add(_model); } } nvto.TotalPackage = string.Format("{0} {1}", tongsoluong, "Kiện"); nvto.TongGiaTriHangHoa = tonggiatrihanghoa.ToTien(priceFormatter); nvto.TongCuocPhi = tongcuocphi.ToTien(priceFormatter); nvto.TongCanNang = tongcannang.ToSoNguyen(); } return(nvto); }
public virtual void DeletePhieuGuiHang(PhieuGuiHang item) { item.TinhTrangVanChuyen = ENTinhTrangVanChuyen.Huy; item.NgayUpdate = DateTime.Now; _phieuguihangRepository.Update(item); }
/// <summary> /// So tien <0 co nghia la chua thu cuoc /// </summary> /// <param name="NhaXeId"></param> /// <param name="CustomerId"></param> /// <param name="XeXuatBenId"></param> /// <param name="GuiTen"></param> /// <param name="GuiSDT"></param> /// <param name="NhanTen"></param> /// <param name="NhanSDT"></param> /// <param name="DiemGui"></param> /// <param name="DiemTra"></param> /// <param name="TenHang"></param> /// <param name="SoTien"></param> /// <param name="apiToken"></param> /// <returns></returns> public ActionResult NhanHang(int NhaXeId, int CustomerId, int XeXuatBenId , string GuiTen , string GuiSDT , string NhanTen , string NhanSDT , string DiemGui , string DiemTra , string TenHang , int SoTien , string apiToken) { //kiem tra xac thuc string _checkauthentication = isAuthentication(NhaXeId, CustomerId, apiToken, XeXuatBenId); if (!String.IsNullOrEmpty(_checkauthentication)) { return(ErrorOccured(_checkauthentication)); } var phieugui = new PhieuGuiHang(); //them nguoi gui var nguoigui = _nhaxecustomerService.CreateNew(NhaXeId, GuiTen, GuiSDT, DiemGui); //them nguoi nhan var nguoinhan = _nhaxecustomerService.CreateNew(NhaXeId, NhanTen, NhanSDT, DiemTra); //them phieu gui hàng phieugui.NhaXeId = NhaXeId; phieugui.XeXuatBenId = XeXuatBenId; phieugui.NguoiGuiId = nguoigui.Id; phieugui.NguoiNhanId = nguoinhan.Id; phieugui.VanPhongGuiId = currentNhanVien.VanPhongID.GetValueOrDefault(); phieugui.VanPhongNhanId = currentNhanVien.VanPhongID.GetValueOrDefault(); phieugui.NguoiTaoId = currentNhanVien.Id; phieugui.NguoiKiemTraHangId = currentNhanVien.Id; phieugui.TinhTrangVanChuyen = ENTinhTrangVanChuyen.DangVanChuyen; phieugui.NgayTao = DateTime.Now; phieugui.NgayUpdate = DateTime.Now; phieugui.GhiChu = "Hàng hóa được nhận trên quá trình di chuyển"; phieugui.DiemGui = DiemGui; phieugui.DiemTra = DiemTra; if (SoTien > 0) { phieugui.DaThuCuoc = true; phieugui.NgayThanhToan = DateTime.Now; phieugui.NhanVienThuTienId = currentNhanVien.Id; } else { phieugui.DaThuCuoc = false; } _phieuguihangService.InsertPhieuGuiHang(phieugui); //them hàng hóa var hanghoa = new HangHoa(); hanghoa.TenHangHoa = TenHang; hanghoa.LoaiHangHoa = ENLoaiHangHoa.LoaiKhac; hanghoa.GiaCuoc = Math.Abs(SoTien); hanghoa.SoLuong = 1; hanghoa.PhieuGuiHangId = phieugui.Id; _hanghoaService.InsertHangHoa(hanghoa); return(SuccessfulSimple(phieugui.Id.ToString())); }