コード例 #1
0
        public ActionResult IndexPemilik(LossEventViewModel vm)
        {
            UpdateParam(vm.Param);
            CalcPemilik(vm);

            return(View(vm));
        }
コード例 #2
0
        public ActionResult IndexKantor(LossEventViewModel vm)
        {
            UpdateParam(vm.Param);
            CalcLossEventKantor(vm);

            return(View(vm));
        }
コード例 #3
0
        public ActionResult IndexKantor()
        {
            LossEventViewModel vm = new LossEventViewModel();

            vm.Param             = new Param();
            vm.Param.IsApproved  = true;
            vm.Param.ReportDate  = DateTime.Now;
            vm.Param.ReportDate2 = DateTime.Now;
            UpdateParam(vm.Param);
            CalcLossEvent(vm);

            return(View(vm));
        }
コード例 #4
0
        private IQueryable <Askrindo.Models.LossEvent> lossvm(LossEventViewModel vm)
        {
            var loss = db.LossEvents.Where(p => p.InputDate != null);

            if (vm.Param.PosId == 1)
            {
                loss = loss.Where(p => p.DeptId != null || p.BranchId != null);
            }
            else if (vm.Param.PosId == 2)
            {
                loss = loss.Where(p => p.DeptId != null && p.SubDivId == vm.Param.BranchId);
            }
            else if (vm.Param.PosId == 3)
            {
                loss = loss.Where(p => p.BranchId != null);
                if (vm.Param.BranchId != null)
                {
                    loss = loss.Where(p => p.BranchId == vm.Param.BranchId);
                }
            }
            else if (vm.Param.PosId == 4)
            {
                var query = from b in db.Branches
                            join l in db.LossEvents on b.BranchId equals l.BranchId
                            where b.KorwilId == vm.Param.BranchId
                            select l;
                loss = query;
            }

            if (vm.Param.KlasId != null)
            {
                var i = vm.Param.KlasId.ToString();
                loss = loss.Where(k => k.KlasifikasiId == i);
            }

            if (vm.Param.IsApproved)
            {
                loss = loss.Where(p => p.LossDate == null || (p.LossDate >= vm.Param.ReportDate && p.LossDate <= vm.Param.ReportDate2));
                loss = loss.Where(p => p.ApproveDate != null && (p.ApproveDate >= vm.Param.ReportDate && p.ApproveDate <= vm.Param.ReportDate2));
            }
            else
            {
                loss = loss.Where(p => p.ApproveDate == null && (p.LossDate >= vm.Param.ReportDate && p.LossDate <= vm.Param.ReportDate2));
            }

            loss = loss.OrderBy(p => p.LossDate);

            return(loss);
        }
コード例 #5
0
        public ActionResult IndexTahun(LossEventViewModel vm)
        {
            UpdateParam(vm.Param);

            if (vm.Param.PeriodeId == 1)
            {
                CalcLossEventTahun(vm);
            }
            else
            {
                CalcLossEventBulan(vm);
            }

            return(View(vm));
        }
コード例 #6
0
        public virtual void ValidateVM()
        {
            var dbContext       = DbContext(GetCurrentMethod());
            var serviceProvider = GetServiceProviderMock(dbContext).Object;

            LossEventFacade facade = new LossEventFacade(serviceProvider, dbContext);

            var data            = new LossEventViewModel();
            var validateService = new ValidateService(serviceProvider);

            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(data));

            data.ProcessType = new Production.Lib.ViewModels.Integration.Master.ProcessTypeIntegrationViewModel();
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(data));
        }
コード例 #7
0
        private void CalcLossEventKantor(LossEventViewModel vm)
        {
            var LossK = db.LossEventKantorViews.Where(m => m.tanggal <= vm.Param.ReportDate2 && m.tanggal >= vm.Param.ReportDate);

            if (vm.Param.BranchId != null)
            {
                LossK = LossK.Where(m => m.id_pemilik == vm.Param.BranchId);
            }

            vm.LossList = new List <LossRecord>();
            foreach (var r in LossK)
            {
                LossRecord lr = new LossRecord();
                lr.lossEventKantor = r;

                vm.LossList.Add(lr);
            }
        }
コード例 #8
0
        public void ExportToExcelPemilik(int?posId, int?branchId, int?klasId, DateTime reportDate, DateTime reportDate2)
        {
            LossEventViewModel vm = new LossEventViewModel();

            vm.LossList          = new List <LossRecord>();
            vm.Param             = new Param();
            vm.Param.PosId       = posId;
            vm.Param.BranchId    = branchId;
            vm.Param.KlasId      = klasId;
            vm.Param.ReportDate  = reportDate;
            vm.Param.ReportDate2 = reportDate2;
            CalcPemilik(vm);

            StringWriter sw = new StringWriter();

            sw.WriteLine("<table rules='all' border='1' style='border-collapse:collapse;'>");
            sw.WriteLine("<tr>");
            sw.WriteLine("<th style='background-color: #eee'>Tahun</th>");
            sw.WriteLine("<th style='background-color: #eee'>Unit Kerja(Pemilik Kerugian)</th>");
            sw.WriteLine("<th style='background-color: #eee'>Klasifikasi Kerugian</th>");
            sw.WriteLine("<th style='background-color: #eee'>Jumlah Kasus</th>");
            sw.WriteLine("<th style='background-color: #eee'>Dampak Keuangan</th>");
            sw.WriteLine("<th style='background-color: #eee'>Dampak Non Keuangan</th>");
            sw.WriteLine("</tr>");

            foreach (var item in vm.LossList)
            {
                sw.WriteLine("<tr>");
                sw.WriteLine(string.Format("<td>{0}</td>", item.lossEventPemilik.tahun));
                sw.WriteLine(string.Format("<td>{0}</td>", item.lossEventPemilik.pemilik));
                sw.WriteLine(string.Format("<td>{0}</td>", item.lossEventPemilik.Klasifikasi));
                sw.WriteLine(string.Format("<td>{0}</td>", item.lossEventPemilik.jml_kasus));
                sw.WriteLine(string.Format("<td>{0}</td>", item.lossEventPemilik.ImpactFinancial));
                //sw.WriteLine(string.Format("<td>{0}</td>", item.lossEventPemilik.ImpactFinancial));
                sw.WriteLine("</tr>");
            }
            sw.WriteLine("</table>");

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment;filename=LossEventPemilik.xls");
            Response.ContentType = "application/vnd.ms-excel";
            Response.Write(sw.ToString());
            Response.End();
        }
コード例 #9
0
        public void Mapping_With_AutoMapper_Profiles()
        {
            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <LossEventProfile>();
            });
            var mapper = configuration.CreateMapper();

            LossEventViewModel vm = new LossEventViewModel {
                Id = 1
            };
            LossEventModel model = mapper.Map <LossEventModel>(vm);

            Assert.Equal(vm.Id, model.Id);

            var vm2 = mapper.Map <LossEventViewModel>(model);

            Assert.Equal(vm2.Id, model.Id);
        }
コード例 #10
0
        private void CalcLossEventTahun(LossEventViewModel vm)
        {
            var LossT = db.LossEventTahunViews.Where(m => m.tahun <= vm.Param.ReportDate2.Year && m.tahun >= vm.Param.ReportDate.Year);

            //var LossP = db.LossEventBulanViews.Where(m => m.tahun <= vm.Param.ReportDate2.Year && m.bulan <= vm.Param.ReportDate2.Month);
            //LossP = db.LossEventBulanViews.Where(m => m.tahun >= vm.Param.ReportDate.Year && m.bulan >= vm.Param.ReportDate.Month);

            if (vm.Param.BranchId != null)
            {
                LossT = LossT.Where(m => m.id_pemilik == vm.Param.BranchId);
            }

            vm.LossList = new List <LossRecord>();
            foreach (var r in LossT)
            {
                LossRecord lr = new LossRecord();
                lr.lossEventTahun = r;

                vm.LossList.Add(lr);
            }
        }
コード例 #11
0
        private void CalcLossEvent(LossEventViewModel vm)
        {
            var loss = lossvm(vm);

            vm.LossList = new List <LossRecord>();
            foreach (var r in loss)
            {
                LossRecord lr = new LossRecord();
                lr.lossEvent = r;
                lr.klas      = db.KlasifikasiKerugians.Where(p => p.KlasifikasiId == r.KlasifikasiId).SingleOrDefault();
                if (r.BranchId == null)
                {
                    var pemilik = db.SubDivs.Where(p => p.SubDivId == r.SubDivId).FirstOrDefault();
                    lr.pemilik = pemilik.SubDivName;
                }
                else
                {
                    var pemilik = db.Branches.Where(p => p.BranchId == r.BranchId).FirstOrDefault();
                    lr.pemilik = pemilik.BranchName;
                }
                vm.LossList.Add(lr);
            }
        }
コード例 #12
0
        private void CalcPemilik(LossEventViewModel vm)
        {
            var lossP = db.LossEventPemilikViews.Where(m => m.tahun <= vm.Param.ReportDate2.Year && m.tahun >= vm.Param.ReportDate.Year);

            if (vm.Param.BranchId != null)
            {
                lossP = lossP.Where(m => m.id_pemilik == vm.Param.BranchId);
            }

            if (vm.Param.KlasId != null)
            {
                var i = vm.Param.KlasId.ToString();
                lossP = lossP.Where(k => k.id_klasifikasi == i);
            }

            vm.LossList = new List <LossRecord>();
            foreach (var r in lossP)
            {
                LossRecord lr = new LossRecord();
                lr.lossEventPemilik = r;

                vm.LossList.Add(lr);
            }
        }
コード例 #13
0
        public void ExportToExcel(int?posId, int?branchId, DateTime reportDate, DateTime reportDate2,
                                  bool isApproved, bool showOrg, bool showAssets, bool showKeterangan,
                                  bool showLocation, bool showLossAction, bool showLossCat,
                                  bool showLossCause, bool showLossCode, bool showLossDate,
                                  bool showLossEffectFinancial, bool showLossEffectNonFinancial, bool showLossEvent,
                                  bool showPihakTerlibat)
        {
            LossEventViewModel vm = new LossEventViewModel();

            vm.LossList                         = new List <LossRecord>();
            vm.Param                            = new Param();
            vm.Param.PosId                      = posId;
            vm.Param.BranchId                   = branchId;
            vm.Param.ReportDate                 = reportDate;
            vm.Param.ReportDate2                = reportDate2;
            vm.Param.IsApproved                 = isApproved;
            vm.Param.ShowOrg                    = showOrg;
            vm.Param.ShowAssets                 = showAssets;
            vm.Param.ShowKeterangan             = showKeterangan;
            vm.Param.ShowLocation               = showLocation;
            vm.Param.ShowLossAction             = showLossAction;
            vm.Param.ShowLossCat                = showLossCat;
            vm.Param.ShowLossCause              = showLossCode;
            vm.Param.ShowLossCode               = showLossCode;
            vm.Param.ShowLossDate               = showLossDate;
            vm.Param.ShowLossEffectFinancial    = showLossEffectFinancial;
            vm.Param.ShowLossEffectNonFinancial = showLossEffectNonFinancial;
            vm.Param.ShowLossEvent              = showLossEvent;
            vm.Param.ShowPihakTerlibat          = showPihakTerlibat;
            CalcLossEvent(vm);

            StringWriter sw = new StringWriter();

            sw.WriteLine("<table rules='all' border='1' style='border-collapse:collapse;'>");
            sw.WriteLine("<tr>");
            if (vm.Param.ShowLossCode)
            {
                sw.WriteLine("<th style='background-color: #eee'>Kode Loss Event</th>");
            }
            sw.WriteLine("<th style='background-color: #eee'>Peristiwa Kerugian</th>");
            if (vm.Param.ShowLossDate)
            {
                sw.WriteLine("<th style='background-color: #eee'>Tanggal</th>");
            }
            if (vm.Param.ShowOrg)
            {
                sw.WriteLine("<th style='background-color: #eee'>Unit Kerja</th>");
            }
            if (vm.Param.ShowLossCat)
            {
                sw.WriteLine("<th style='background-color: #eee'>Klasifikasi Kerugian</th>");
            }
            if (vm.Param.ShowLossCause)
            {
                sw.WriteLine("<th style='background-color: #eee'>Sebab Kerugian</th>");
            }
            if (vm.Param.ShowLossEffectFinancial)
            {
                sw.WriteLine("<th style='background-color: #eee'>Dampak Kerugian Keuangan</th>");
            }
            if (vm.Param.ShowLossEffectNonFinancial)
            {
                sw.WriteLine("<th style='background-color: #eee'>Dampak Kerugian Non Keuangan</th>");
            }
            if (vm.Param.ShowPihakTerlibat)
            {
                sw.WriteLine("<th style='background-color: #eee'>Pihak Terlibat</th>");
            }

            sw.WriteLine("</tr>");
            foreach (var item in vm.LossList)
            {
                sw.WriteLine("<tr>");
                if (vm.Param.ShowLossCode)
                {
                    sw.WriteLine(string.Format("<td>{0}</td>", item.lossEvent.LossEventCode));
                }
                sw.WriteLine(string.Format("<td>{0}</td>", item.lossEvent.LossEventName));
                if (vm.Param.ShowLossDate)
                {
                    sw.WriteLine(string.Format("<td>{0:dd-MM-yyyy}</td>", item.lossEvent.LossDate));
                }
                if (vm.Param.ShowOrg)
                {
                    sw.WriteLine(string.Format("<td>{0}</td>", Utils.GetRiskOrgNameLoss(item.lossEvent)));
                }

                /*if (vm.Param.ShowRiskCat)
                 * {
                 *  sw.WriteLine("<td>");
                 *  if (item.Risk.RiskCat != null)
                 *  {
                 *      sw.WriteLine(item.Risk.RiskCat.RiskCatName);
                 *  }
                 *  sw.WriteLine("</td>");
                 * }*/
                if (vm.Param.ShowLossCause)
                {
                    sw.WriteLine("<td>");
                    if (item.lossEvent.LossCause != null)
                    {
                        sw.WriteLine(item.lossEvent.LossCause);
                    }
                    sw.WriteLine("</td>");
                }
                if (vm.Param.ShowLossEffectFinancial)
                {
                    sw.WriteLine("<td>");

                    sw.WriteLine(item.lossEvent.ImpactFinancial);

                    sw.WriteLine("</td>");
                }
                if (vm.Param.ShowLossEffectNonFinancial)
                {
                    sw.WriteLine("<td>");

                    sw.WriteLine(item.lossEvent.ImpactNonFinancial);

                    sw.WriteLine("</td>");
                }

                if (vm.Param.ShowPihakTerlibat)
                {
                    sw.WriteLine("<td>{0}</td>", item.lossEvent.PihakTerlibat);
                }
                sw.WriteLine("</tr>");
            }
            sw.WriteLine("</table>");

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment;filename=LossEvent.xls");
            Response.ContentType = "application/vnd.ms-excel";
            Response.Write(sw.ToString());
            Response.End();
        }