// GET: Counter public ActionResult Index() { var cus = (from s in db.ServiceAssign from c in db.Customer from n in db.Service where s.NewspaperId == n.Id && s.CustomerId == c.Id select new { Customer = c, ServiceAssign = s, NewsPaper = n }).ToList(); // as IEnumerable<CounterVM>; var uniqCustomer = from m in cus group m by new { m.Customer.Id } into mygroup select mygroup.FirstOrDefault(); List <CounterVM> objConter = new List <CounterVM>(); foreach (var item in cus) { CounterVM counter = new CounterVM(); counter.NewsPaper = item.NewsPaper; counter.Customer = item.Customer; counter.ServiceAssign = item.ServiceAssign; objConter.Add(counter); } return(View(objConter.AsEnumerable())); }
public MainWindow() { InitializeComponent(); // We create a counter var counter = new Counter(); // We wrap it in a CounterVM var vm = new CounterVM(counter); // We set the DataContext so that bindings can fetch data from the vm this.DataContext = vm; }
public ActionResult EditEndedDate(int?id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} //ServiceAssign service = db.ServiceAssign.Find(id); //if (service == null) //{ // return HttpNotFound(); //} //return View(service); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var cus = (from s in db.ServiceAssign from c in db.Customer from n in db.Service where s.NewspaperId == n.Id && s.CustomerId == c.Id && s.Id == id select new { Customer = c, ServiceAssign = s, NewsPaper = n }); // as IEnumerable<CounterVM>; CounterVM counter = new CounterVM(); if (cus.ToList().Any()) { counter.NewsPaper = cus.ToList().First().NewsPaper; counter.Customer = cus.ToList().First().Customer; counter.ServiceAssign = cus.ToList().First().ServiceAssign; counter.payment = counter.ServiceAssign.PaymentType; counter.Billdate = ADTOBS.EngToNep(counter.ServiceAssign.UpdatedDate).ToString(); counter.Paperdispatch = ADTOBS.EngToNep(counter.ServiceAssign.PaperDispatchDate).ToString(); counter.enddate = ADTOBS.EngToNep(counter.ServiceAssign.EndedDate).ToString(); } return(View(counter)); }
public ActionResult CustomerDetail(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var cus = (from s in db.ServiceAssign from c in db.Customer from n in db.Service where s.NewspaperId == n.Id && s.CustomerId == c.Id && s.CustomerId == id select new { Customer = c, ServiceAssign = s, NewsPaper = n }).ToList(); // as IEnumerable<CounterVM>; List <CounterVM> objConter = new List <CounterVM>(); foreach (var item in cus) { CounterVM counter = new CounterVM(); counter.NewsPaper = item.NewsPaper; counter.Customer = item.Customer; counter.ServiceAssign = item.ServiceAssign; var dispatch = item.ServiceAssign.PaperDispatchDate; counter.Paperdispatch = ADTOBS.EngToNep(dispatch).ToString(); var date = item.ServiceAssign.EndedDate; counter.NepaliDate = ADTOBS.EngToNep(date).ToString(); objConter.Add(counter); } if (objConter.AsEnumerable() == null) { return(HttpNotFound()); } return(View(objConter.AsEnumerable())); }
public ActionResult ExpiredReport() { var Newspaper = (from p in db.ServiceAssign from c in db.Customer from s in db.SalesMan from e in db.Service where p.CustomerId == c.Id && p.SalesManId == s.Id && p.NewspaperId == e.Id && p.EndedDate <= DateTime.Now select new { serviceAssign = p, customer = c, salesman = s, newspaper = e }).ToList(); List <CounterVM> listCounter = new List <CounterVM>(); for (int i = 0; i < Newspaper.ToList().Count; i++) { CounterVM objcounter = new CounterVM(); objcounter.ServiceAssign = Newspaper[i].serviceAssign; objcounter.Customer = Newspaper[i].customer; objcounter.NewsPaper = Newspaper[i].newspaper; objcounter.SalesMan = Newspaper[i].salesman; objcounter.enddate = ADTOBS.EngToNep(Newspaper[i].serviceAssign.EndedDate).ToString(); listCounter.Add(objcounter); // AddedCustomerVM.Add(new AddedCustomerVM { NewsPaperName = Newspaper[i].NewspaperName, NepaliDate = AddedDate, SalesMan = Newspaper[i].SalesMan/*, NewsPaperName =Newspaper[i].NewspaperName*/, ReportDate = Newspaper[i].date, FirstName = Newspaper[i].FirstName, Address = Newspaper[i].Address, MPhone = Newspaper[i].MPhone, PaperDispatchDate = Newspaper[i].PaperDispatchDate, EndedDate = Newspaper[i].EndedDate, CustomerId = Newspaper[i].CustomerId.ToString(), branch = "All Branches" }); } // var Count = db.ServiceAssign.Where(t => t.EndedDate <= DateTime.Now).ToList(); if (Newspaper.Count == 0) { TempData["message"] = "No one is expired"; return(RedirectToAction("Report", "DayWiseCount")); } log.AddActivity("Expired Customers reported printed successfully"); return(View(listCounter)); }
public ActionResult CustomerActivate(int?id) { FiscalYear fiscalYear = db.FiscalYear.FirstOrDefault(m => m.Status == true); int billNo = 1; if (fiscalYear != null) { if (db.Account.Any(m => m.fiscalyear.Id == fiscalYear.Id)) { billNo = db.Account.Where(m => m.fiscalyear.Id == fiscalYear.Id).Max(m => m.BillNo) + 1; } } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var list = new List <SelectListItem> { new SelectListItem { Text = "--छान्नुहोस्-- ", Value = "" }, new SelectListItem { Text = "मासिक", Value = "30" }, new SelectListItem { Text = "त्रेमासिक", Value = "90" }, new SelectListItem { Text = "चौ मासिक", Value = "120" }, new SelectListItem { Text = "अर्ध बार्षिक", Value = "182" }, new SelectListItem { Text = "बार्षिक", Value = "365" }, new SelectListItem { Text = "२ वर्ष", Value = "730" }, new SelectListItem { Text = "३ वर्ष", Value = "1095" }, new SelectListItem { Text = "४ वर्ष", Value = "1460" }, new SelectListItem { Text = "५ वर्ष", Value = "1825" } }; // SelectList countries = new SelectList({ Text = "Quarterly", Value = "90" }, new SelectListItem() { Text = "Half Quarterly", Value = "183" }, new SelectListItem() { Text = "Yearly", Value = "365" } } var cus = (from s in db.ServiceAssign from c in db.Customer from n in db.Service where s.NewspaperId == n.Id && s.CustomerId == c.Id && s.Id == id select new { Customer = c, ServiceAssign = s, NewsPaper = n }); // as IEnumerable<CounterVM>; CounterVM counter = new CounterVM(); if (cus.ToList().Any()) { counter.NewsPaper = cus.ToList().First().NewsPaper; counter.Customer = cus.ToList().First().Customer; counter.ServiceAssign = cus.ToList().First().ServiceAssign; counter.Paperdispatch = ADTOBS.EngToNep(counter.ServiceAssign.PaperDispatchDate).ToString(); counter.enddate = ADTOBS.EngToNep(counter.ServiceAssign.EndedDate).ToString(); counter.fiscalYear = fiscalYear.NepYear; counter.billNo = billNo; } ViewBag.Duration = new SelectList(list, "Value", "Text", cus.ToList().FirstOrDefault().ServiceAssign.Duration); return(View(counter)); }
public ActionResult Index()//string sortOrder,string CurrentSort, string currentFilter, string searchString, int? page) { var Cus = (from m in db.ServiceAssign group m by new { m.CustomerId } into mygroup select mygroup.FirstOrDefault()).ToList(); var sale = db.SalesMan.ToList(); var Custom = db.Customer.ToList(); var news = db.Service.ToList(); int newspaper = news.Count; int num = Cus.Count; int Customers = Custom.Count; int salesman = sale.Count; ViewBag.cus = Customers; ViewBag.message = num; ViewBag.sellman = salesman; ViewBag.news = newspaper; ViewBag.Newspaper = new SelectList(db.Service.ToList(), "NewsPaperName", "NewspaperName"); //int Cont = db.Customer.Count(t => (t.EndedDate > DateTime.Now)); //ViewBag.active = Cont; //int Coot = db.Customer.Count(t => (t.EndedDate <= DateTime.Now)); //ViewBag.inactive = Coot; var cus = (from s in db.ServiceAssign from c in db.Customer from n in db.Service from i in db.SalesMan where s.NewspaperId == n.Id && s.CustomerId == c.Id && s.SalesManId == i.Id select new { Customer = c, ServiceAssign = s, NewsPaper = n, SalesMan = i }).ToList(); var uniqCustomer = from m in cus group m by new { m.Customer.Id } into mygroup select mygroup.FirstOrDefault(); List <CounterVM> objConter = new List <CounterVM>(); foreach (var item in cus) { CounterVM counter = new CounterVM(); counter.NewsPaper = item.NewsPaper; counter.SalesMan = item.SalesMan; counter.Customer = item.Customer; counter.ServiceAssign = item.ServiceAssign; objConter.Add(counter); } return(View(objConter.AsEnumerable())); //var Cus = db.ServiceAssign.ToList(); // var sale = db.SalesMan.ToList(); // int num = Cus.Count; // int salesman = sale.Count; // ViewBag.message = num; // ViewBag.sellman = salesman; // int Cont = db.Customer.Count(t => (t.EndedDate > DateTime.Now)); // ViewBag.active = Cont; // int Coot = db.Customer.Count(t => (t.EndedDate <= DateTime.Now)); // ViewBag.inactive = Coot; // return View(Cus.ToList()); //} //int BranchId = Convert.ToInt32(Session["BranchId"].ToString()); //var saleman = db.SalesMan.Where(m=>m.BranchId==BranchId).ToList(); //var customers = db.Customer.Where(m => m.BranchId == BranchId).ToList(); //int number = customers.Count; //int salesmanNo = saleman.Count; //ViewBag.message = number; //ViewBag.sellman = salesmanNo; ////int Count = db.Customer.Where(m => m.BranchId == BranchId).Count(t => (t.EndedDate > DateTime.Now)); ////ViewBag.active = Count; ////int cout = db.Customer.Where(m => m.BranchId == BranchId).Count(t => (t.EndedDate <= DateTime.Now)); ////ViewBag.inactive = cout; //return View(db.Customer.Where(m => m.BranchId == BranchId).ToList()); }