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()); }
public IActionResult ChangeReis(int dogovorId) { ViewBag.DogovorId = dogovorId; var dogovor = _dogovor.Read(new DogovorBindingModel { Id = dogovorId })[0]; ViewBag.Raions = raions.Read(null); if (dogovor.Dogovor_Reiss.Count == 0) { ViewBag.Reiss = _reis.Read(null); } else { foreach (var keyr in dogovor.Dogovor_Reiss) { var ghjj = _reis.Read(new ReisBindingModel { Id = keyr.Value.Item2 }); ViewBag.Reiss = _reis.Read(new ReisBindingModel { OfId = (int)raions.Read(new RaionBindingModel { Id = _reis.Read(new ReisBindingModel { Id = keyr.Value.Item2 })[0].OfId })[0].Id }); } } return(View()); }
public IActionResult Dogovor(string?FIO, AgentListModel model) { ViewBag.Agent = FIO; var id = _agent.Read(new AgentBindingModel { Name = FIO }).FirstOrDefault(); if (FIO == null) { return(NotFound()); } var dogovor = _dogovor.Read(null); /*foreach (var d in dogovor) * { * if (d.Dogovor_Reiss.Count == 0) * { * _dogovor.Delete(new DogovorBindingModel { Id = d.Id }); * } * }*/ /*if (model.Id > 0) * { * dogovor = _dogovor.Read(new DogovorBindingModel * { * AgentId = (int)model.Id, * * }); * foreach (var r in dogovor) * { * * ViewBag.Dogovors = _dogovor.Read(new DogovorBindingModel { AgentId = (int)id.Id }); * } * if (dogovor.Count != 0) * { * ViewBag.Dogovors = dogovor; * return View(); * } * ModelState.AddModelError("Passport", "Такого Договора у клиента не существует"); * }*/ ViewBag.Dogovors = _dogovor.Read(new DogovorBindingModel { AgentId = (int)id.Id }); return(View()); }
private double ResultZp(string[] Month, int id, bool check) { if (Month.Length == 0) { TempData["ErrorLack"] = "Вы не выбрали месяц"; return(0); } double dogovor = 0; if (check) { dogovor = _dogovor.Read(null).Where(rec => (rec.data > DateTime.Now.AddYears(-1) && rec.data < DateTime.Now) && (rec.AgentId == id)).Select(rec => rec.Summa).Sum(); zp *= 12; } else { DateTime date = AgentController.PeriodDate(Month[0]); dogovor = _dogovor.Read(null).Where(rec => (rec.data.Month == date.Month) && (rec.AgentId == id)).Select(rec => rec.Summa).Sum(); } zp += dogovor * (comis / 100); return(zp); }
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 })); }
public IActionResult Client(ClientSpisokViewModel model) { if (model.DogovorId > 0) { var dogovor = _dogovor.Read(new DogovorBindingModel { Id = model.DogovorId }); foreach (var r in dogovor) { ViewBag.Client = _client.Read(new ClientBindingModel { Id = r.ClientId }); return(View()); } if (dogovor.Count == 0) { ModelState.AddModelError("Passport", "Договора не существует"); ViewBag.Client = _client.Read(null); return(View()); } } if (model.Passport != null) { if (!Regex.IsMatch(model.Passport, @"^[1-9]{10}$")) { ModelState.AddModelError("Passport", "Паспорт введен некорректно"); ViewBag.Client = _client.Read(null); return(View()); } var client = _client.Read(new ClientBindingModel { Pasport = model.Passport }); ViewBag.Client = client; if (client.Count == 0) { ModelState.AddModelError("Passport", "Клиента не существует"); ViewBag.Client = _client.Read(null); return(View()); } return(View()); } if (Validation(model.Obem) == true) { var clients = _client.Read(null); List <ClientViewModel> listclient = new List <ClientViewModel> { }; foreach (var client in clients) { double obem = 0; var dogovorss = _dogovor.Read(null); var dogovors = _dogovor.Read(new DogovorBindingModel { ClientId = client.Id, AgentId = (int)Program.Agent.Id }); foreach (var dogovor in dogovors) { foreach (var reis in dogovor.Dogovor_Reiss) { obem += reis.Value.Item6; } } if (obem >= Convert.ToDouble(model.Obem)) { listclient.Add(client); } } ViewBag.Client = listclient; return(View()); } else { if (model.Obem != "0") { ModelState.AddModelError("Obem", "Объем введен неправильно"); } } ViewBag.Client = _client.Read(null); return(View()); }
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()); }
public IActionResult Dogovors() { ViewBag.Dogovors = _dogovor.Read(null); return(View()); }