Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public StateProcessApproval Approval(string id)
        {
            StateProcessApproval result;
            var unitCode = GetCurrentUnitCode();
            var periods  = CurrentSetting.GetKhoaSo(unitCode);

            if (periods != null)
            {
                var tableName = ProcedureCollection.GetTableName(periods.Year, periods.Period);
                if (ProcedureCollection.DecreaseVoucher(tableName, periods.Year, periods.Period, id))
                {
                    result = StateProcessApproval.Success;
                }
                else
                {
                    result = StateProcessApproval.Failed;
                }
            }
            else
            {
                result = StateProcessApproval.NoPeriod;
            }

            return(result);
        }
Exemplo n.º 3
0
        public NvNhapKhacVm.Dto CreateNewInstance()
        {
            var unitCode = GetCurrentUnitCode();

            return(new NvNhapKhacVm.Dto()
            {
                LoaiPhieu = TypeVoucher.NKHAC.ToString(),
                MaChungTu = BuildCode_PTNX(TypeVoucher.NKHAC.ToString(), unitCode, false),
                NgayCT = CurrentSetting.GetNgayKhoaSo(unitCode)
            });
        }
Exemplo n.º 4
0
        public NvNhapHangBanTraLaiVm.Dto CreateNewInstance()
        {
            var unitCode = GetCurrentUnitCode();
            var code     = BuildCode_PTNX(TypeVoucher.NHBANTL.ToString(), unitCode, false);

            return(new NvNhapHangBanTraLaiVm.Dto()
            {
                LoaiPhieu = TypeVoucher.NHBANTL.ToString(),
                MaChungTu = code,
                NgayCT = CurrentSetting.GetNgayKhoaSo(unitCode)
            });
        }
Exemplo n.º 5
0
        public NvCongNoVm.Dto CreateNewInstance(string _loaiChungTu)
        {
            var unitCode = GetCurrentUnitCode();
            var code     = BuildCode_PTNX(_loaiChungTu, unitCode, false);

            return(new NvCongNoVm.Dto()
            {
                LoaiChungTu = _loaiChungTu,
                MaChungTu = code,
                NgayCT = CurrentSetting.GetNgayKhoaSo(unitCode),
            });
        }
Exemplo n.º 6
0
        public NvXuatBanLeVm.Dto CreateNewInstance()
        {
            var code     = BuildCode();
            var unitCode = GetCurrentUnitCode();

            return(new NvXuatBanLeVm.Dto()
            {
                LoaiPhieu = TypeVoucher.XBANLE.ToString(),
                MaChungTu = code,
                MaHoaDon = code,
                NgayCT = CurrentSetting.GetNgayKhoaSo(unitCode),
            });
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public List <string[]> GetInventory(string code)
        {
            List <string[]> list = new List <string[]>();

            using (var ctx = new ERPContext())
            {
                using (var dbContextTransaction = ctx.Database.BeginTransaction())
                {
                    try
                    {
                        var unitCode     = GetCurrentUnitCode();
                        var pP_TABLENAME = new OracleParameter(":P_TABLENAME", OracleDbType.Varchar2, CurrentSetting.GetKhoaSo(unitCode).GetTableName(), ParameterDirection.Input);
                        var pP_UNITCODE  = new OracleParameter(":P_UNITCODE", OracleDbType.Varchar2, unitCode, ParameterDirection.Input);
                        var pP_MAVATTU   = new OracleParameter(":P_MAVATTU", OracleDbType.Varchar2, code, ParameterDirection.Input);
                        var pCUR         = new OracleParameter(":CUR", OracleDbType.RefCursor, ParameterDirection.Output);
                        var str          = "BEGIN TBNETERP.INVENTORE_MULTI_STORE(:P_MAVATTU, :P_UNITCODE, :P_TABLENAME,:CUR); END;";
                        ctx.Database.ExecuteSqlCommand(str, pP_MAVATTU, pP_UNITCODE, pP_TABLENAME, pCUR);
                        OracleDataReader reader = ((OracleRefCursor)pCUR.Value).GetDataReader();

                        bool hasNameColumn = false;
                        while (reader.Read())
                        {
                            var      it         = new InventoryUniCode();
                            int      fieldCount = reader.FieldCount;
                            string[] obj        = new string[fieldCount];
                            if (!hasNameColumn)
                            {
                                for (int i = 0; i < fieldCount; i++)
                                {
                                    var colName = reader.GetName(i);
                                    obj[i] = colName;
                                }
                                hasNameColumn = true;
                                list.Add(obj);
                                obj = new string[fieldCount];
                            }
                            for (int i = 0; i < fieldCount; i++)
                            {
                                var colName = reader.GetName(i);
                                obj[i] = reader[colName].ToString();
                            }
                            list.Add(obj);
                        }
                    }
                    catch
                    {
                        dbContextTransaction.Rollback();
                    }
                }
                return(list);
            }
        }
Exemplo n.º 10
0
        public void RUNSTORE_TANGGIAM_TON(string MaGiaoDichQuayPk, int LoaiGiaoDich)
        {
            //chạy store trừ xuất nhập tồn
            try
            {
                using (var context = new ERPContext())
                {
                    string         query        = "";
                    var            _unitCode    = GetCurrentUnitCode();
                    NvGiaoDichQuay gdquay       = context.NvGiaoDichQuays.Where(x => x.MaGiaoDichQuayPK == MaGiaoDichQuayPk).SingleOrDefault();
                    string         ID           = gdquay.Id;
                    var            pP_TABLENAME = new OracleParameter(":P_TABLENAME", OracleDbType.Varchar2, CurrentSetting.GetKhoaSo(_unitCode).GetTableName(), ParameterDirection.Input);
                    var            pP_NAM       = new OracleParameter(":P_NAM", OracleDbType.Varchar2, CurrentSetting.GetKhoaSo(_unitCode).Year, ParameterDirection.Input);
                    var            pP_KY        = new OracleParameter(":P_KY", OracleDbType.Decimal, CurrentSetting.GetKhoaSo(_unitCode).Period, ParameterDirection.Input);
                    var            pP_ID        = new OracleParameter(":P_ID", OracleDbType.Varchar2, ID, ParameterDirection.Input);
                    query = "BEGIN TBNETERP.XNT.XNT_GIAM_PHIEU(:pP_TABLENAME,:pP_NAM,:pP_KY,:pP_ID); END;";

                    if (gdquay.LoaiGiaoDich == 2)
                    {
                        string IDTraLai    = gdquay.MaGiaoDichQuayPK;
                        var    pP_IDTraLai = new OracleParameter(":P_ID", OracleDbType.Varchar2, IDTraLai, ParameterDirection.Input);
                        query = "BEGIN TBNETERP.XNT.XNT_TANG_PHIEU(:pP_TABLENAME,:pP_NAM,:pP_KY,:pP_IDTraLai); END;";
                        context.Database.ExecuteSqlCommand(query, pP_TABLENAME, pP_NAM, pP_KY, pP_IDTraLai);
                    }
                    else
                    {
                        context.Database.ExecuteSqlCommand(query, pP_TABLENAME, pP_NAM, pP_KY, pP_ID);
                    }
                }
            }
            catch (Exception)
            {
            }
        }