public ActionResult Archive()
        {
            Dictionary <int, DateTime> dats = new Dictionary <int, DateTime> {
            };
            var dogovors    = dogovorLogic.Read(null);//все договоры
            var olddogovors = dogovorLogic.Read(new DogovorBindingModel {
                Id = 0
            });                                                                     //
            var oldreis = dogovorLogic.ReadReis(new Dogovor_ReisBM {
                Id = 0
            });                                                                //устаревшие рейсы по договору
            bool proverca = false;

            foreach (var dogovor in dogovors)
            {
                dats.Add((int)dogovor.Id, new DateTime());
                proverca = false;
                foreach (var dr in dogovor.Dogovor_Reiss)
                {
                    var reis1 = rlogic.Read(new ReisBindingModel {
                        Id = dr.Value.Item2
                    })[0];
                    DateTime dt1 = dogovor.data.AddDays(reis1.Time + dr.Value.Item4);
                    if (dt1 > dats[(int)dogovor.Id])
                    {
                        dats[(int)dogovor.Id] = dt1;
                    }
                    DateTime dt2 = DateTime.Now;
                    if (DateTime.Now.Month != 12)
                    {
                        dt2 = DateTime.Now.AddYears(-1);
                    }
                    if (dt1 > dt2)
                    {
                        proverca = true;
                    }
                }
                if (proverca != true)
                {
                    olddogovors.Add(dogovor);
                    foreach (var dr in dogovor.Dogovor_Reiss)
                    {
                        oldreis.Add(dogovorLogic.ReadReis(new Dogovor_ReisBM {
                            Id = dr.Key
                        })[0]);
                    }
                }
            }
            ViewBag.Dats     = dats;
            ViewBag.dogovors = olddogovors;

            return(View());
        }
Ejemplo n.º 2
0
        public IActionResult Report(ReportViewModel model, int dogovorid)
        {
            List <string> list = new List <string> {
                "Название", "Цена", "Откуда", "Куда", "Время выполнения", "Объем товара", "Вес товара"
            };
            var clientsall = _client.Read(null);
            var clients    = _client.Read(new ClientBindingModel {
                Id = 0
            });

            foreach (var client in clientsall)
            {
                var dogovorofclient = _dogovor.Read(new DogovorBindingModel {
                    ClientId = client.Id, AgentId = (int)Program.Agent.Id
                });
                if (dogovorofclient.Count >= 0)
                {
                    clients.Add(client);
                }
            }
            SaveToPdf.CreateDocDogovor(new Info
            {
                FileName = model.puth + $"ReportDogovorpdf{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}.pdf",
                Colon    = list,
                Title    = $" Договор {dogovorid}",
                Client   = _client.Read(new ClientBindingModel {
                    Id = Program.ClientId
                })[0].ClientFIO,
                Agent   = Program.Agent.Name,
                dogovor = _dogovor.Read(new DogovorBindingModel {
                    Id = dogovorid
                })[0],
                dogovor_Reis = _dogovor.ReadReis(null),
                raion        = _raion.Read(null),
                reiss        = _reis.Read(null)
            });
            return(RedirectToAction("Dogovor", new { id = Program.ClientId }));
        }
Ejemplo n.º 3
0
        public IActionResult Reis(int raion, ReisSpisokModel model)
        {
            ViewBag.Reiss = _reis.Read(null);
            var Raion = raions.Read(null);

            ViewBag.Raions = Raion;
            Raion.Insert(0, new RaionViewModel {
                Name = "Все", Id = 0
            });
            ReisSpisokModel plvm = new ReisSpisokModel
            {
                Raion = new SelectList(Raion, "Id", "Name")
            };
            var reisView = _reis.Read(null);
            List <ReisViewModel> reisV = new List <ReisViewModel>()
            {
            };

            ViewBag.Reiss = reisV;
            if (Validation(model) == true)
            {
                foreach (var i in reisView)
                {
                    if ((i.Cena > Convert.ToDouble(model.Cena1)) && (i.Cena < Convert.ToDouble(model.Cena2)) && (raion != 0))
                    {
                        if ((i.OfId == raion) || (i.ToId == raion) || (raion == 0))
                        {
                            reisV.Add(i);
                        }
                    }
                }
            }
            else
            {
                ViewBag.Reiss = _reis.Read(null);
            }
            return(View(plvm));
        }
Ejemplo n.º 4
0
        public IActionResult Report()
        {
            var raions   = _raions.Read(null);
            var dogovors = _dogovor.Read(null);
            var reiss    = _reis.Read(null);
            var Texts    = new List <string> {
            };
            var list     = new List <List <string> > {
            };

            if (TempData["ErrorLack"] != null)
            {
                ModelState.AddModelError("", TempData["ErrorLack"].ToString());
            }
            foreach (var raion in raions)
            {
                Texts = new List <string> {
                    raion.Name,
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 1, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 2, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 3, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 4, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 5, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 6, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 7, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 8, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 9, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 10, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 11, 1)),
                    SaveToPdf.Count(new Info {
                        dogovors = _dogovor.Read(new DogovorBindingModel {
                            AgentId = (int)Program.Agent.Id
                        }), reiss = _reis.Read(null)
                    }, raion, new DateTime(2020, 12, 1))
                };
                list.Add(Texts);
            }
            ViewBag.list = list;
            return(View());
        }