Example #1
0
        public ActionResult Create(InvoiceDetail InvoiceDetails)
        {
            if (ModelState.IsValid)
            {
                InvoiceDetails.ID = Guid.NewGuid();
                //InvoiceDetails.PaidDate = DateTime.Now;
                db.InvoiceDetails.Add(InvoiceDetails);
                db.SaveChanges();
                return Content(Boolean.TrueString);
            }

            return View();
        }
Example #2
0
 public virtual MailMessage sendreport(string pathToCreate,string toaddress, InvoiceDetail invoicedetail)
 {
     var report = new MailMessage { Subject = "Invoice report" };
     report.To.Add(toaddress);
     report.Attachments.Add(new Attachment(pathToCreate));
     report.Sender = new MailAddress("*****@*****.**");
     PopulateBody(report, viewName: "report");
     return report;
 }
        public ActionResult SaveFile(InvoiceDetail vm)
        {
            var abresults = new List<InvoiceDetail>();

            var results = new List<Appointment>();
            var allAppt = db.Appointments.ToList();
            Session["Practice"] = db.Practices.Where(p => p.ID == vm.PracticeID).FirstOrDefault();
            foreach (var appt in allAppt)
            {
                var origStartDate = Convert.ToDateTime(appt.startDate);
                var origEndDate = Convert.ToDateTime(appt.endDate);
                if (DateTime.Compare(vm.startDate, origStartDate) <= 0 || DateTime.Compare(vm.endDate, origEndDate) >= 0)
                {
                    if (vm.PracticeID == appt.PracID)
                    {
                        appt.sessionDetail = new Sessions();
                        appt.sessionDetail = db.Sessions.Where(a => a.PID == appt.PracID).FirstOrDefault() != null ? db.Sessions.Where(a => a.PID == appt.PracID).FirstOrDefault() : null;
                        results.Add(appt);
                    }
                }
            }
            if (results != null)
            {
                foreach (var r in results)
                    abresults.Add(new InvoiceDetail()
                    {

                        InvoicedDate = DateTime.Now,
                        ID = Guid.NewGuid(),
                        Appointment = r

                    });

            }
            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/Reports/Invoice.rdlc");
            ReportDataSource reportDataSource = new ReportDataSource("Invoice", abresults);
            localReport.DataSources.Add(reportDataSource);

            string reportType = "pdf";
            string mimeType;
            string encoding;
            string fileNameExtension;
            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
            string deviceInfo =
                "" +
                "  PDF" +
                "  8.5in" +
                "  11in" +
                "  0.5in" +
                "  1in" +
                "  1in" +
                "  0.5in" +
                "";
            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;
            //Render the report
            renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            // Save to Database
            InvoiceFileGenerator dataFile = new InvoiceFileGenerator
            {
                FileName = "Customer",
                FileData = renderedBytes,
                FileExtension = ".pdf",
                isInvoicePaid=false,
                GeneratedDate=DateTime.Now

            };

            bool Status;
            try
            {
                db.Invoices.Add(dataFile);
                db.SaveChanges();
                ViewBag.Status = true;
                return View();
            }
            catch
            {
                ViewBag.Status = false;
                return View();
            }
        }
Example #4
0
        public ActionResult SaveGeneratedInvoice(InvoiceDetail vm, Guid id, decimal total)
        {
            DateTime sd=vm.startDate;
            DateTime ed=vm.endDate;
            var date = "1753-01-01 00:00:00.000";
            vm.Total = total;
            try
            {
                if (ModelState.IsValid)
                {
                    //vm.Appointment.APPID = id;
                    vm.InAppointmentID = id;
                    vm.FileExtension = ".doc";
                    vm.IsPaid = false;
                    vm.PaidDate = Convert.ToDateTime(date);
                    vm.ID = Guid.NewGuid();
                    var person = (Session["Person"] as Person);
                    vm.PersonID = person.ID;
                    string pathToCreate = "~/Reports/" + person.FirstName;
                    if (!Directory.Exists(Server.MapPath(pathToCreate)))
                    {
                        Directory.CreateDirectory(Server.MapPath(pathToCreate));
                    }

                    vm.Filename = "Invoice" + "_" + person.FirstName + "_" + person.ID + ".doc";
                    Generateinvoice docreport = new Generateinvoice();
                    docreport.CreatePackage(Server.MapPath(pathToCreate + "\\" + vm.Filename), Session["Allinvoice"] as List<InvoiceDetail>, Session["Practice"] as Practices);

                    var allappointment = db.Appointments.Where(app => app.APPID == id);
                    foreach (var iteam in allappointment)
                    {
                        vm.startDate = Convert.ToDateTime(iteam.startDate);
                        vm.endDate = Convert.ToDateTime(iteam.endDate);
                        iteam.Invoiced = true;

                    }

                    db.InvoiceDetails.Add(vm);

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("_Form", ex.Message);
            }
            //send mail invoice
            try
            {
                var mailmessage = new System.Net.Mail.MailMessage { Subject = "Reports" };
                var per = (Session["Person"] as Person);
                var Prac = Session["Practice"] as AutoComplete.Models.Practices;
                string pathToCre = "~/Reports/" + per.FirstName + "/Invoice" + "_" + per.FirstName + "_" + per.ID + ".doc";
               //convert into pdf

                //
                string toaddress = Prac.cEmail;
                var to = toaddress;
                mailmessage.Attachments.Add(new Attachment(Server.MapPath(pathToCre)));
                var path = Server.MapPath(pathToCre);
                _userMailer.sendreport(path, to, vm).Send();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("_Form", ex.Message);
            }

            //
            //get Appointment

            var abresults = new List<InvoiceDetail>();
            var results = new List<Appointment>();
            var allAppt = db.Appointments.Where(a => a.Invoiced == false).ToList();
            vm.session = new Sessions();
            vm.session = vm.session;
            Session["Practice"] = db.Practices.Where(p => p.ID == vm.PracticeID).FirstOrDefault();
            var practice = Session["Practice"] as AutoComplete.Models.Practices;
            var name = Session["Person"] as AutoComplete.Models.Person;

            foreach (var appt in allAppt)
            {
                var origStartDate = Convert.ToDateTime(appt.startDate);
                var origEndDate = Convert.ToDateTime(appt.endDate);
                //var day = (origEndDate - origStartDate).TotalDays;

                //int dy = Convert.ToInt32(day) + 1;
                if (sd <= origStartDate && ed >= origEndDate)
                {
                    if (vm.PracticeID == appt.PracID)
                    {
                        appt.sessionDetail = new Sessions();
                        //appt.days = dy;
                        appt.sessionDetail = db.Sessions.Where(a => a.ID == appt.SessID).FirstOrDefault() != null ? db.Sessions.Where(a => a.ID == appt.SessID).FirstOrDefault() : null;
                        results.Add(appt);
                    }
                }
            }
            if (results != null)
            {
                foreach (var r in results)
                    abresults.Add(new InvoiceDetail()
                    {

                        InvoicedDate = DateTime.Now,
                        ID = Guid.NewGuid(),
                        Appointment = r,
                        SessionFees = Convert.ToDecimal(r.Total),
                        SessionName = r.sessionDetail.Name,
                        totalFees = Convert.ToDecimal(r.Total),

                    });

            }
            return View(abresults);
            //get appointment close
        }
Example #5
0
        public ActionResult Saveinvoice(InvoiceDetail InvoiceDetails)
        {
            if (ModelState.IsValid)
            {
                var AppID = Request["Appointment.APPID"];
                InvoiceDetails.ID = Guid.NewGuid();
                InvoiceDetails.PaidDate = DateTime.Now;

                InvoiceDetails.startDate = DateTime.Now;
                InvoiceDetails.endDate = DateTime.Now;
                InvoiceDetails.InvoicedDate = DateTime.Now;
                db.InvoiceDetails.Add(InvoiceDetails);
                db.SaveChanges();
                return Content(Boolean.TrueString);
            }

            return View();
        }
Example #6
0
 public ActionResult mailInvoice(InvoiceDetail invoice)
 {
     var mailmessage = new System.Net.Mail.MailMessage { Subject = "Reports" };
     var person = (Session["Person"] as Person);
     var Prac = Session["Practice"] as AutoComplete.Models.Practices;
     string pathToCreate = "~/Reports/" + person.FirstName + "/Invoice" + "_" + person.FirstName + "_" + person.ID + ".doc";
     string toaddress = Prac.cEmail;
     var to = toaddress;
     mailmessage.Attachments.Add(new Attachment(Server.MapPath(pathToCreate)));
     var path = Server.MapPath(pathToCreate);
     _userMailer.sendreport(path, to, invoice).Send();
     return Content(Boolean.TrueString);
 }
Example #7
0
 public ActionResult SaveGeneratedInvoice()
 {
     var vm = new InvoiceDetail() { startDate = DateTime.Today.Date, endDate = DateTime.Today.Date, IsPaid = false, InvoicedDate = DateTime.Today.Date, PracticeID = Guid.NewGuid() };
     return View();
 }
Example #8
0
        public ActionResult InvoicingreportTable(InvoiceDetail vm, string writer, Guid id)
        {
            var abresults = new List<InvoiceDetail>();
            var results = new List<Appointment>();
            var practice = new Practices();
            var name = Session["Person"] as AutoComplete.Models.Person;
            var allAppt = db.Appointments.Where(a => a.Invoiced == false && a.APPID == id).ToList();
            vm.session = new Sessions();
            vm.session = vm.session;
            decimal total = 0;

            foreach (var appt in allAppt)
            {
                vm.PracticeID = appt.PracID;
                vm.startDate = Convert.ToDateTime(appt.startDate);
                vm.endDate = Convert.ToDateTime(appt.endDate);
                vm.Total =Convert.ToDecimal(appt.Total);
                Session["Practice"] = db.Practices.Where(p => p.ID == appt.PracID).FirstOrDefault();
                practice = Session["Practice"] as AutoComplete.Models.Practices;
                if (practice.ID == appt.PracID)
                {
                    appt.sessionDetail = new Sessions();
                    appt.sessionDetail = db.Sessions.Where(a => a.ID == appt.SessID).FirstOrDefault() != null ? db.Sessions.Where(a => a.ID == appt.SessID).FirstOrDefault() : null;
                    results.Add(appt);
                }
            }
            if (results != null)
            {
                foreach (var r in results)
                    abresults.Add(new InvoiceDetail()
                    {

                        InvoicedDate = DateTime.Now,
                        ID = Guid.NewGuid(),
                        Appointment = r,
                        //SessionFees = Convert.ToDecimal(r.sessionDetail.fees) * r.days,
                        SessionFees = Convert.ToDecimal(r.Total),
                        SessionName = r.sessionDetail.Name,
                        totalFees = Convert.ToDecimal(r.Total),

                    });

                //  Generateinvoice docreport = new Generateinvoice();
                //  docreport.CreatePackage(Server.MapPath("\\Reports\\abc.doc"), abresults, practice);
                Session["Allinvoice"] = abresults;
                var report = new Report(abresults.Select(ap => new { ap.InvoicedDate, ap.SessionName, ap.SessionFees }).ToList().ToReportSource());
                // Customize the Text Fields
                report.TextFields.Header = string.Format(@"<table  width='100%'><tr><td align='left'>
                &nbsp To : {0}
                 Website :  {1}
                 City :  {2}
                 Street Address :  {3}
                 Contact no. :  {4}
                <span style='color:red'>Email</span> :  {5}</td>

            <td align=''>
             From Dr. : {6}
             City :    {7}
              Country :    {8}
               Contact no.:  {9}
             Email : {10} </td></tr></table>", practice.Name, practice.cWebsite, practice.city, practice.streetAdd, practice.cphone, practice.cEmail, name.FirstName, name.city, name.country, name.phone, name.Email);
                report.TextFields.Title = "Invoicing For " + db.Practices.Where(p => p.ID == vm.PracticeID).FirstOrDefault() == null ? "Not Found" : db.Practices.Where(p => p.ID == vm.PracticeID).FirstOrDefault().Name;
                report.TextFields.SubTitle = " From : " + vm.startDate + " End : " + vm.endDate;
                report.TextFields.Footer = string.Format(@"<table width='80%'><tr><td align='right'> Total Fees {0}</td></tr></table>", Convert.ToString(vm.Total));
                // Render hints allow you to pass additional hints to the reports as they are being rendered
                report.RenderHints.BooleanCheckboxes = true;
                report.RenderHints.BooleansAsYesNo = true;
                report.RenderHints.FreezeRows = 20;
                report.RenderHints.FreezeColumns = 10;
                Session["Report"] = report;

                if (writer == "excel") return new ReportResult(report, new DoddleReport.Writers.ExcelReportWriter());

            }
            return View(abresults);
            //return Json(abresults.Select(ap => new { ap.PatientId, ap.TestDateTime,ap.Age, ap.Gender,  ap.TestName, ap.Technician, ap.Result, ap.NormalRange, ap.Name }).ToList(), JsonRequestBehavior.AllowGet);
        }
Example #9
0
 public ActionResult Invoicingreport()
 {
     var vm = new InvoiceDetail() { startDate = DateTime.Today.Date, endDate = DateTime.Today.Date, IsPaid = false, InvoicedDate = DateTime.Today.Date, PracticeID = Guid.NewGuid() };
     var name = Session["Person"] as AutoComplete.Models.Person;
     ViewBag.PracticeID = new SelectList(db.Practices.Where(a => a.PersonID == name.ID), "ID", "Name");
     return View(vm);
 }
Example #10
0
        public ActionResult GetAppointment(InvoiceDetail vm)
        {
            try
            {
                var abresults = new List<InvoiceDetail>();
                var results = new List<Appointment>();
                var allAppt = db.Appointments.Where(a => a.Invoiced == false).ToList();
                vm.session = new Sessions();
                vm.session = vm.session;
                decimal total = 0;
                Session["Practice"] = db.Practices.Where(p => p.ID == vm.PracticeID).FirstOrDefault();
                var practice = Session["Practice"] as AutoComplete.Models.Practices;
                var name = Session["Person"] as AutoComplete.Models.Person;

                foreach (var appt in allAppt)
                {
                    var origStartDate = Convert.ToDateTime(appt.startDate);
                    var origEndDate = Convert.ToDateTime(appt.endDate);
                    //var day = (origEndDate - origStartDate).TotalDays;

                    //int dy = Convert.ToInt32(day) + 1;
                    if (vm.startDate <= origStartDate && vm.endDate >= origEndDate)
                    {
                        if (vm.PracticeID == appt.PracID)
                        {
                            appt.sessionDetail = new Sessions();
                            //appt.days = dy;

                            appt.sessionDetail = db.Sessions.Where(a => a.ID == appt.SessID).FirstOrDefault() != null ? db.Sessions.Where(a => a.ID == appt.SessID).FirstOrDefault() : null;
                            results.Add(appt);
                        }
                    }
                }
                if (results != null)
                {
                    foreach (var r in results)
                        abresults.Add(new InvoiceDetail()
                        {

                            InvoicedDate = DateTime.Now,
                            ID = Guid.NewGuid(),
                            Appointment = r,
                            SessionFees = Convert.ToDecimal(r.Total),
                            SessionName = r.sessionDetail.Name,
                            totalFees = Convert.ToDecimal(r.Total),

                        });

                }
                return View(abresults);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("_Form", ex.Message);
            }
            return View();
        }
Example #11
0
 public ActionResult Edit(InvoiceDetail invoicedetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(invoicedetail).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.InAppointmentID = new SelectList(db.Appointments, "APPID", "Notes", invoicedetail.InAppointmentID);
     return View(invoicedetail);
 }
Example #12
0
        //public ActionResult makepaid(Generateinvoice gi)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.SaveChanges();
        //        return Content(Boolean.TrueString);
        //    }
        //    return View(gi);
        //}
        public ActionResult DetailPensionB(int id, InvoiceDetail vm)
        {
            var abresults = new List<InvoiceDetail>();

            var results = new List<Appointment>();
            var allAppt = db.Appointments.ToList();
            vm.session = new Sessions();
            vm.session = vm.session;

            Session["Practice"] = db.Practices.Where(p => p.ID == vm.PracticeID).FirstOrDefault();
            var practice = Session["Practice"] as AutoComplete.Models.Practices;
            var name = Session["Person"] as AutoComplete.Models.Person;

            return View();
        }