Ejemplo n.º 1
0
        public JsonResult SaveEvent(Schedule s)
        {
            var status = false;

            using (ERP1DataContext dc = new ERP1DataContext())
            {
                if (s.EventID > 0)
                {
                    //Update the event
                    var v = dc.Schedules.Where(a => a.EventID == s.EventID).FirstOrDefault();
                    if (v != null)
                    {
                        v.Subject     = s.Subject;
                        v.Start       = s.Start;
                        v.End         = s.End;
                        v.Description = s.Description;
                        v.IsFullDay   = s.IsFullDay;
                        v.Theme       = s.Theme;
                    }
                }
                else
                {
                    dc.Schedules.InsertOnSubmit(s);
                }
                dc.SubmitChanges();
                status = true;
            }

            return(new JsonResult {
                Data = new { status = status }
            });
        }
Ejemplo n.º 2
0
        public JsonResult SaveBill(BillVM B)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (ERP1DataContext dc = new ERP1DataContext())
                {
                    string Day   = DateTime.Now.Day.ToString();
                    string Month = DateTime.Now.Month.ToString();
                    string Year  = DateTime.Now.Year.ToString();
                    Bill   bill  = new Bill {
                        AppointmentID = B.AppointmentID, DoctorID = B.DoctorID, PatientID = B.PatientID, TotalAmount = decimal.Parse(B.TotalAmount), AddedDay = Day, AddedMonth = Month, AddedYear = Year
                    };
                    foreach (var i in B.BillDetails)
                    {
                        //
                        // i.TotalAmount =
                        bill.BillDetails.Add(i);
                    }
                    dc.Bills.InsertOnSubmit(bill);
                    dc.SubmitChanges();
                    status = true;
                    return(new JsonResult {
                        Data = new { status = status }
                    });
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Ejemplo n.º 3
0
        public JsonResult SaveOrder(OrderVM O)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (ERP1DataContext dc = new ERP1DataContext())
                {
                    Order Order = new Order {
                        OrderDate = O.OrderDate, OrderStatus = O.OrderStatus, TotalAmount = O.TotalAmount, Payment = O.Payment
                    };
                    foreach (var i in O.OrderDetails)
                    {
                        //
                        // i.TotalAmount =
                        Order.OrderDetails.Add(i);
                    }
                    dc.Orders.InsertOnSubmit(Order);
                    dc.SubmitChanges();
                    status = true;
                }
            }
            else
            {
                status = false;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Ejemplo n.º 4
0
        //Get Event
        public JsonResult GetEvents()
        {
            using (ERP1DataContext dc = new ERP1DataContext())
            {
                var events = dc.Schedules.ToList();

                return(new JsonResult {
                    Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
Ejemplo n.º 5
0
        public JsonResult SaveInvoice(InvoiceVM I)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (ERP1DataContext dc = new ERP1DataContext())
                {
                    string  Day     = DateTime.Now.Day.ToString();
                    string  Month   = DateTime.Now.Month.ToString();
                    string  Year    = DateTime.Now.Year.ToString();
                    Invoice invoice = new Invoice {
                        InvoiceDate = I.InvoiceDate, TotalAmount = I.TotalAmount, InvoiceStatus = I.InvoiceStatus, Payment = I.Payment, AppointmentID = I.AppointmentID, AddedDay = Day, AddedMonth = Month, AddedYear = Year
                    };
                    foreach (var i in I.InvoiceDetails)
                    {
                        //
                        // i.TotalAmount =
                        invoice.InvoiceDetails.Add(i);
                    }
                    dc.Invoices.InsertOnSubmit(invoice);
                    foreach (var v in I.QuantityDetails)
                    {
                        var data = dc.Stocks.Where(s => s.StockID == v.StockID).ToList();
                        foreach (Stock s in data)
                        {
                            s.Quantity = s.Quantity - v.Quantity;
                        }
                        foreach (var item in I.QuantityDetails)
                        {
                            StockOut Sout = new StockOut();
                            Sout.StockID       = item.StockID;
                            Sout.StockName     = item.ItemName;
                            Sout.StockQuantity = item.Quantity;
                            Sout.StockRevenue  = item.cast;
                            Sout.AddedDay      = Day;
                            Sout.AddedMonth    = Month;
                            Sout.AddedYear     = Year;
                            dc.StockOuts.InsertOnSubmit(Sout);
                        }
                    }
                    dc.SubmitChanges();
                    status = true;
                }
            }
            else
            {
                status = false;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Ejemplo n.º 6
0
        public List <AppointmentDetails> getAppointmentDetails(int ID)
        {
            ERP1DataContext dc     = new ERP1DataContext();
            var             result = from app in dc.Appointments
                                     join doc in dc.Doctors on app.DoctorID equals doc.DoctorID
                                     join p in dc.Patients on app.PatientID equals p.PatientID
                                     where app.PatientID == ID
                                     select new
            {
                AppointmentID  = app.AppointmentID,
                DoctorID       = doc.DoctorID,
                Department     = doc.Designation,
                DoctorName     = doc.FirstName + doc.LastName,
                DoctorImage    = doc.Image,
                DoctorEmail    = doc.DoctorEmail,
                PatientID      = p.PatientID,
                PatientName    = p.PatientName,
                PatientEmail   = p.PatientEmail,
                PatientContact = p.PatientContact,
                PatientImage   = p.PatientImage,
                Date           = app.Date,
                TimeSlot       = app.TimeSlot,
                Status         = app.Status
            };

            var data = from r in result where (r.Status == "Scheduled") select r;

            if (data != null)
            {
                foreach (var v in data)
                {
                    AppointmentDetails details = new AppointmentDetails();
                    details.AppointmentID  = v.AppointmentID;
                    details.DoctorID       = v.DoctorID;
                    details.Designation    = v.Department;
                    details.DoctorName     = v.DoctorName;
                    details.DoctorImage    = v.DoctorImage;
                    details.DoctorEmail    = v.DoctorEmail;
                    details.PatientID      = v.PatientID;
                    details.PatientName    = v.PatientName;
                    details.PatientEmail   = v.PatientEmail;
                    details.PatientContact = v.PatientContact;
                    details.PatientImage   = v.PatientImage;
                    details.Date           = v.Date.ToString();
                    details.TimeSlot       = v.TimeSlot;
                    AppList.Add(details);
                }

                return(AppList);
            }

            return(AppList);
        }
Ejemplo n.º 7
0
        public JsonResult CheckPassword(string Password)
        {
            using (ERP1DataContext dc = new ERP1DataContext())
            {
                var result = dc.Users.Where(x => x.Password == Password).FirstOrDefault();

                if (result != null)
                {
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 8
0
        public void SaveAppointment(AppointmentModel amodel)
        {
            ERP1DataContext dc  = new ERP1DataContext();
            Appointment     App = new Appointment();

            {
                App.DoctorID    = amodel.DoctorID;
                App.PatientID   = amodel.PatientID;
                App.Description = amodel.Description;
                App.Date        = amodel.Date;
                App.TimeSlot    = amodel.TimeSlot;
            }
            dc.Appointments.InsertOnSubmit(App);
            dc.SubmitChanges();
        }
Ejemplo n.º 9
0
        public JsonResult CheckSchedule(string Date)
        {
            DateTime date = Convert.ToDateTime(Date);;

            using (ERP1DataContext dc = new ERP1DataContext())
            {
                var result = dc.Schedules.Where(x => x.Start.Date == date.Date).FirstOrDefault();

                if (result != null)
                {
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 10
0
        public bool DeleteAppointment(int Id, bool status)
        {
            using (ERP1DataContext dc = new ERP1DataContext())
            {
                var AppData = dc.Appointments.Where(a => a.AppointmentID == Id).ToList();

                if (AppData != null)
                {
                    foreach (Appointment ds in AppData)
                    {
                        dc.Appointments.DeleteOnSubmit(ds);
                    }
                    dc.SubmitChanges();
                    return(status = true);
                }
                return(status = false);
            }
        }
Ejemplo n.º 11
0
        //book
        public bool BookDoctor(AppointmentModel App, bool status)
        {
            using (ERP1DataContext dc = new ERP1DataContext())
            {
                Appointment A = new Appointment();
                A.DoctorID    = App.DoctorID;
                A.PatientID   = App.PatientID;
                A.Date        = App.Date;
                A.Description = App.Description;
                A.TimeSlot    = App.TimeSlot;
                A.Status      = "Scheduled";
                dc.Appointments.InsertOnSubmit(A);
                dc.SubmitChanges();
                status = true;

                return(status);
            }
        }
Ejemplo n.º 12
0
        //timeSlot
        public bool TimeSlot(bool status, int DocID, string Date, string slot)
        {
            DateTime date = Convert.ToDateTime(Date);;

            using (ERP1DataContext dc = new ERP1DataContext())
            {
                var result = dc.Appointments.Where(x => x.Date == date.Date && x.DoctorID == DocID && x.TimeSlot == slot).FirstOrDefault();

                if (result != null)
                {
                    status = true;
                    return(status);
                }
                else
                {
                    status = false;
                    return(status);
                }
            }
        }
Ejemplo n.º 13
0
        public bool CheckSchedule(bool status, string Date)
        {
            DateTime date = Convert.ToDateTime(Date);;

            using (ERP1DataContext dc = new ERP1DataContext())
            {
                var result = dc.Schedules.Where(x => x.Start.Date == date.Date).FirstOrDefault();

                if (result != null)
                {
                    status = true;
                    return(status);
                }
                else
                {
                    status = false;
                    return(status);
                }
            }
        }
Ejemplo n.º 14
0
        public JsonResult CheckQuanity(int Quantity, int id)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (ERP1DataContext dc = new ERP1DataContext())
                {
                    bool status1 = dc.Stocks.Where(s => s.StockID == id).Any(s => s.Quantity < Quantity);
                    return(new JsonResult {
                        Data = new { status = status1 }
                    });
                }
            }
            else
            {
                status = false;
                return(new JsonResult {
                    Data = new { status = status }
                });
            }
        }
Ejemplo n.º 15
0
        public JsonResult SavePrescription(PrescriptionVM P)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (ERP1DataContext dc = new ERP1DataContext())
                {
                    Prescription pres = new Prescription {
                        AppointmentID = P.AppointmentID, DoctorID = P.DoctorID, PatientID = P.PatientID
                    };
                    foreach (var i in P.MedDetails)
                    {
                        //
                        // i.TotalAmount =
                        pres.Medications.Add(i);
                    }
                    dc.Prescriptions.InsertOnSubmit(pres);
                    dc.SubmitChanges();
                    var data = dc.Appointments.Where(a => a.AppointmentID == P.AppointmentID).ToList();
                    foreach (Appointment A in data)
                    {
                        //
                        // i.TotalAmount =
                        A.Status = "Prescribed";
                        dc.SubmitChanges();
                    }
                    dc.SubmitChanges();
                    status = true;
                }
            }
            else
            {
                status = false;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Ejemplo n.º 16
0
        public JsonResult deleteEvent(int eventID)
        {
            var status = false;

            using (ERP1DataContext dc = new ERP1DataContext())
            {
                var v    = dc.Schedules.Where(a => a.EventID == eventID).FirstOrDefault();
                var data = dc.DoctorSchedules.Where(a => a.EventID == eventID).ToList();
                if (v != null || data != null)
                {
                    foreach (DoctorSchedule ds in data)
                    {
                        dc.DoctorSchedules.DeleteOnSubmit(ds);
                    }
                    dc.Schedules.DeleteOnSubmit(v);
                    dc.SubmitChanges();
                    status = true;
                }
            }

            return(new JsonResult {
                Data = new { status = status }
            });
        }
Ejemplo n.º 17
0
        public JsonResult SaveSchedule(int DoctorID, int EventID)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (ERP1DataContext dc = new ERP1DataContext())
                {
                    DoctorSchedule ds = new DoctorSchedule();
                    ds.DoctorID = DoctorID;
                    ds.EventID  = EventID;
                    dc.DoctorSchedules.InsertOnSubmit(ds);
                    dc.SubmitChanges();
                    status = true;
                }
            }
            else
            {
                status = false;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }