Пример #1
0
        public static DataTable GetDataSoLuongKiemTraBanVe(DateTime?startDate, DateTime?endDate)
        {
            DateTime dateNow = ManageBase.GetDateNow();

            #region Create datatable
            DataTable  dt = new DataTable("Data");
            DataColumn dc = new DataColumn("STT", typeof(string));
            dt.Columns.Add(dc);
            dc = new DataColumn("Phuong", typeof(string));
            dt.Columns.Add(dc);
            dc = new DataColumn("TongSoBienNhan", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("BienNhanHopLy", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("BienNhanHuy", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("TongBanVeDaKiemTra", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("SoBanVeDat", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("TyLeBanVeDat", typeof(double));
            dt.Columns.Add(dc);
            dc = new DataColumn("SoBanVeChuaDat", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("TyLeBanVeChuaDat", typeof(double));
            dt.Columns.Add(dc);
            dc = new DataColumn("SoBanVeDungHan_DKT", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("SoBanVeQuaHan_DKT", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("TongBanVeChuaKiemTra", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("SoBanVeDungHan_CKT", typeof(int));
            dt.Columns.Add(dc);
            dc = new DataColumn("SoBanVeQuaHan_CKT", typeof(int));
            dt.Columns.Add(dc);
            #endregion

            #region Set data
            int stt = 1;
            RelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add(XaFields.HuyenId == 769);
            EntityCollection ecXa = GenericEntityColManagerBase <XaEntityFactory> .SelectAll(0, null, filter);

            Dictionary <int, string> dictXa = new Dictionary <int, string>();
            int tongSoBienNhan, bienNhanHopLy, bienNhanHuy, tongBanVeDKT, soBanVeDat, soBanVeChuaDat, soBanVeDungHan_DKT, soBanVeQuaHan_DKT, tongBanVeChuaKiemTra, soBanVeDungHan_CKT, soBanVeQuaHan_CKT;
            foreach (XaEntity item in ecXa)
            {
                DataRow dr = dt.NewRow();
                dr["STT"]    = stt.ToString();
                dr["Phuong"] = item.TenXa;

                #region Hồ sơ đăng ký kiểm tra
                filter = new RelationPredicateBucket();
                filter.PredicateExpression.Add(ThongTinHoSoFields.XaId == item.XaId);
                if (startDate != null)
                {
                    filter.PredicateExpression.Add(ThongTinHoSoFields.NgayNop >= startDate);
                }
                if (endDate != null)
                {
                    filter.PredicateExpression.Add(ThongTinHoSoFields.NgayNop <= endDate);
                }
                tongSoBienNhan = GenericEntityColManagerBase <ThongTinHoSoEntityFactory> .GetDbCount(filter);

                filter.PredicateExpression.Add(ThongTinHoSoFields.HoSoKhongHopLy == true);
                bienNhanHuy = GenericEntityColManagerBase <ThongTinHoSoEntityFactory> .GetDbCount(filter);

                bienNhanHopLy = tongSoBienNhan - bienNhanHuy;
                #endregion

                #region Hồ sơ đã kiểm tra
                filter = new RelationPredicateBucket();
                filter.PredicateExpression.Add(ThongTinHoSoFields.XaId == item.XaId);
                if (startDate != null)
                {
                    filter.PredicateExpression.Add(ThongTinHoSoFields.NgayNop >= startDate);
                }
                if (endDate != null)
                {
                    filter.PredicateExpression.Add(ThongTinHoSoFields.NgayNop <= endDate);
                }
                filter.PredicateExpression.Add(ThongTinHoSoFields.HoSoDaKiemTra == true);
                tongBanVeDKT = GenericEntityColManagerBase <ThongTinHoSoEntityFactory> .GetDbCount(filter);

                filter.PredicateExpression.Add(ThongTinHoSoFields.HoSoChuaDat == true);
                soBanVeChuaDat = GenericEntityColManagerBase <ThongTinHoSoEntityFactory> .GetDbCount(filter);

                soBanVeDat = tongBanVeDKT - soBanVeChuaDat;

                filter = new RelationPredicateBucket();
                filter.PredicateExpression.Add(ThongTinHoSoFields.XaId == item.XaId);
                if (startDate != null)
                {
                    filter.PredicateExpression.Add(ThongTinHoSoFields.NgayNop >= startDate);
                }
                if (endDate != null)
                {
                    filter.PredicateExpression.Add(ThongTinHoSoFields.NgayNop <= endDate);
                }
                filter.PredicateExpression.Add(ThongTinHoSoFields.HoSoDaKiemTra == true);
                filter.PredicateExpression.Add(ThongTinHoSoFields.NgayTraHoSo <= ThongTinHoSoFields.NgayHenTra | ThongTinHoSoFields.NgayHenTra >= dateNow);
                soBanVeDungHan_DKT = GenericEntityColManagerBase <ThongTinHoSoEntityFactory> .GetDbCount(filter);

                soBanVeQuaHan_DKT = tongBanVeDKT - soBanVeDungHan_DKT;
                #endregion

                #region Hồ sơ chưa kiểm tra
                filter = new RelationPredicateBucket();
                filter.PredicateExpression.Add(ThongTinHoSoFields.XaId == item.XaId);
                if (startDate != null)
                {
                    filter.PredicateExpression.Add(ThongTinHoSoFields.NgayNop >= startDate);
                }
                if (endDate != null)
                {
                    filter.PredicateExpression.Add(ThongTinHoSoFields.NgayNop <= endDate);
                }
                filter.PredicateExpression.Add(ThongTinHoSoFields.HoSoDaKiemTra == false);
                tongBanVeChuaKiemTra = GenericEntityColManagerBase <ThongTinHoSoEntityFactory> .GetDbCount(filter);

                filter.PredicateExpression.Add(ThongTinHoSoFields.NgayTraHoSo <= ThongTinHoSoFields.NgayHenTra | ThongTinHoSoFields.NgayHenTra >= dateNow);
                soBanVeDungHan_CKT = GenericEntityColManagerBase <ThongTinHoSoEntityFactory> .GetDbCount(filter);

                soBanVeQuaHan_CKT = tongBanVeChuaKiemTra - soBanVeDungHan_CKT;
                #endregion

                dr["TongSoBienNhan"]     = tongSoBienNhan;
                dr["BienNhanHopLy"]      = bienNhanHopLy;
                dr["BienNhanHuy"]        = bienNhanHuy;
                dr["TongBanVeDaKiemTra"] = tongBanVeDKT;
                dr["SoBanVeDat"]         = soBanVeDat;
                dr["SoBanVeChuaDat"]     = soBanVeChuaDat;
                if (tongBanVeDKT > 0)
                {
                    dr["TyLeBanVeDat"]     = Math.Round(soBanVeDat / (double)tongBanVeDKT * 100, 2);
                    dr["TyLeBanVeChuaDat"] = 100 - (double)dr["TyLeBanVeDat"];
                }
                dr["SoBanVeDungHan_DKT"]   = soBanVeDungHan_DKT;
                dr["SoBanVeQuaHan_DKT"]    = soBanVeQuaHan_DKT;
                dr["TongBanVeChuaKiemTra"] = tongBanVeChuaKiemTra;
                dr["SoBanVeDungHan_CKT"]   = soBanVeDungHan_CKT;
                dr["SoBanVeQuaHan_CKT"]    = soBanVeQuaHan_CKT;

                stt++;
                dt.Rows.Add(dr);
            }
            #endregion

            return(dt);
        }
Пример #2
0
        public static bool SaveThongTinHoSo(ref ThongTinHoSo value)
        {
            bool result = true;

            try
            {
                DateTime           dateNow            = ManageBase.GetDateNow();
                ThongTinHoSoEntity thongTinHoSoEntity = new ThongTinHoSoEntity();
                thongTinHoSoEntity.ThongTinHoSoId       = value.ThongTinHoSoId;
                thongTinHoSoEntity.IsNew                = value.IsNew;
                thongTinHoSoEntity.XaId                 = GlobalVariable.XaId;
                thongTinHoSoEntity.SoBienNhan           = value.SoBienNhan;
                thongTinHoSoEntity.NgayNop              = value.NgayNop;
                thongTinHoSoEntity.NgayHenTra           = value.NgayHenTra;
                thongTinHoSoEntity.NgayTraHoSo          = value.NgayTraHoSo;
                thongTinHoSoEntity.NgayKiemTraNoiNghiep = value.NgayKiemTraNoiNghiep;
                thongTinHoSoEntity.SoBanVe              = value.SoBanVe;
                thongTinHoSoEntity.PhiDoVe              = value.PhiDoVe;
                thongTinHoSoEntity.GioiTinhNguoiNop     = new bool?(value.GioiTinhNguoiNop);
                thongTinHoSoEntity.NguoiNopHoSo         = value.NguoiNopHoSo;
                thongTinHoSoEntity.SoGiayToNguoiNop     = value.SoGiayToNguoiNop;
                thongTinHoSoEntity.PhiThamDinh          = value.PhiThamDinh;
                thongTinHoSoEntity.ChuyenVienId         = value.ChuyenVienId;
                thongTinHoSoEntity.ChuyenVienKiemTra    = value.ChuyenVienKiemTra;
                thongTinHoSoEntity.CongTyDoVeId         = value.CongTyDoVeId;
                thongTinHoSoEntity.CongTyDoVe           = value.CongTyDoVe;
                thongTinHoSoEntity.HoSoChuaDat          = value.HoSoChuaDat;
                thongTinHoSoEntity.HoSoDaKiemTra        = value.HoSoDaKiemTra;
                thongTinHoSoEntity.HoSoKhongHopLy       = value.HoSoKhongHopLy;
                thongTinHoSoEntity.RootId               = value.RootId;
                UserLog userLog = new UserLog();
                userLog.NguoiDungId              = new int?(GlobalVariable.NguoiDungId);
                userLog.NgayChinhSua             = new DateTime?(dateNow);
                userLog.LogHistory               = value.LichSuCapNhat;
                thongTinHoSoEntity.LichSuCapNhat = JsonConvert.SerializeObject(userLog);
                List <string> list = new List <string>();
                bool          flag = value.ThongTinChiTiet.ListGiayChungNhan != null;
                if (flag)
                {
                    foreach (GiayChungNhan current in value.ThongTinChiTiet.ListGiayChungNhan)
                    {
                        bool flag2 = !string.IsNullOrEmpty(current.SoSerial);
                        if (flag2)
                        {
                            list.Add(current.SoSerial);
                        }
                    }
                }
                thongTinHoSoEntity.SoHieuGiayChungNhan = string.Join(" ", list);
                list = new List <string>();
                List <string> list2 = new List <string>();
                bool          flag3 = value.ThongTinChiTiet.ListChu != null;
                if (flag3)
                {
                    foreach (ChuSuDung current2 in value.ThongTinChiTiet.ListChu)
                    {
                        bool flag4 = !string.IsNullOrEmpty(current2.HoTen);
                        if (flag4)
                        {
                            list.Add(current2.HoTen);
                        }
                        bool flag5 = !string.IsNullOrEmpty(current2.SoGiayTo);
                        if (flag5)
                        {
                            list2.Add(current2.SoGiayTo);
                        }
                    }
                }
                thongTinHoSoEntity.HoTen    = string.Join(" ", list);
                thongTinHoSoEntity.SoGiayTo = string.Join(" ", list2);
                list  = new List <string>();
                list2 = new List <string>();
                List <string> list3 = new List <string>();
                bool          flag6 = value.ThongTinChiTiet.ListThua != null;
                if (flag6)
                {
                    foreach (ThuaDat current3 in value.ThongTinChiTiet.ListThua)
                    {
                        bool flag7 = !list.Contains(current3.SoThuTuThua);
                        if (flag7)
                        {
                            list.Add(current3.SoThuTuThua);
                        }
                        bool flag8 = !list2.Contains(current3.SoHieuToBanDo);
                        if (flag8)
                        {
                            list2.Add(current3.SoHieuToBanDo);
                        }
                    }
                }
                thongTinHoSoEntity.SoThuTuThua    = string.Join(" ", list);
                thongTinHoSoEntity.SoHieuToBanDo  = string.Join(" ", list2);
                thongTinHoSoEntity.GhiChu         = value.GhiChu;
                thongTinHoSoEntity.LoaiBienDongId = value.LoaiBienDongId;
                bool isNew = value.IsNew;
                if (isNew)
                {
                    thongTinHoSoEntity.HoSoMoiNhat = true;
                }
                else
                {
                    thongTinHoSoEntity.HoSoMoiNhat = value.LaHoSoMoiNhat;
                }
                thongTinHoSoEntity.NguoiDungId = new int?(GlobalVariable.NguoiDungId);
                thongTinHoSoEntity.ChiTietHoSo = JsonConvert.SerializeObject(value.ThongTinChiTiet);
                thongTinHoSoEntity.KhoaChaId   = value.KhoaChaId;
                value.ThongTinHoSoId           = ManageBase.SaveThongTinHoSo(thongTinHoSoEntity);
                value.IsSuccess    = true;
                value.NguoiCapNhat = GlobalVariable.HoTenNguoiDung;
                bool flag9 = string.IsNullOrEmpty(value.NguoiCapNhat);
                if (flag9)
                {
                    value.NguoiCapNhat = GlobalVariable.TenDangNhap;
                }
                value.NgayChinhSua  = new DateTime?(dateNow);
                value.LichSuCapNhat = userLog;
                value.LaHoSoMoiNhat = thongTinHoSoEntity.HoSoMoiNhat;
                bool flag10 = value.IsNew && value.KhoaChaId.HasValue;
                if (flag10)
                {
                    ManageBase.Update(new ThongTinHoSoEntity
                    {
                        HoSoMoiNhat = false,
                        NguoiDungId = new int?(GlobalVariable.NguoiDungId)
                    }, new RelationPredicateBucket
                    {
                        PredicateExpression =
                        {
                            ThongTinHoSoFields.ThongTinHoSoId == value.KhoaChaId
                        }
                    });
                }
                value.IsNew = false;
            }
            catch (Exception var_27_4C1)
            {
                result = false;
            }
            return(result);
        }