Exemple #1
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 }
            });
        }
Exemple #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 }
            });
        }
        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 }
            });
        }
        public JsonResult SendRequest(string Req)
        {
            bool status = false;

            if (Req != null)
            {
                Request R = new Request();
                R.ReqText = Req;
                R.Status  = "UnSeen";
                string Day   = DateTime.Now.Day.ToString();
                string Month = DateTime.Now.Month.ToString();
                string Year  = DateTime.Now.Year.ToString();
                R.AddedDay   = Day;
                R.AddedMonth = Month;
                R.AddedYear  = Year;
                dc.Requests.InsertOnSubmit(R);
                dc.SubmitChanges();
                status = true;
                return(new JsonResult {
                    Data = new { status = status }
                });
            }
            else
            {
                status = false;
                return(new JsonResult {
                    Data = new { status = status }
                });
            }
        }
        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 }
            });
        }
Exemple #6
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 }
            });
        }
Exemple #7
0
        //Get DeliveredOrders
        //user enter orderID and date to confirm the delivery
        public JsonResult UpdateLog(int orderID, string orderDate)
        {
            List <string> AlertMessage = new List <string>(1);

            if (orderID != 0 && orderDate != null)
            {
                var order = from o in dc.Orders where (o.OrderId == orderID) select o;

                if (order != null)
                {
                    foreach (var v in order)
                    {
                        v.OrderStatus = "Delivered";
                    }
                    dc.SubmitChanges();
                    List <ShipmentVM> NewArrival = new List <ShipmentVM>(5);
                    var result = dc.Orders.Where(x => x.OrderStatus == "Delivered").ToList();
                    if (result != null)
                    {
                        foreach (var v in result)
                        {
                            ShipmentVM s = new ShipmentVM();
                            s.OrderID     = v.OrderId;
                            s.OrderStatus = v.OrderStatus;
                            DateTime OrderDate = (DateTime)v.OrderDate;
                            string   date      = OrderDate.ToString("MM/dd/yyyy");
                            s.OrderDate = date;

                            NewArrival.Add(s);
                        }
                        return(Json(NewArrival, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            AlertMessage.Add("OrderID or Date is null!");
            //return the status
            return(Json(AlertMessage, JsonRequestBehavior.AllowGet));
        }
        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();
        }
Exemple #9
0
 public ActionResult PatientRegistration(PatientRegistrationModel PReg)
 {
     if (ModelState.IsValid)
     {
         Patient p = new Patient();
         p.PatientEmail = PReg.Email;
         p.UserName     = PReg.UserName;
         p.Password     = PReg.Password;
         dc.Patients.InsertOnSubmit(p);
         dc.SubmitChanges();
         return(Redirect("/PatientAccounts/PatientLogin"));
     }
     else
     {
         return(View());
     }
 }
        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);
            }
        }
        //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);
            }
        }
        public JsonResult ChangeAppStatus(int id)
        {
            bool status = false;

            if (id != 0)
            {
                var data = dc.Appointments.Where(a => a.AppointmentID == id).ToList();
                foreach (Appointment A in data)
                {
                    A.Status = "Ref to Desk";
                }
                dc.SubmitChanges();
                status = true;
                return(new JsonResult {
                    Data = new { status = status }
                });
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        // GET: /PendingOrder/ApproveOrder/id
        public JsonResult ApproveOrder(int OrderID)
        {
            string status = null;
            var    order  = from o in dc.Orders where (o.OrderId == OrderID) select o;

            if (order != null)
            {
                foreach (var v in order)
                {
                    v.OrderStatus = "Approved";
                    v.Payment     = "Paid";
                }
                dc.SubmitChanges();
                status = "success";
            }
            else
            {
                status = "failed";
            }
            return(Json(status, JsonRequestBehavior.AllowGet));
        }
        public JsonResult MarkSeen(int id)
        {
            bool status = false;

            if (id != null)
            {
                List <RequestVM> List = new List <RequestVM>();
                var data = dc.Requests.Where(s => s.RequestID == id).ToList();
                foreach (Request r in data)
                {
                    r.Status = "Seen";
                    dc.SubmitChanges();
                    status = true;
                }
                return(new JsonResult {
                    Data = new { status = status }
                });
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        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 }
            });
        }
        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 }
            });
        }