public ActionResult Create(List <PurchaseReportVM> prakashanreport, FormCollection col)
        {
            DateTime date    = Convert.ToDateTime(col["EnglishDate"]);
            string   Nepdate = col["NepaliDate"].ToString();
            var      report  = db.prakashanreports.FirstOrDefault(m => m.Date == date);

            if (report == null)
            {
                PurchaseReportVM purchasevm = new PurchaseReportVM();
                foreach (var item in prakashanreport)
                {
                    Prakashanreport objreport = new Prakashanreport();
                    objreport.NepaliDate     = Nepdate;
                    objreport.Date           = date;
                    objreport.GroupId        = Convert.ToInt32(item.GroupId);
                    objreport.PrakashanGroup = db.prakashanGroups.Find(objreport.GroupId);
                    objreport.gp_Total       = item.gp_Total;
                    objreport.rn_Total       = item.rn_Total;
                    objreport.Remarks        = item.Remarks;
                    db.prakashanreports.Add(objreport);
                    db.SaveChanges();
                }
                TempData["message"] = "Production record inserted sucessfully";
                log.AddActivity("Production report Successfully Inserted");
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["message"] = " Production Record for this date is already stored please edit this record here";
                return(RedirectToAction("EditByDate"));
            }
        }
예제 #2
0
        public ActionResult ChangeSaleman(assignNewspaperVM serviceAssign)
        {
            if (db.ServiceAssign.Any(m => m.CustomerId == serviceAssign.CustomerId))
            {
                foreach (var item in serviceAssign.NewspaperIds)
                {
                    ServiceAssign objService = db.ServiceAssign.FirstOrDefault(m => m.CustomerId == serviceAssign.CustomerId && m.NewspaperId == item);


                    objService.SalesManId = serviceAssign.SalesManId;


                    log.AddActivity("Service assign to customer successfully");
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Newspaper Already Assigned.");
                serviceAssign.Newspapers = new SelectList(db.Service, "Id", "NewsPaperName");
                serviceAssign.Salesmans  = new SelectList(db.SalesMan, "Id", "FullName");
                return(View(serviceAssign));
            }
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "Id,RouteId,RouteName")] Route route)
        {
            if (ModelState.IsValid)
            {
                db.Routes.Add(route);
                db.SaveChanges();
                log.AddActivity("Route created Successfully");
                return(RedirectToAction("Index"));
            }

            return(View(route));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "Id,GroupId,GroupName")] PrakashanGroup prakashanGroup)
        {
            if (ModelState.IsValid)
            {
                db.prakashanGroups.Add(prakashanGroup);
                db.SaveChanges();
                TempData["message"] = "Prakahan Group created sucessfully";
                log.AddActivity("Group Name Created Successfuly");
                return(RedirectToAction("Index"));
            }

            return(View(prakashanGroup));
        }
        public ActionResult EditEndedDate(DateTime PaperDispatchDate, DateTime EndedDate, bool payment, int Quantity, int id, DateTime PaymentDate)
        {
            ServiceAssign objserviceAssign = db.ServiceAssign.Find(id);

            objserviceAssign.PaperDispatchDate = PaperDispatchDate;
            objserviceAssign.EndedDate         = EndedDate;
            objserviceAssign.UpdatedDate       = PaymentDate;
            objserviceAssign.Quantity          = Quantity;
            objserviceAssign.PaymentType       = payment;
            db.SaveChanges();
            TempData["message"] = "EndedDate Edited Sucessfully";
            log.AddActivity("EndedDate is changed");
            return(RedirectToAction("Index", "Counter"));
        }
        public ActionResult Create([Bind(Include = "Id,AgentName,Pan,GP_Quantity,RN_Quantity,MUNA_Quantity,Madhu_Quantity,Yuwa_Quantity,Address,Time,RouteName,Transport,State,District,Phone,Email,URL,RouteId")] GroupName groupName)
        {
            if (ModelState.IsValid)
            {
                groupName.Route = db.Routes.Find(groupName.RouteId);
                db.groupNames.Add(groupName);
                db.SaveChanges();
                TempData["message"] = "Agent created successfully";
                log.AddActivity("Agent Names Created Successfully");
                return(RedirectToAction("Index"));
            }

            ViewBag.RouteId = new SelectList(db.Routes, "Id", "RouteName", groupName.RouteId);
            return(View(groupName));
        }
예제 #7
0
        public ActionResult Create(Customer customer)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.SalesManId = new SelectList(db.SalesMan, "Id", "FullName");
                ViewBag.ServiceId  = new SelectList(db.Service, "Id", "NewsPaperName");
                ViewBag.BranchId   = new SelectList(db.Branch, "BranchId", "BranchName");
                ViewBag.OfficerId  = new SelectList(db.Officers.Where(m => m.Status && m.OfficerType == "निशुल्क प्रदान गर्ने"), "Id", "Name");

                return(View(customer));
            }
            else
            {
                customer.RegisterDate = DateTime.Now;
                customer.RegisteredBy = Session["userEmail"].ToString();
                db.Customer.Add(customer);
                db.SaveChanges();

                try
                {
                    log.AddActivity("Customer Created Successfully");

                    return(RedirectToAction("index"));
                }
                catch
                {
                    return(View());
                }
            }
        }
예제 #8
0
 public JsonResult changeStatus(string fyId)
 {
     try
     {
         if (db.FiscalYear.Any(m => m.Status == true))
         {
             var activeFiscalYear = db.FiscalYear.FirstOrDefault(m => m.Status == true);
             activeFiscalYear.Status = false;
         }
         int id         = Convert.ToInt32(fyId);
         var objFisYear = db.FiscalYear.Find(id);
         objFisYear.Status = true;
         db.SaveChanges();
         log.AddActivity("Fiscal Year changed sucessfully");
         return(Json(true));
     }
     catch
     {
         return(Json(false));
     }
 }
예제 #9
0
        public ActionResult CountSalesManReport(FormCollection col)
        {
            List <SelectSalesManVM> SelectSalesManVM = new List <SelectSalesManVM>();
            string   NepaliDate = col["NepDate"].ToString();
            int      salesManId = Convert.ToInt32(col["SalesManId"]);
            DateTime date       = Convert.ToDateTime(col["PaperDispatchDate"]);



            NewspaperEntities db = new NewspaperEntities();


            var salesManList = db.SalesMan.ToList();

            foreach (var item in salesManList)
            {
                var customer = db.ServiceAssign.Where(m => m.EndedDate > date && m.SalesManId == item.Id && m.PaperDispatchDate < date).GroupBy(n => n.NewspaperId)
                               .Select(g => new { ServiceId = g.Key, Count = g.Sum(m => m.Quantity), newspaperId = g.FirstOrDefault().NewspaperId }).ToList();


                for (int i = 0; i < customer.ToList().Count; i++)
                {
                    int    newsId        = Int32.Parse(customer[i].newspaperId.ToString());
                    string newspapername = db.Service.FirstOrDefault(m => m.Id == newsId).NewsPaperName;
                    SelectSalesManVM.Add(new SelectSalesManVM {
                        SalesManId = item.Id, NepDate = NepaliDate, SalesManName = item.FullName, ReportDate = DateTime.Now, NewsPaperName = newspapername, Count = customer[i].Count, branch = "All Branches"
                    });
                }
            }
            if (SelectSalesManVM.Count == 0)
            {
                TempData["message"] = "No record found.";
                return(RedirectToAction("SelectSalesMan"));
            }
            try
            {
                string Operation = "Daywise count Report is printed";
                db.ActivityLog.Add(new ActivityLog
                {
                    Operation   = Operation,
                    CreatedBy   = Session["userName"].ToString(),
                    CreatedDate = DateTime.Now
                });
            }
            catch
            {
                ViewBag.ErrorMessage = "Daywise count Report failed to print";
            }
            log.AddActivity("Gatepass report printed successfully");
            return(View(SelectSalesManVM));
        }
예제 #10
0
        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));
        }
예제 #11
0
        public ActionResult backup(string directory)
        {
            string backupDIR = "";
            string drive     = "";

            backupDIR = ConfigurationManager.AppSettings["Path"].ToString();
            if (!System.IO.Directory.Exists(backupDIR))
            {
                System.IO.Directory.CreateDirectory(backupDIR);
            }
            try
            {
                var           connectionString = ConfigurationManager.ConnectionStrings["Newspaper"].ConnectionString;
                SqlConnection conx             = new SqlConnection(connectionString);
                SqlCommand    cmd = new SqlCommand();
                cmd.Connection  = conx;
                cmd.CommandType = CommandType.StoredProcedure;
                conx.Open();
                cmd = new SqlCommand("backup database Newspaper to disk='" + backupDIR + "\\" + DateTime.Now.ToString("ddMMyyyy") + ".Bak'", conx);
                cmd.ExecuteNonQuery();
                conx.Close();
                ViewBag.Message = "Backup Database file created successfully in 'Backup_Database_Newspaper' folder in " + drive + "  drive.";
                log.AddActivity("Data backup succesfully");
                //if (SendMail())
                //{
                //    ViewBag.Message = "Backup database successfully";
                //}
                //else
                //{
                //    ViewBag.Message = "Backup database successfully but backup file not send to mail.";
                //}
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "Error Occured During DB backup process !<br>" + ex.ToString();
                // lblError.Text = "Error Occured During DB backup process !<br>" + ex.ToString();
            }
            return(View());
        }
예제 #12
0
        public ActionResult Create(Officer officer)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.OfficerType = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "---छान्नुहोस---", Value = ""
                    },
                    new SelectListItem {
                        Text = "कम्प्लिमेन्ट", Value = "कम्प्लिमेन्ट"
                    },
                    new SelectListItem {
                        Text = "नर्मल", Value = "नर्मल"
                    }
                };
                return(View(officer));
            }
            else
            {
                officer.CreatedBy   = Session["userEmail"].ToString();
                officer.CreatedDate = DateTime.Now;
                officer.UpdatedDate = DateTime.Now;
                db.Officers.Add(officer);
                db.SaveChanges();

                try
                {
                    log.AddActivity("Officer Created Successfully");

                    return(RedirectToAction("index"));
                }
                catch
                {
                    return(View());
                }
            }
        }
예제 #13
0
        public ActionResult Create(Customer customer)
        {
            customer.RegisterDate = DateTime.Now;
            customer.RegisteredBy = Session["userEmail"].ToString();


            db.Customer.Add(customer);
            db.SaveChanges();

            try
            {
                log.AddActivity("Customer Created Successfully");
                //db.ActivityLog.Add(new ActivityLog
                //{
                //    BranchId = customer.BranchId,
                //    Operation = Operation,
                //    CreatedBy = Session["userEmail"].ToString(),
                //    CreatedDate = DateTime.Now

                //});
                //db.SaveChanges();
                return(RedirectToAction("index"));
            }
            catch
            {
                return(View());
            }
            //if (Session["Category"].ToString() == "SuperAdmin")
            //{
            //    customer.RegisterDate = DateTime.Now;
            //    customer.RegisteredBy = Session["userEmail"].ToString();


            //    db.Customer.Add(customer);
            //    db.SaveChanges();

            //    try
            //    {


            //        String Operation = "Customer Created Sucessfully ";
            //        db.ActivityLog.Add(new ActivityLog
            //        {
            //            BranchId = customer.BranchId,
            //            Operation = Operation,
            //            CreatedBy = Session["userEmail"].ToString(),
            //            CreatedDate = DateTime.Now

            //        });
            //        db.SaveChanges();
            //        return RedirectToAction("index");
            //    }
            //    catch
            //    {
            //        return View();
            //    }
            //}
            //else
            //{
            //    customer.RegisterDate = DateTime.Now;
            //    customer.RegisteredBy = Session["userEmail"].ToString();

            //    db.Customer.Add(customer);
            //    db.SaveChanges();

            //    try
            //    {
            //        int BranchId = Convert.ToInt32(Session["BranchId"].ToString());
            //        String Operation = "Customer Created Sucessfully ";
            //        db.ActivityLog.Add(new ActivityLog
            //        {
            //            BranchId = BranchId,
            //            Operation = Operation,
            //            CreatedBy = Session["userEmail"].ToString(),
            //            CreatedDate = DateTime.Now

            //        });
            //        db.SaveChanges();
            //        return RedirectToAction("index");
            //    }
            //    catch
            //    {
            //        return View();
            //    }
            //}
        }
예제 #14
0
        public ActionResult Login(Models.LoginViewModel l, string ReturnUrl = "")
        {
            using (NewspaperEntities db = new NewspaperEntities())
            {
                var Admin = _db.Admin.FirstOrDefault(a => (a.UserName == l.UserName || a.Email == l.UserName));
                if (Admin != null)
                {
                    var pass = Crypto.Hash(l.Password);
                    if (string.Compare(pass, Admin.Password) == 0)
                    {
                        var check = _db.Admin.FirstOrDefault(a => a.Status);
                        if (Admin.Status == true)
                        {
                            string imageUrl = "../../img/17.jpg";
                            if (System.IO.File.Exists(Server.MapPath(@"~/images/" + Admin.Id + ".jpg")))
                            {
                                imageUrl = "../../images/" + Admin.Id + ".jpg";
                            }
                            Session.Add("id", Admin.Id);
                            Session.Add("userName", Admin.UserName);
                            Session.Add("userEmail", Admin.Email);
                            Session.Add("FullName", Admin.FullName);
                            Session.Add("Category", Admin.Category);
                            Session.Add("imageUrl", imageUrl);
                            Session.Add("BranchId", Admin.BranchId);


                            if (Session["Category"].ToString() == "Counter")
                            {
                                var login = Session["userEmail"].ToString();
                                log.AddActivity(login + " " + "logged in successfully");
                                return(RedirectToAction("Index", "Counter"));
                            }
                            else if (Session["Category"].ToString() == "Accountant")
                            {
                                var login = Session["userEmail"].ToString();
                                log.AddActivity(login + " " + "logged in successfully");
                                return(RedirectToAction("Index", "Accountant"));
                            }
                            else
                            {
                                return(RedirectToAction("Index", "DashBoard"));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Admin is Deactivate");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "UserName and Password not match");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "UserName and Password not match");
                }
            }
            return(View());
        }
        public ActionResult RouteReport(string NepDate, string engdate)
        {
            if (engdate == "")
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DateTime           engdatea        = Convert.ToDateTime(engdate);
            List <RouteReport> prakashanreport = db.RouteReports.Include(m => m.Groupname).Include(m => m.Route).Where(m => m.Date == engdatea).ToList();
            //List<PurchaseReportVM> purchasevm = new List<PurchaseReportVM>();
            var report = db.RouteReports.FirstOrDefault(m => m.Date == engdatea);

            if (report == null)
            {
                TempData["message"] = "No prakashan for record for this date is created";
                return(RedirectToAction("RouteReportByDate"));
            }
            else
            {
                IEnumerable <RouteReport> routes          = db.RouteReports.Where(m => m.NepaliDate == NepDate);
                List <RouteVM>            purchasevm      = new List <RouteVM>();
                List <RouteVM>            purchasevmtotal = new List <RouteVM>();

                var results = (from p in routes
                               group p by p.RouteId into g
                               select new { g.Key }).ToList();

                ViewBag.Routes = results.Select(x => x.Key).ToArray();
                foreach (var item in results.Select(x => x.Key).ToArray())
                {
                    RouteVM objRep = new RouteVM();
                    objRep.gp_total         = routes.Where(m => m.RouteId == item).Sum(m => m.gp_Quantity);
                    objRep.rn_total         = routes.Where(m => m.RouteId == item).Sum(m => m.rn_Quantity);
                    objRep.muna_total       = routes.Where(m => m.RouteId == item).Sum(m => m.muna_Quantity);
                    objRep.madhu_total      = routes.Where(m => m.RouteId == item).Sum(m => m.madhu_Quantity);
                    objRep.yuwa_total       = routes.Where(m => m.RouteId == item).Sum(m => m.Yuwa_Quantity);
                    objRep.gp_grandtotal    = routes.Sum(m => m.gp_Quantity);
                    objRep.rn_grandtotal    = routes.Sum(m => m.rn_Quantity);
                    objRep.muna_grandtotal  = routes.Sum(m => m.muna_Quantity);
                    objRep.madhu_grandtotal = routes.Sum(m => m.madhu_Quantity);
                    objRep.Yuwa_grandtotal  = routes.Sum(m => m.Yuwa_Quantity);
                    objRep.RouteId          = Convert.ToInt32(item);
                    purchasevmtotal.Add(objRep);
                }


                foreach (var item in routes)
                {
                    RouteVM objRep = new RouteVM();
                    objRep.AgentName        = item.Groupname.AgentName;
                    objRep.Id               = item.Id;
                    objRep.Transport        = item.Groupname.Transport;
                    objRep.RouteName        = item.Route.RouteName;
                    objRep.Address          = item.Groupname.Address;
                    objRep.RouteId          = Convert.ToInt32(item.RouteId);
                    objRep.gp_Quantity      = item.gp_Quantity;
                    objRep.rn_Quantity      = item.rn_Quantity;
                    objRep.muna_Quantity    = item.muna_Quantity;
                    objRep.madhu_Quantity   = item.madhu_Quantity;
                    objRep.Yuwa_Quantity    = item.Yuwa_Quantity;
                    objRep.NepaliDate       = item.NepaliDate;
                    objRep.Date             = item.Date;
                    objRep.gp_total         = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).gp_total;
                    objRep.rn_total         = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).rn_total;
                    objRep.muna_total       = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).muna_total;
                    objRep.madhu_total      = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).madhu_total;
                    objRep.yuwa_total       = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).yuwa_total;
                    objRep.gp_grandtotal    = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).gp_grandtotal;
                    objRep.rn_grandtotal    = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).rn_total;
                    objRep.muna_grandtotal  = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).muna_grandtotal;
                    objRep.madhu_grandtotal = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).madhu_grandtotal;
                    objRep.Yuwa_grandtotal  = purchasevmtotal.FirstOrDefault(m => m.RouteId == item.RouteId).Yuwa_grandtotal;
                    purchasevm.Add(objRep);
                }
                log.AddActivity("Route report printed successfully");
                return(View(purchasevm));
            }
        }