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"));
            }
        }
Exemplo n.º 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));
            }
        }
        public ActionResult Create([Bind(Include = "BranchId,BranchName,BranchAddress,BrachPhone")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                db.Branch.Add(branch);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(branch));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,RouteId,RouteName")] Route route)
        {
            if (ModelState.IsValid)
            {
                db.Routes.Add(route);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(route));
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Id,NewspaperName,CreatedBy,UpdatedBy,CreatedDate,UpdatedDate")] Newspaper.Models.Newspaper newspaper)
        {
            if (ModelState.IsValid)
            {
                db.Newspaper.Add(newspaper);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(newspaper));
        }
Exemplo n.º 6
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";
                return(RedirectToAction("Index"));
            }

            return(View(prakashanGroup));
        }
Exemplo n.º 7
0
        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";
                return(RedirectToAction("Index"));
            }

            ViewBag.RouteId = new SelectList(db.Routes, "Id", "RouteName", groupName.RouteId);
            return(View(groupName));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Id,SalesManId,Area,Comment,CreatedBy,EditedBy,ModifiedBy")] AreaRegister arearegister)
        {
            if (ModelState.IsValid)
            {
                arearegister.CreatedBy  = Session["userEmail"].ToString();
                arearegister.EditedBy   = Session["userEmail"].ToString();
                arearegister.ModifiedBy = Session["userEmail"].ToString();

                try
                {
                    db.AreaRegister.Add(arearegister);
                    db.SaveChanges();
                    String Operation = "Area Registered Sucessfully";
                    db.ActivityLog.Add(new ActivityLog
                    {
                        Operation   = Operation,
                        CreatedBy   = Session["userEmail"].ToString(),
                        CreatedDate = DateTime.Now
                    });
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }

            ViewBag.SalesManId = new SelectList(db.SalesMan, "Id", "FullName", arearegister.SalesManId);
            return(View(arearegister));
        }
        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"));
        }
Exemplo n.º 10
0
        // In this method we will create default User roles and Admin user for login
        private void createUsers()
        {
            NewspaperEntities context = new NewspaperEntities();

            //  var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));
            // var UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));


            // In Startup iam creating  a default Admin User

            var user = new Admin();

            user.EmployeeId   = "100";
            user.UserName     = "******";
            user.FullName     = "Super Admin";
            user.Email        = "*****@*****.**";
            user.Category     = "SuperAdmin";
            user.Phone        = "01-4220638";
            user.Password     = Crypto.Hash("admin123");
            user.CreatedDate  = DateTime.Now;
            user.ModifiedDate = DateTime.Now;
            user.PPSizePhoto  = "~/img/17.jpg";
            user.Status       = true;

            if (context.Admin.ToList().Count == 0)
            {
                context.Admin.Add(user);
                context.SaveChanges();
            }

            //string userPWD = "admin123";


            //var chkUser = UserManager.Create(user, userPWD);
        }
        public ActionResult NewspaperToPrint(FormCollection col)
        {
            List <SelectSalesManVM> publishNewspaper = new List <SelectSalesManVM>();

            DateTime date = Convert.ToDateTime(col["NewpaperToPublish"]);
            string   Date = col["NepDate"].ToString();

            if (date > DateTime.Now)
            {
                NewspaperEntities db = new NewspaperEntities();


                string Email = Session["userEmail"].ToString();

                //DateTime endedDate = db.Customer.Include("Service").FirstOrDefault(m => m.EndedDate > date).EndedDate;
                var Newspaper = db.ServiceAssign.FirstOrDefault(m => m.EndedDate > date && m.PaperDispatchDate < date);


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

                if (Newspaper == null)
                {
                    TempData["message"] = "No record found.";
                    return(RedirectToAction("SelectPublishDate"));
                }
                for (int i = 0; i < Paper.ToList().Count; i++)
                {
                    int    newsId        = Int32.Parse(Paper[i].newspaperId.ToString());
                    string newspapername = db.Service.FirstOrDefault(m => m.Id == newsId).NewsPaperName;
                    publishNewspaper.Add(new SelectSalesManVM {
                        NepDate = Date, NewsPaperName = newspapername, Count = Paper[i].Count, branch = "All Branches"
                    });
                    // imagesList.Add(new SelectSalesManVM { NewsPaperName=customer[i].ServiceId, Count = customer[i].Count });
                }

                try
                {
                    string operation = "Estimated Report to print Newspaper is created by" + " " + Email;
                    db.ActivityLog.Add(new ActivityLog
                    {
                        Operation   = operation,
                        CreatedBy   = Session["userEmail"].ToString(),
                        CreatedDate = DateTime.Now
                    });
                    db.SaveChanges();
                }
                catch
                {
                    ViewBag.ErrorMessage = "Estimated Report Failed To Print";
                }
                return(View(publishNewspaper));
            }
            else
            {
                TempData["message"] = "You cannot Estimate for this date";
                return(RedirectToAction("SelectPublishDate"));
            }
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "Id,SalesManId,FullName,Email,BranchId,AltEmail,Phone1,Phone2")] SalesMan salesman)
        {
            if (ModelState.IsValid)
            {
                //salesman.BranchId = Convert.ToInt32(Session["BranchId"].ToString());


                try
                {
                    db.SalesMan.Add(salesman);
                    db.SaveChanges();
                    //int BranchId = Convert.ToInt32(Session["BranchId"].ToString());
                    String Operation = "Sales Man 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());
                }
            }

            return(View(salesman));
        }
Exemplo n.º 13
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());
                }
            }
        }
        public ActionResult Create(List <RouteVM> routes, FormCollection col)
        {
            if (ModelState.IsValid)
            {
                DateTime date    = Convert.ToDateTime(col["EnglishDate"]);
                string   Nepdate = col["NepaliDate"].ToString();
                var      report  = db.RouteReports.FirstOrDefault(m => m.Date == date);
                if (report == null)
                {
                    foreach (var item in routes)
                    {
                        RouteReport rep = new RouteReport();
                        rep.Route   = db.Routes.Find(item.RouteId);
                        rep.RouteId = item.RouteId;

                        rep.NepaliDate     = Nepdate;
                        rep.Date           = date;
                        rep.gp_Quantity    = item.gp_Quantity;
                        rep.rn_Quantity    = item.rn_Quantity;
                        rep.muna_Quantity  = item.muna_Quantity;
                        rep.madhu_Quantity = item.madhu_Quantity;
                        rep.Yuwa_Quantity  = item.Yuwa_Quantity;
                        rep.AgentId        = item.AgentId; //GroupId as AgentId
                        rep.Groupname      = db.groupNames.Find(item.AgentId);
                        db.RouteReports.Add(rep);
                        db.SaveChanges();
                    }
                    log.AddActivity("Route report inserted successfully");
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["message"] = " Production Record for this date is already stored please edit this record here";
                    return(RedirectToAction("EditByDate"));
                }
            }
            var results = (from p in db.groupNames
                           group p by p.RouteId into g
                           select new { g.Key }).ToList();

            ViewBag.Routes = results.Select(x => x.Key).ToArray();


            return(View(routes));
        }
Exemplo n.º 15
0
        public ActionResult ChangePassword(ChangePasswordViewModel ch)
        {
            int employeeid = Convert.ToInt32(Session["Id"].ToString());

            Admin us = _db.Admin.Single(m => m.Id == employeeid);// (u => u.Id == employeeid && u.Password == ch.OldPassword).FirstOrDefault();

            if (us != null)
            {
                var pass = Crypto.Hash(ch.OldPassword);
                if (string.Compare(pass, us.Password) == 0)

                {
                    if (ch.NewPassword == ch.ConfirmNew)
                    {
                        us.Password = Crypto.Hash(ch.NewPassword);
                        _db.SaveChanges();
                        ViewBag.Message = "Password Changed Successfully";
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "New Password and Confirm Password Mismatched";
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = "Password not matched with previous one!";
                }
            }
            ModelState.Clear();
            return(View());
        }
Exemplo n.º 16
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();
         return(Json(true));
     }
     catch
     {
         return(Json(false));
     }
 }
Exemplo n.º 17
0
 public void AddActivity(string message)
 {
     if (!string.IsNullOrEmpty(message))
     {
         db.ActivityLog.Add(new ActivityLog
         {
             //BranchId = customer.BranchId,
             Operation   = message,
             CreatedBy   = HttpContext.Current.Session["userEmail"].ToString(),
             CreatedDate = DateTime.Now
         });
         db.SaveChanges();
     }
 }
Exemplo n.º 18
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());
                }
            }
        }
Exemplo n.º 19
0
        public ActionResult Create(Customer customer, FormCollection col)
        {
            int      days        = Convert.ToInt32(col["HoldingDays"].ToString());
            string   datestr     = col["EndedDate"];
            DateTime date        = Convert.ToDateTime(col["EndedDate"]);
            var      objCustomer = db.Customer.Find(customer.Id);
            // int remainDays = objCustomer.EndedDate-DateTime.Now;
            DateTime holdingEndedDate = date.AddDays(days);

            //  DateTime customerEndedDate = date.AddDays(days+|)
            if (date > DateTime.Now)
            {
                customer.PaperDispatchDate = customer.EndedDate.AddDays(days);
            }
            db.HoldingDays.Add(new HoldingDays {
                CustomerId = customer.Id, HoldingStartDays = date, HoldingEndDays = customer.EndedDate
            });
            db.SaveChanges();


            objCustomer.EndedDate = customer.EndedDate;
            db.SaveChanges();
            return(View());
        }
Exemplo n.º 20
0
        public ActionResult Create(assignNewspaperVM serviceAssign)
        {
            if (!db.ServiceAssign.Any(m => m.NewspaperId == serviceAssign.NewspaperId && m.CustomerId == serviceAssign.CustomerId))
            {
                serviceAssign.EndedDate = serviceAssign.PaperDispatchDate.AddDays(serviceAssign.Duration);

                ServiceAssign objService = new ServiceAssign();

                objService.NepaliDate        = serviceAssign.NepaliDate;
                objService.NewspaperId       = serviceAssign.NewspaperId;
                objService.SalesManId        = serviceAssign.SalesManId;
                objService.Duration          = serviceAssign.Duration.ToString();
                objService.PaperDispatchDate = Convert.ToDateTime(serviceAssign.PaperDispatchDate.ToShortDateString());
                objService.status            = true;
                objService.UpdatedBy         = serviceAssign.UpdatedBy;
                objService.UpdatedDate       = serviceAssign.UpdatedDate;
                objService.CreatedBy         = serviceAssign.CreatedBy;
                objService.CreatedDate       = serviceAssign.CreatedDate;
                objService.CustomerId        = serviceAssign.CustomerId;
                objService.Quantity          = serviceAssign.Quantity;
                objService.EndedDate         = Convert.ToDateTime(serviceAssign.EndedDate.ToShortDateString());

                db.ServiceAssign.Add(objService);


                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));
            }
        }
Exemplo n.º 21
0
        public ActionResult Create([Bind(Include = "Id,ServiceCode,NewsPaperName,TimeBase,CreatedBy,EditedBy,EditedDate,images")] Service service, HttpPostedFileBase ImageFile)
        {
            if (ModelState.IsValid)
            {
                service.CreatedBy  = Session["userEmail"].ToString();
                service.EditedBy   = Session["userEmail"].ToString();
                service.EditedDate = DateTime.Now;


                HttpFileCollectionBase image = Request.Files;
                string filename = image[0].FileName; /* service.NewsPaperName + ".jpg";*/
                string name     = "/Images/Newspaper/";
                bool   exist    = System.IO.Directory.Exists(Server.MapPath(name));
                if (!exist)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(name));
                }
                service.Images = "/Images/Newspaper/" + filename;
                if (ImageFile != null)
                {
                    filename = Path.Combine(Server.MapPath("~/Images/Newspaper/"), filename);
                    ImageFile.SaveAs(filename);
                }

                try
                {
                    db.Service.Add(service);
                    db.SaveChanges();
                    String Operation = "Service Created Sucessfully";
                    db.ActivityLog.Add(new ActivityLog
                    {
                        Operation   = Operation,
                        CreatedBy   = Session["userEmail"].ToString(),
                        CreatedDate = DateTime.Now
                    });
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }

            return(View(service));
        }
Exemplo n.º 22
0
        public int CreateAdmin(AdminViewModel av)
        {
            Admin tb = new Admin();

            tb.EmployeeId   = av.EmployeeId;
            tb.FullName     = av.FullName;
            tb.Email        = av.Email;
            tb.UserName     = av.UserName;
            tb.Password     = av.Password;
            tb.Phone        = av.Phone;
            tb.WorkPhone    = av.WorkPhone;
            tb.URL          = av.URL;
            tb.PPSizePhoto  = av.PPSizePhoto;
            tb.CreatedDate  = DateTime.Now; // av.CreatedDate;
            tb.ModifiedDate = DateTime.Now; //av.ModifiedDate;
            tb.CreatedBy    = av.CreatedBy;
            tb.ModifiedBy   = av.ModifiedBy;
            _db.Admin.Add(tb);
            return(_db.SaveChanges());
        }
Exemplo n.º 23
0
        public ActionResult RenewCustomerReport(FormCollection col)
        {
            List <AddedCustomerVM> AddedCustomerVM = new List <AddedCustomerVM>();
            int ServiceId = Convert.ToInt32(col["ServiceId"]);

            string   AddedDate = col["NepDate"].ToString();
            DateTime date      = Convert.ToDateTime(col["RegisterDate"]);

            NewspaperEntities db = new NewspaperEntities();
            {
                var Newspaper = (from p in db.ServiceAssign
                                 from c in db.Customer
                                 from s in db.SalesMan
                                 from e in db.Service
                                 // replace  && p.CustomerId == c.Id && p.SalesManId == s.Id && p.NewspaperId == e.Id
                                 //where p.NewspaperId == e.Id && p.CreatedDate == date && p.CustomerId.ToString() == c.CustomerId && p.SalesManId == s.Id && p.NewspaperId == ServiceId
                                 where p.NewspaperId == ServiceId && p.UpdatedDate == date && p.PaymentType == true && p.CustomerId == c.Id && p.SalesManId == s.Id && p.NewspaperId == e.Id
                                 select new
                {
                    serviceId = p.NewspaperId,
                    FirstName = c.FirstName,
                    quantity = p.Quantity,
                    NepaliDate = p.NepaliDate,
                    SalesMan = s.FullName,
                    MPhone = c.MPhone,
                    Address = c.Address,
                    PaperDispatchDate = p.PaperDispatchDate,
                    EndedDate = p.EndedDate,

                    NewspaperName = e.NewsPaperName,
                    date = p.UpdatedDate,
                    CustomerId = c.CustomerId
                }).ToList();

                if (Newspaper == null || Newspaper.Count == 0)
                {
                    TempData["message"] = "No record found.";
                    return(RedirectToAction("SelectRewNewspaper"));
                }
                for (int i = 0; i < Newspaper.ToList().Count; i++)
                {
                    if (Newspaper[i].CustomerId == null)
                    {
                        AddedCustomerVM.Add(new AddedCustomerVM {
                            dispatch = ADTOBS.EngToNep(Newspaper[i].PaperDispatchDate).ToString(), enddate = ADTOBS.EngToNep(Newspaper[i].EndedDate).ToString(), NewsPaperName = Newspaper[i].NewspaperName, NepaliDate = AddedDate, SalesMan = Newspaper[i].SalesMan /*, NewsPaperName =Newspaper[i].NewspaperName*/, ReportDate = Newspaper[i].date, FirstName = Newspaper[i].FirstName, quantity = Convert.ToInt32(Newspaper[i].quantity).ToString(), Address = Newspaper[i].Address, MPhone = Newspaper[i].MPhone, PaperDispatchDate = Newspaper[i].PaperDispatchDate, EndedDate = Newspaper[i].EndedDate, branch = "All Branches"
                        });
                    }
                    else
                    {
                        AddedCustomerVM.Add(new AddedCustomerVM
                        {
                            dispatch          = ADTOBS.EngToNep(Newspaper[i].PaperDispatchDate).ToString(),
                            enddate           = ADTOBS.EngToNep(Newspaper[i].EndedDate).ToString(),
                            NewsPaperName     = Newspaper[i].NewspaperName,
                            quantity          = Convert.ToInt32(Newspaper[i].quantity).ToString(),
                            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(),
                        });
                    }
                }
                if (AddedCustomerVM == null)
                {
                    TempData["message"] = "No record found.";
                    return(RedirectToAction("SelectRewNewspaper"));
                }
                try
                {
                    String Operation = "Renew Customer Report Printed";
                    db.ActivityLog.Add(new ActivityLog
                    {
                        Operation   = Operation,
                        CreatedBy   = Session["userEmail"].ToString(),
                        CreatedDate = DateTime.Now
                    });
                    db.SaveChanges();
                }
                catch
                {
                    ViewBag.ErrorMessage = "Email sending failed";
                }
                return(View(AddedCustomerVM));
            }
        }
Exemplo n.º 24
0
        public ActionResult DistributorAddReport(FormCollection col)
        {
            List <DistributorVM> DistributorVM = new List <DistributorVM>();
            int               ServiceId        = Convert.ToInt32(col["ServiceId"]);
            string            EndedDate        = col["NepDate"].ToString();
            DateTime          date             = Convert.ToDateTime(col["EndedDate"]);
            DateTime          yes       = date.AddDays(-1);
            NewspaperEntities db        = new NewspaperEntities();
            int               serviceId = Convert.ToInt32(col["ServiceId"].ToString());

            var objService = db.Service.Find(serviceId);

            var paperAll = db.ServiceAssign.Where(m => m.EndedDate >= date && m.PaperDispatchDate <= date).Where(m => m.NewspaperId == serviceId).GroupBy(n => n.SalesManId)
                           .Select(g => new { FullName = g.Key, SalesManId = g.Key, Count = g.Sum(m => m.Quantity) }).ToList();

            var PaperTotal = db.ServiceAssign.Where(m => m.EndedDate >= yes && m.PaperDispatchDate <= yes).Where(m => m.NewspaperId == serviceId).GroupBy(n => n.SalesManId)
                             .Select(g => new { FullName = g.Key, SalesManId = g.Key, Count = g.Sum(m => m.Quantity) }).ToList();
            var substracted = db.ServiceAssign.Where(m => m.EndedDate == date).Where(m => m.NewspaperId == serviceId).GroupBy(n => n.SalesManId)
                              .Select(g => new { FullName = g.Key, SalesManId = g.Key, Count = g.Sum(m => m.Quantity) }).ToList();

            var added = db.ServiceAssign.Where(m => m.PaperDispatchDate == date).Where(m => m.NewspaperId == serviceId).GroupBy(n => n.SalesManId)
                        .Select(g => new { FullName = g.Key, SalesManId = g.Key, Count = g.Sum(m => m.Quantity) }).ToList();

            for (int i = 0; i < paperAll.Count; i++)
            {
                int addedInt = 0, substractInt = 0, paperTotalInt = 0;
                if (PaperTotal.FirstOrDefault(m => m.SalesManId == paperAll[i].SalesManId) == null)
                {
                    paperTotalInt = 0;
                }
                else
                {
                    paperTotalInt = PaperTotal.FirstOrDefault(m => m.SalesManId == paperAll[i].SalesManId).Count;
                }

                if (added.FirstOrDefault(m => m.SalesManId == paperAll[i].SalesManId) == null)
                {
                    addedInt = 0;
                }
                else
                {
                    addedInt = added.FirstOrDefault(m => m.SalesManId == paperAll[i].SalesManId).Count;
                }

                if (substracted.FirstOrDefault(m => m.SalesManId == paperAll[i].SalesManId) == null)
                {
                    substractInt = 0;
                }
                else
                {
                    substractInt = substracted.FirstOrDefault(m => m.SalesManId == paperAll[i].SalesManId).Count;
                }


                DistributorVM.Add(new DistributorVM
                {
                    DistributorName = db.SalesMan.Find(paperAll[i].SalesManId).FullName,
                    newspaperName   = objService.NewsPaperName,
                    Quantity        = paperTotalInt,

                    Added      = addedInt,
                    Subs       = substractInt,
                    NepaliDate = EndedDate,
                });
            }
            try
            {
                string operation = "Distributor Report is created";
                db.ActivityLog.Add(new ActivityLog
                {
                    Operation   = operation,
                    CreatedBy   = Session["userEmail"].ToString(),
                    CreatedDate = DateTime.Now,
                });
                db.SaveChanges();
            }
            catch
            {
                ViewBag.ErrorMessage = "Distributor Report Failed to print";
            }
            if (DistributorVM.Count == 0)
            {
                TempData["message"] = "No record found.";
                return(RedirectToAction("SelectDistributorDate"));
            }

            return(View(DistributorVM));
        }
Exemplo n.º 25
0
        public ActionResult ExpiredCustomerBydate(FormCollection col)
        {
            List <AddedCustomerVM> AddedCustomerVM = new List <AddedCustomerVM>();
            string   EndedDate = col["NepDate"].ToString();
            DateTime date      = Convert.ToDateTime(col["EndedDate"]);

            NewspaperEntities db = new NewspaperEntities();

            var Newspaper = (from s in db.ServiceAssign
                             from e in db.Service
                             from d in db.SalesMan
                             from c in db.Customer
                             where s.EndedDate == date && s.CustomerId == c.Id && s.SalesManId == d.Id && s.NewspaperId == e.Id
                             select new
            {
                ServiceId = s.NewspaperId,
                FirstName = c.FirstName,
                SalesMan = d.FullName,
                MPhone = c.MPhone,
                Address = c.Address,
                NewspaperName = e.NewsPaperName,
                date = s.EndedDate,
                CustomerId = c.CustomerId
            }).ToList();



            if (Newspaper == null || Newspaper.Count == 0)
            {
                TempData["message"] = "No record found.";
                return(RedirectToAction("SelectDate"));
            }
            for (int i = 0; i < Newspaper.ToList().Count; i++)
            {
                AddedCustomerVM.Add(new AddedCustomerVM {
                    enddate = ADTOBS.EngToNep(date).ToString(), EndedDate = date, NepaliDate = EndedDate, SalesMan = Newspaper[i].SalesMan, NewsPaperName = Newspaper[i].NewspaperName, ReportDate = Newspaper[i].date, FirstName = Newspaper[i].FirstName, Address = Newspaper[i].Address, MPhone = Newspaper[i].MPhone, CustomerId = Newspaper[i].CustomerId
                });
            }
            if (AddedCustomerVM == null)
            {
                TempData["message"] = "No record found.";
                return(RedirectToAction("SelectDistributorDate"));
            }
            try
            {
                String Operation = "Expired Reported printed";

                db.ActivityLog.Add(new ActivityLog
                {
                    Operation   = Operation,
                    CreatedBy   = Session["userEmail"].ToString(),
                    CreatedDate = DateTime.Now
                });
                db.SaveChanges();
            }
            catch
            {
                ViewBag.ErrorMessage = "Email sending failed";
            }

            return(View(AddedCustomerVM));
        }
Exemplo n.º 26
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();
            //    }
            //}
        }
Exemplo n.º 27
0
        public ActionResult CustomMail(MailViewModel mm)
        {
            List <string> email = db.Customer.Where(s => (DbFunctions.DiffDays(DateTime.Now, s.EndedDate) >= 0))
                                  .Select(t => t.Email).ToList();

            //string from = "*****@*****.**";
            // string fromPassword = "******";

            if (email != null)
            {
                try
                {
                    int i;
                    for (i = 0; i <= email.Count; i++)
                    {
                        try
                        {
                            string str = "<font size='5'>Regards <br/> <b>DebugSoft</b></font>";
                            using (MailMessage mail = new MailMessage(/*from, email[i]*/))
                            {
                                List <string> Name = db.Customer.Where(s => (DbFunctions.DiffDays(DateTime.Now, s.EndedDate) >= 0))
                                                     .Select(t => t.FirstName).ToList();

                                mail.To.Add(new MailAddress(email[i]));
                                mail.Subject = mm.MailSubject;

                                mail.IsBodyHtml = true;
                                mail.Body       = "Dear" + " " + Name[i] + "," + mm.MailBody + "<br/>" + "Thank You<br/>" + str;


                                SmtpClient smtp = new SmtpClient();
                                //smtp.Host = "smtp.gmail.com";
                                //smtp.EnableSsl = true;
                                //smtp.UseDefaultCredentials = false;
                                //NetworkCredential networkCredential = new NetworkCredential(from, fromPassword);

                                //smtp.Credentials = networkCredential;
                                //smtp.Port = 587;
                                smtp.Send(mail);
                            }
                        }
                        catch
                        {
                            ViewBag.Message = "Custom Mail sent";
                        }
                    }
                }
                catch
                {
                    ViewBag.ErrorMessage = "Email sending failed";
                }
                try
                {
                    String Operation = "Custom mail sent";
                    db.ActivityLog.Add(new ActivityLog
                    {
                        Operation   = Operation,
                        CreatedBy   = Session["userEmail"].ToString(),
                        CreatedDate = DateTime.Now
                    });
                    db.SaveChanges();
                }
                catch
                {
                    ViewBag.ErrorMessage = "Email sending failed";
                }
            }


            return(View());
        }
Exemplo n.º 28
0
        public ActionResult CustomerActivate(string BillNo, string PaymentDate, string Duration, string NepaliDate1, DateTime PaperDispatchDate, string Nepalidate, string PaymentType, string BankName, string ACNumber, decimal Amount, decimal Discount, int id)
        {
            ServiceAssign objserviceAssign = db.ServiceAssign.Find(id);
            int           quant            = objserviceAssign.Quantity;

            //if (objserviceAssign.BillNo != null && objserviceAssign.EndedDate < PaperDispatchDate)
            //{
            objserviceAssign.Duration = Duration;
            //}
            objserviceAssign.NepaliDate = NepaliDate1;


            objserviceAssign.PaperDispatchDate = PaperDispatchDate;
            objserviceAssign.Amount            = Amount;
            objserviceAssign.Discount          = Discount;
            decimal AWithoutDis = quant * Amount;

            objserviceAssign.DiscountAmount = objserviceAssign.Quantity * AWithoutDis * (Discount / 100);
            objserviceAssign.GrandTotal     = AWithoutDis - objserviceAssign.DiscountAmount;
            objserviceAssign.BillNo         = BillNo;
            if (objserviceAssign.status)
            {
                objserviceAssign.EndedDate = objserviceAssign.PaperDispatchDate.AddDays(Convert.ToInt32(Duration));
                objserviceAssign.status    = false;
            }
            else
            {
                if (objserviceAssign.EndedDate.Date > DateTime.Now.Date)
                {
                    objserviceAssign.EndedDate = objserviceAssign.EndedDate.AddDays(Convert.ToInt32(Duration));
                }
                else if (objserviceAssign.EndedDate.Date < DateTime.Now.Date)
                {
                    objserviceAssign.EndedDate = objserviceAssign.PaperDispatchDate.AddDays(Convert.ToInt32(Duration));
                }
            }

            db.SaveChanges();

            Account objAccount = new Account();

            objAccount.Amount         = objserviceAssign.GrandTotal;
            objAccount.Paymentdate    = Convert.ToDateTime(PaymentDate);
            objAccount.Nepalidate     = Nepalidate;
            objAccount.BankName       = BankName;
            objAccount.BankAcc        = ACNumber;
            objAccount.DiscountAmount = objserviceAssign.DiscountAmount;
            objAccount.CustomerId     = objserviceAssign.CustomerId;
            objAccount.NewspaperId    = objserviceAssign.NewspaperId;
            objAccount.CreatedBy      = "counter";
            objAccount.CreatedDate    = DateTime.Now;
            objAccount.UpdateDate     = DateTime.Now;
            objAccount.UpdatedBy      = "counter";
            objAccount.fiscalyear     = db.FiscalYear.FirstOrDefault(m => m.Status == true);
            objAccount.FiscalYear     = db.FiscalYear.FirstOrDefault(m => m.Status == true).NepYear;
            objAccount.BillNo         = Convert.ToInt32(BillNo);
            objAccount.Payoption      = PaymentType;
            db.Account.Add(objAccount);
            db.SaveChanges();
            string accId = db.Account.OrderByDescending(m => m.Id).FirstOrDefault().Id.ToString();


            // return ReportCounter(BillNo.ToString());
            return(RedirectToAction("ReportCounter", "Counter", new { BillNo = accId }));//
        }
Exemplo n.º 29
0
        public ActionResult ForgetPassword(Admin admin)
        {
            //string from = "usern";
            //string fromPassword = "******";

            string password = Membership.GeneratePassword(6, 1);

            if (admin.Email != null)
            {
                var mail = new MailMessage();

                //using (MailMessage mail = new MailMessage(admin.Email))


                try
                {
                    var tb = _db.Admin.Where(u => u.Email == admin.Email).FirstOrDefault();

                    if (tb == null)
                    {
                        ViewBag.Message = "email Doesnot Exist Please enter valid email";
                    }
                    else
                    {
                        mail.To.Add(new MailAddress(admin.Email));

                        mail.Subject = "Password Recovery";
                        mail.Body    = "Use this Password to login:"******"smtp.gmail.com";
                            //smtp.EnableSsl = true;
                            //smtp.UseDefaultCredentials = false;
                            //NetworkCredential networkCredential = new NetworkCredential(from, fromPassword);

                            //smtp.Credentials = networkCredential;
                            //smtp.Port = 587;
                            smtp.Send(mail);

                        ViewBag.Message = "Your Password Is Sent to your email";
                        var query = (from q in _db.Admin
                                     where q.Email == admin.Email
                                     select q).First();
                        query.randompass = password;
                        _db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    return(RedirectToAction(e.ToString().Substring(0, 100) + "errorpage"));
                }
                TempData["Message"] = admin.Email;
                TempData.Keep();
                return(RedirectToAction("conformation"));
            }



            var errors = ModelState.Where(x => x.Value.Errors.Count > 0)
                         .Select(x => new { x.Key, x.Value.Errors }).ToArray();


            return(View());


            //return RedirectToAction("Index", "Home");
        }