Exemple #1
0
        public NvTonDauKyVm.ReportModel CreateReport(string id)
        {
            var result = new NvTonDauKyVm.ReportModel();
            var exsit  = FindById(id);

            if (exsit != null)
            {
                result = Mapper.Map <NvVatTuChungTu, NvTonDauKyVm.ReportModel>(exsit);
                var nhanvien = UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == exsit.ICreateBy).FirstOrDefault();
                if (nhanvien != null)
                {
                    result.Username           = nhanvien.TenNhanVien != null ? nhanvien.TenNhanVien : "";
                    result.NameNhanVienCreate = nhanvien.TenNhanVien != null ? nhanvien.TenNhanVien : "";
                }
                var detailData = UnitOfWork.Repository <NvVatTuChungTuChiTiet>().DbSet.Where(x => x.MaChungTuPk == exsit.MaChungTuPk).ToList();
                result.DataReportDetails = Mapper.Map <List <NvVatTuChungTuChiTiet>, List <NvTonDauKyVm.ReportDetailModel> >(detailData);

                var customer = UnitOfWork.Repository <MdCustomer>().DbSet.FirstOrDefault(x => x.MaKH == result.MaKhachHang);
                if (customer != null)
                {
                    result.TenKhachHang    = customer.TenKH;
                    result.DiaChiKhachHang = customer.DiaChi;
                }
            }
            var unitCode   = GetCurrentUnitCode();
            var createDate = DateTime.Now;

            result.CreateDay   = createDate.Day;
            result.CreateMonth = createDate.Month;
            result.CreateYear  = createDate.Year;
            result.TenDonVi    = CurrentSetting.GetUnitName(unitCode);
            result.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
            return(result);
        }
        public NvNhapHangBanTraLaiVm.ReportModel CreateReport(string id)
        {
            var result = new NvNhapHangBanTraLaiVm.ReportModel();
            var exsit  = FindById(id);

            if (exsit != null)
            {
                result = Mapper.Map <NvVatTuChungTu, NvNhapHangBanTraLaiVm.ReportModel>(exsit);
                var detailData = UnitOfWork.Repository <NvVatTuChungTuChiTiet>().DbSet.Where(x => x.MaChungTuPk == exsit.MaChungTuPk).ToList();
                result.DataReportDetails = Mapper.Map <List <NvVatTuChungTuChiTiet>, List <NvNhapHangBanTraLaiVm.ReportDetailModel> >(detailData);
                var customer = UnitOfWork.Repository <MdCustomer>().DbSet.FirstOrDefault(x => x.MaKH == result.MaKhachHang);
                if (customer != null)
                {
                    result.TenKhachHang    = customer.TenKH;
                    result.DienThoai       = customer.DienThoai;
                    result.DiaChiKhachHang = customer.DiaChi;
                }
                var kho = UnitOfWork.Repository <MdWareHouse>().DbSet.FirstOrDefault(x => x.MaKho == result.MaKhoNhap);
                if (kho != null)
                {
                    result.TenKho = kho.TenKho;
                }
            }
            var unitCode   = GetCurrentUnitCode();
            var createDate = DateTime.Now;

            result.CreateDay   = createDate.Day;
            result.CreateMonth = createDate.Month;
            result.CreateYear  = createDate.Year;
            result.TenDonVi    = CurrentSetting.GetUnitName(unitCode);
            result.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
            //GetNhanVien
            if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal)
            {
                var currentUser = (HttpContext.Current.User as ClaimsPrincipal);
                var name        = currentUser.Identity.Name;
                var userName    = UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault();
                if (userName != null)
                {
                    result.Username = userName.TenNhanVien;
                }
                else
                {
                    result.Username = "******";
                }
            }
            return(result);
        }
Exemple #3
0
        public NvXuatKhacVm.ReportModel CreateReport(string id)
        {
            var     _ParentUnitCode = GetParentUnitCode();
            var     result          = new NvXuatKhacVm.ReportModel();
            decimal sum             = 0;
            var     exsit           = FindById(id);

            if (exsit != null)
            {
                result = Mapper.Map <NvVatTuChungTu, NvXuatKhacVm.ReportModel>(exsit);
                var nhanvien = UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == exsit.ICreateBy).FirstOrDefault();
                if (nhanvien != null)
                {
                    result.NameNhanVienCreate = nhanvien.TenNhanVien != null ? nhanvien.TenNhanVien : "";
                }
                var detailData = UnitOfWork.Repository <NvVatTuChungTuChiTiet>().DbSet.Where(x => x.MaChungTuPk == exsit.MaChungTuPk).ToList();
                result.DataReportDetails = Mapper.Map <List <NvVatTuChungTuChiTiet>, List <NvXuatKhacVm.ReportDetailModel> >(detailData);
                var sup = UnitOfWork.Repository <MdSupplier>().DbSet.FirstOrDefault(x => x.MaNCC == result.MaKhachHang);
                var cus = UnitOfWork.Repository <MdCustomer>().DbSet.FirstOrDefault(x => x.MaKH == result.MaKhachHang);
                if (sup != null)
                {
                    result.TenKhachHang    = sup.TenNCC;
                    result.DiaChiKhachHang = sup.DiaChi;
                }
                else if (cus != null)
                {
                    result.TenKhachHang    = cus.TenKH;
                    result.DiaChiKhachHang = cus.DiaChi;
                }
                var typeR = UnitOfWork.Repository <MdTypeReason>().DbSet.FirstOrDefault(x => x.MaLyDo == result.MaLyDo);
                if (typeR != null)
                {
                    result.TenLyDo = typeR.TenLyDo;
                }
                if (exsit.TrangThai != 10)
                {
                    List <NvXuatKhacVm.DtoDetail> listDetails = new List <NvXuatKhacVm.DtoDetail>();
                    var ky        = CurrentSetting.GetKhoaSo(exsit.UnitCode);
                    var tableName = ProcedureCollection.GetTableName(ky.Year, ky.Period);
                    var MaKho     = exsit.MaKhoXuat;
                    //string kyKeToan = _servicePeriod.GetKyKeToan((DateTime)phieu.NgayCT);
                    foreach (var value in result.DataReportDetails)
                    {
                        List <MdMerchandiseVm.DataXNT> data = ProcedureCollection.GetDataInventoryByCondition(exsit.UnitCode, MaKho, value.MaHang, tableName, _ParentUnitCode);
                        value.GiaVon    = value.GiaVon;
                        value.DonGia    = value.GiaVon;
                        value.ThanhTien = value.DonGia * value.SoLuong;
                        sum            += (decimal)value.ThanhTien;
                    }
                    var tyLe = UnitOfWork.Repository <MdTax>().DbSet.Where(x => x.MaLoaiThue == exsit.VAT).Select(x => x.TaxRate).FirstOrDefault();
                    if (tyLe != null)
                    {
                        result.TienVat = sum * (tyLe / 100);
                    }
                    else
                    {
                        result.TienVat = 0;
                    }

                    result.ThanhTienTruocVat = sum;
                    result.ThanhTienSauVat   = result.ThanhTienTruocVat + result.TienVat;
                }
                var warehouses      = UnitOfWork.Repository <MdWareHouse>().DbSet;
                var exportWareHouse = warehouses.FirstOrDefault(x => x.MaKho == result.MaKhoXuat);
                result.TenKhoXuat = exportWareHouse != null ? exportWareHouse.TenKho : "";
            }
            var unitCode   = GetCurrentUnitCode();
            var createDate = DateTime.Now;

            result.CreateDay   = createDate.Day;
            result.CreateMonth = createDate.Month;
            result.CreateYear  = createDate.Year;
            result.TenDonVi    = CurrentSetting.GetUnitName(unitCode);
            result.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
            //GetNhanVien
            if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal)
            {
                var currentUser = (HttpContext.Current.User as ClaimsPrincipal);
                var name        = currentUser.Identity.Name;
                var nhanVien    = UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault();
                if (nhanVien != null)
                {
                    result.Username = nhanVien.TenNhanVien;
                }
                else
                {
                    result.Username = "******";
                }
            }

            return(result);
        }