Esempio n. 1
0
        protected override void Seed(LaCrosseDental.Models.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            DateTime             dt  = new DateTime(2017, 1, 1, 10, 0, 0);
            ApplicationDbContext db2 = new ApplicationDbContext();

            var    userMgr = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db2));
            String patient = userMgr.FindByEmail("*****@*****.**").Id;

            Appointment a = new Models.Appointment
            {
                AppointmentID = "" + dt.Month + dt.Day + dt.Hour,
                Time          = dt,
                Confirmed     = true,
                DoctorID      = "Dan Johnson",
                HygienistID   = "Mary Riley",
                PatientID     = patient,
                Type          = "Tooth Extraction"
            };

            context.Appointments.Add(a);

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
        }
Esempio n. 2
0
        public ActionResult AppointmentDetails(FormCollection form, string submitBtn)
        {
            switch (submitBtn)
            {
            case "Search":
                Appointment obj = new Models.Appointment();

                obj.fromdt = form["fromdate"];
                obj.todt   = form["todate"];
                if (obj.fromdt != "" && obj.todt != "")
                {
                    obj.CMD = "View2";
                    obj.hid = Convert.ToInt32(Session["hospital"].ToString());
                    string       xml     = Common.ToXML(obj);
                    DBConnection cn      = new DBConnection();
                    DataSet      dataset = cn.ExecuteProcedure("SP_Appointment", xml);
                    return(View(dataset));
                }
                else
                {
                    return(RedirectToAction("AppointmentDetails"));
                }

            case "ViewAll":
                return(RedirectToAction("AppointmentDetails"));

            default:
                return(View());
            }
        }
        public FinancialTransactionEdit(DialogMode mode, int?transactionID, int clientID, int?appointmentID, IDialogService dialogService, IMessageBoxService messageService)
            : base(mode, dialogService, messageService)
        {
            SubTitle = "финансовой операции";
            if (transactionID.HasValue)
            {
                _data = _dc.FinancialTransactions.SingleOrDefault(x => x.ID == transactionID);
                //  _data.ModifiedBy = CurrentUser.ID;
                _data.ModificationTime = DateTime.Now;
            }
            else
            {
                var client = _dc.Customers.Single(x => x.ID == clientID);
                Models.Appointment appointment = null;
                if (appointmentID.HasValue)
                {
                    appointment = _dc.Appointments.SingleOrDefault(x => x.ID == appointmentID);
                }

                _data = new Models.FinancialTransaction()
                {
                    Customer          = client,
                    Appointment       = appointment,
                    TransactionTypeID = (int)TransactionType.Deposit,
                    CreatedBy         = CurrentUser.ID,
                    CreationTime      = DateTime.Now,
                    Amount            = 0m
                };
                _dc.FinancialTransactions.Add(_data);
            };
        }
Esempio n. 4
0
        public async Task <Models.Appointment> AddAppointmentToTimeslotAsync(Models.Appointment appointment, int TimeslotId)
        {
            var timeslot = await _context.Timeslots.FindAsync(TimeslotId);

            if (timeslot == null)
            {
                throw new ArgumentException($"Timeslot id:{TimeslotId} can't be modified because it doesn't exist");
            }
            if (timeslot.AppointmentId is not null)
            {
                throw new ArgumentException($"Timeslot id:{TimeslotId} already has an appointment");
            }

            var new_appointment = new DataModel.Appointment
            {
                DoctorId  = appointment.DoctorId,
                PatientId = appointment.PatientId,
                Start     = timeslot.Start,
                End       = timeslot.End
            };

            await _context.Appointments.AddAsync(new_appointment);

            await _context.SaveChangesAsync();

            timeslot.AppointmentId = new_appointment.Id;
            appointment.Id         = new_appointment.Id;
            await _context.SaveChangesAsync();

            return(appointment);
        }
Esempio n. 5
0
        public ActionResult AppointmentDetails()
        {
            Appointment  obj = new Models.Appointment();
            DBConnection cn  = new DBConnection();

            obj.CMD = "View";
            obj.hid = Convert.ToInt32(Session["hospital"].ToString());
            string  xml     = Common.ToXML(obj);
            DataSet dataset = cn.ExecuteProcedure("SP_Appointment", xml);

            return(View(dataset));
        }
        private static Models.Appointment MapToDto(Data.Appointment dbo)
        {
            var dto = new Models.Appointment
            {
                Date     = dbo.Date,
                CreateOn = dbo.CreateOn,
                Id       = dbo.ExternalId
            };

            if (dbo.Participants != null)
            {
                dto.Participant = dbo.Participants.Where(x => !x.DeletedAt.HasValue).Select(x => x.Name).ToArray();
            }

            dto.Type = dbo.Type.ToString();
            return(dto);
        }
        public long InsertAppointment(Models.Appointment appointment)
        {
            long result = -1;

            try
            {
                _repositoryWrapper.Appointment.Create(appointment);
                _repositoryWrapper.Save();
                result = appointment.Idappointment;
            }
            catch
            {
                result = -1;
            }

            return(result);
        }
        public RedirectToActionResult CreateAppointment(AppointmentViewModel appointment)
        {
            if (context.Appointments.Where(x => x.AppointmentDate == appointment.AppointmentDate && x.Doctor.DoctorID == appointment.Doctor.DoctorID).Any())
            {
                return(RedirectToAction("AppointmentExists"));
            }

            else
            {
                Models.Appointment appointmentModel = new Models.Appointment();

                appointmentModel.Doctor          = context.Doctors.FirstOrDefault(x => x.DoctorID == appointment.Doctor.DoctorID);
                appointmentModel.UserName        = userManager.GetUserName(User);
                appointmentModel.AppointmentDate = appointment.AppointmentDate;

                Appointment newAppointment = _appointmentRepository.Add(appointmentModel);
                context.SaveChanges();
            }
            return(RedirectToAction("MyAppointment"));
        }
Esempio n. 9
0
        public Models.Appointment CreateAppointment(DateTime dateTime, Guid patientId, Guid physicianId)
        {
            var vm = new Models.Appointment
            {
                Start     = dateTime,
                End       = dateTime.AddMinutes(10),
                Title     = "Consulta con " + "Neurología",
                PatientId = patientId,
            };

            //TODO: Esta responsabilidad debería ser controller para hacer el mapeo entre VM -> DM
            var model = new Entities.Appointment
            {
                Start = vm.Start,
                End   = vm.End,
                Title = vm.Title
            };

            _appointmentsRepository.Save(model);
            return(vm);
        }
Esempio n. 10
0
        private void Add_Appointment(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }
            try
            {
                DateTime expenseDueDate = Convert.ToDateTime(ExpenseDueDate.ToString());
                DateTime help = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                string[] separators = new string[] { ", " };
                string staff = Staff.SelectedValue.ToString();
                string grant = Grant.SelectedValue.ToString();
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                //MessageBox.Show(PatientBill + "\n" + DonorBill + "\n" + startDateTime + "\n" + endDateTime + "\n" + expenseDueDate + "\n" + staff, grant);
                string[] words = staff.Split(separators, StringSplitOptions.None);
                string FName = words[0]; string LName = words[1]; string username = words[2];
                var staffID = (from dc in db.Staff
                               where dc.StaffFirstName == FName && dc.StaffLastName == LName && dc.StaffUserName == username
                               select dc.StaffID).Distinct().FirstOrDefault();
                var grantproposalID = (from g in db.GrantProposals
                                       where g.GrantName == grant
                                       select g.GrantProposalID).Distinct().FirstOrDefault();
                var donationID = (from d in db.Donations
                                  where d.GrantProposalID == grantproposalID
                                  select d.DonationID).Distinct().FirstOrDefault();
                var donation = (from d in db.Donations
                                where d.GrantProposalID == grantproposalID
                                select d).First();
                if (donation.DonationAmountRemaining >= DonorBill)
                {
                    Models.Appointment a = new Models.Appointment();
                    a.StaffID = staffID;
                    a.AppointmentStartDate = startDateTime;
                    a.AppointmentEndDate = endDateTime;
                    db.Appointments.Add(a);
                    db.SaveChanges();

                    Models.Expense expense = new Models.Expense();

                    expense.ExpenseTypeID = 1;
                    expense.DonationID = donationID;
                    expense.PatientID = PatientID;
                    expense.AppointmentID = a.AppointmentID;
                    expense.ExpenseDueDate = expenseDueDate;
                    expense.DonorBill = DonorBill;
                    expense.PatientBill = PatientBill;
                    expense.TotalExpenseAmount = DonorBill + PatientBill;
                    if (ExpensePaidDate.IsEnabled == true) { expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString()); }
                    db.Expenses.Add(expense);
                    db.SaveChanges();

                    donation.DonationAmountRemaining = donation.DonationAmountRemaining - DonorBill;
                    db.SaveChanges();


                    this.Close();
                }
                else
                {
                    MessageBox.Show("This would result in a negative balance.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
Esempio n. 11
0
        private void Add_Appointment(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }
            try
            {
                DateTime           expenseDueDate = Convert.ToDateTime(ExpenseDueDate.ToString());
                DateTime           help           = Convert.ToDateTime(DateRecieved.ToString());
                DateTime           startDateTime  = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime           endDateTime    = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                string[]           separators     = new string[] { ", " };
                string             staff          = Staff.SelectedValue.ToString();
                string             grant          = Grant.SelectedValue.ToString();
                Models.FCS_DBModel db             = new Models.FCS_DBModel();
                //MessageBox.Show(PatientBill + "\n" + DonorBill + "\n" + startDateTime + "\n" + endDateTime + "\n" + expenseDueDate + "\n" + staff, grant);
                string[] words = staff.Split(separators, StringSplitOptions.None);
                string   FName = words[0]; string LName = words[1]; string username = words[2];
                var      staffID = (from dc in db.Staff
                                    where dc.StaffFirstName == FName && dc.StaffLastName == LName && dc.StaffUserName == username
                                    select dc.StaffID).Distinct().FirstOrDefault();
                var grantproposalID = (from g in db.GrantProposals
                                       where g.GrantName == grant
                                       select g.GrantProposalID).Distinct().FirstOrDefault();
                var donationID = (from d in db.Donations
                                  where d.GrantProposalID == grantproposalID
                                  select d.DonationID).Distinct().FirstOrDefault();
                var donation = (from d in db.Donations
                                where d.GrantProposalID == grantproposalID
                                select d).First();
                if (donation.DonationAmountRemaining >= DonorBill)
                {
                    Models.Appointment a = new Models.Appointment();
                    a.StaffID = staffID;
                    a.AppointmentStartDate = startDateTime;
                    a.AppointmentEndDate   = endDateTime;
                    db.Appointments.Add(a);
                    db.SaveChanges();

                    Models.Expense expense = new Models.Expense();

                    expense.ExpenseTypeID      = 1;
                    expense.DonationID         = donationID;
                    expense.PatientID          = PatientID;
                    expense.AppointmentID      = a.AppointmentID;
                    expense.ExpenseDueDate     = expenseDueDate;
                    expense.DonorBill          = DonorBill;
                    expense.PatientBill        = PatientBill;
                    expense.TotalExpenseAmount = DonorBill + PatientBill;
                    if (ExpensePaidDate.IsEnabled == true)
                    {
                        expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString());
                    }
                    db.Expenses.Add(expense);
                    db.SaveChanges();

                    donation.DonationAmountRemaining = donation.DonationAmountRemaining - DonorBill;
                    db.SaveChanges();


                    this.Close();
                }
                else
                {
                    MessageBox.Show("This would result in a negative balance.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
        private void Select_AppointmentType(object sender, RoutedEventArgs e)
        {
            try
            {
                if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
                {
                    BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
                }
                if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
                {
                    EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
                }
                if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
                {
                    BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
                }
                if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
                {
                    EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
                }

                DateTime help             = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime    = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime      = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                DateTime expenseDueDate   = startDateTime.AddDays(30);
                string[] separators       = new string[] { ", " };
                string   staff            = Staff.SelectedValue.ToString();
                string   cancellationType = "Not Cxl";
                switch (CancellationType.SelectedIndex)
                {
                case 0:
                    cancellationType = "Not Cxl";
                    break;

                case 1:
                    cancellationType = "No Show";
                    break;

                case 2:
                    cancellationType = "Late Cxl";
                    break;

                case 3:
                    cancellationType = "Cxl";
                    break;

                default:
                    cancellationType = "Not Cxl";
                    break;
                }
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                string[]           words = staff.Split(separators, StringSplitOptions.None);
                string             FName = words[0]; string LName = words[1]; string usertitle = words[2];  string username = words[3];
                var staffID = (from dc in db.Staff
                               where dc.StaffFirstName == FName && dc.StaffLastName == LName && dc.StaffUserName == username
                               select dc.StaffID).Distinct().FirstOrDefault();
                if (TotalGroup.Count == 0)
                {
                    MessageBox.Show("Please add at least one client."); return;
                }
                if (TotalGroup.Count > 1 && (String)ApptType.SelectedItem == "Individual")
                {
                    MessageBox.Show("Individual appointment may only have one client."); return;
                }
                //individual (1st option) (ExpenseTypeID = 1 in database)
                //group (3rd option) (ExpenseTypeID = 2 in database)
                if (ApptType.SelectedIndex == 0 || ApptType.SelectedIndex == 2)
                {
                    if (ApptType.SelectedIndex == 0)
                    {
                        ExpenseTypeID = 1;
                    }
                    else
                    {
                        ExpenseTypeID = 2;
                    }
                    Models.Appointment a = new Models.Appointment();
                    a.StaffID = staffID;
                    a.AppointmentStartDate       = startDateTime;
                    a.AppointmentEndDate         = endDateTime;
                    a.AppointmentCancelationType = cancellationType;
                    db.Appointments.Add(a);
                    db.SaveChanges();

                    foreach (var item in TotalGroup)
                    {
                        AddGroupSession ags = new AddGroupSession(ExpenseTypeID, item, staffID, expenseDueDate, startDateTime, endDateTime, a.AppointmentID);
                        ags.ShowDialog();
                        ags.ExpensePaidDate.IsEnabled = false;
                        ags.FN.IsEnabled            = false;
                        ags.LN.IsEnabled            = false;
                        ags.OQ.IsEnabled            = false;
                        ags.MoneyDonation.IsEnabled = true;
                        ags.Grant.IsEnabled         = false;
                    }
                    this.Close();
                }
                //family (2nd option) (ExpenseTypeID = 3 in database)
                else if (ApptType.SelectedIndex == 1)
                {
                    ExpenseTypeID = 3;
                    foreach (var item in TotalGroup)
                    {
                        Models.Appointment a = new Models.Appointment();
                        a.StaffID = staffID;
                        a.AppointmentStartDate       = startDateTime;
                        a.AppointmentEndDate         = endDateTime;
                        a.AppointmentCancelationType = cancellationType;
                        db.Appointments.Add(a);
                        db.SaveChanges();

                        AddGroupSession ags = new AddGroupSession(ExpenseTypeID, item, staffID, expenseDueDate, startDateTime, endDateTime, a.AppointmentID);
                        ags.Show();
                        ags.ExpensePaidDate.IsEnabled = false;
                        ags.FN.IsEnabled            = false;
                        ags.LN.IsEnabled            = false;
                        ags.OQ.IsEnabled            = false;
                        ags.MoneyDonation.IsEnabled = true;
                        ags.Grant.IsEnabled         = false;
                    }
                    this.Close();
                }
            }
            catch
            {
                if (GroupGrid.Items.Count == 0)
                {
                    MessageBox.Show("Please select atleast one client prior to clicking on Select Appointment Type");
                }
                else if (Staff.SelectedIndex == -1)
                {
                    MessageBox.Show("Please select a Therapist prior to clicking Select on Appointment Type");
                }
                else if (DateRecieved.Text.Equals("") || DateRecieved == null)
                {
                    MessageBox.Show("Please select a Date prior to clicking Select Appointment Type");
                }
                else
                {
                    MessageBox.Show("Something went wrong. Please check the fields and try again.");
                }
            }
        }
        private void Select_AppointmentType(object sender, RoutedEventArgs e)
        {
            try
            {
                if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
                {
                    BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
                }
                if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
                {
                    EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
                }
                if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
                {
                    BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
                }
                if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
                {
                    EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
                }

                DateTime help = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                DateTime expenseDueDate = startDateTime.AddDays(30);
                string[] separators = new string[] { ", " };
                string staff = Staff.SelectedValue.ToString();
                string cancellationType = "Not Cxl";
                switch (CancellationType.SelectedIndex)
                {
                    case 0:
                        cancellationType = "Not Cxl";
                        break;
                    case 1:
                        cancellationType = "No Show";
                        break;
                    case 2:
                        cancellationType = "Late Cxl";
                        break;                 
                    case 3:
                        cancellationType = "Cxl";
                        break;
                    default:
                        cancellationType = "Not Cxl";
                        break;
                }
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                string[] words = staff.Split(separators, StringSplitOptions.None);
                string FName = words[0]; string LName = words[1]; string usertitle = words[2];  string username = words[3];
                var staffID = (from dc in db.Staff
                               where dc.StaffFirstName == FName && dc.StaffLastName == LName && dc.StaffUserName == username
                               select dc.StaffID).Distinct().FirstOrDefault();
                if (TotalGroup.Count == 0) { MessageBox.Show("Please add at least one client."); return; }
                if (TotalGroup.Count > 1 && (String)ApptType.SelectedItem == "Individual") { MessageBox.Show("Individual appointment may only have one client."); return; }
                //individual (1st option) (ExpenseTypeID = 1 in database)
                //group (3rd option) (ExpenseTypeID = 2 in database)
                if (ApptType.SelectedIndex == 0 || ApptType.SelectedIndex == 2)
                {
                    if (ApptType.SelectedIndex == 0) { ExpenseTypeID = 1; }
                    else { ExpenseTypeID = 2; }
                    Models.Appointment a = new Models.Appointment();
                    a.StaffID = staffID;
                    a.AppointmentStartDate = startDateTime;
                    a.AppointmentEndDate = endDateTime;
                    a.AppointmentCancelationType = cancellationType;
                    db.Appointments.Add(a);
                    db.SaveChanges();

                    foreach (var item in TotalGroup)
                    {
                        AddGroupSession ags = new AddGroupSession(ExpenseTypeID, item, staffID, expenseDueDate, startDateTime, endDateTime, a.AppointmentID);
                        ags.ShowDialog();
                        ags.ExpensePaidDate.IsEnabled = false;
                        ags.FN.IsEnabled = false;
                        ags.LN.IsEnabled = false;
                        ags.OQ.IsEnabled = false;
                        ags.MoneyDonation.IsEnabled = true;
                        ags.Grant.IsEnabled = false;
                    }
                    this.Close();
                }
                //family (2nd option) (ExpenseTypeID = 3 in database)
                else if (ApptType.SelectedIndex == 1)
                {
                    ExpenseTypeID = 3;
                    foreach (var item in TotalGroup)
                    {
                        Models.Appointment a = new Models.Appointment();
                        a.StaffID = staffID;
                        a.AppointmentStartDate = startDateTime;
                        a.AppointmentEndDate = endDateTime;
                        a.AppointmentCancelationType = cancellationType;
                        db.Appointments.Add(a);
                        db.SaveChanges();

                        AddGroupSession ags = new AddGroupSession(ExpenseTypeID, item, staffID, expenseDueDate, startDateTime, endDateTime, a.AppointmentID);
                        ags.Show();
                        ags.ExpensePaidDate.IsEnabled = false;
                        ags.FN.IsEnabled = false;
                        ags.LN.IsEnabled = false;
                        ags.OQ.IsEnabled = false;
                        ags.MoneyDonation.IsEnabled = true;
                        ags.Grant.IsEnabled = false;
                    }
                    this.Close();
                }
                
            }
            catch
            {
                
                if (GroupGrid.Items.Count == 0)
                {
                    MessageBox.Show("Please select atleast one client prior to clicking on Select Appointment Type");
                }
                else if (Staff.SelectedIndex == -1)
                {
                    MessageBox.Show("Please select a Therapist prior to clicking Select on Appointment Type");
                }
                else if (DateRecieved.Text.Equals("") || DateRecieved == null)
                {
                    MessageBox.Show("Please select a Date prior to clicking Select Appointment Type");
                }
                else
                {
                    MessageBox.Show("Something went wrong. Please check the fields and try again.");
                }
            }

        }
Esempio n. 14
0
        public AppointmentEdit(DialogMode mode, int?appointmentID, int clientID, IDialogService dialogService, IMessageBoxService messageService)
            : base(mode, dialogService, messageService)
        {
            SubTitle          = "визита";
            AddServiceCommand = new DelegateCommand <object>(OnAddServiceCommand,
                                                             x => { return(CurrentUser.HasPrivilege(Privilege.CreateAppointment) || CurrentUser.HasPrivilege(Privilege.ModifyAppointment)); });
            RemoveServiceCommand = new DelegateCommand <object>(OnRemoveServiceCommand,
                                                                x => { return(CurrentUser.HasPrivilege(Privilege.CreateAppointment) || CurrentUser.HasPrivilege(Privilege.ModifyAppointment)); });

            _services = _dc.Services
                        .Where(x => x.Staffs.Any())
                        .ToList();
            _staffs = _dc.Staffs
                      .Where(x => x.Services.Any())
                      .ToList();

            SesionService.Cache.Add("AllServices", _services);
            SesionService.Cache.Add("AllStaffs", _staffs);

            Details = new ObservableCollection <AppointmentDetail>();

            if (appointmentID.HasValue)
            {
                _data = _dc.Appointments
                        .Where(x => x.ID == appointmentID)
                        .Include(x => x.AppointmentDetails)
                        .Include(x => x.Customer)
                        .Include(x => x.Customer.DiscountCard)
                        .First();

                _data.AppointmentDetails.ToList().ForEach(x => Details.Add(x));


                _data.ModifiedBy       = CurrentUser.ID;
                _data.ModificationTime = DateTime.Now;
            }
            else
            {
                var client = _dc.Customers
                             .Where(x => x.ID == clientID)
                             .Include(x => x.DiscountCard)
                             .First();

                var nextHour = DateTime.Now.AddHours(1).StartOfHour();
                _data = new Models.Appointment()
                {
                    Customer        = client,
                    StartTime       = nextHour,
                    EndTime         = nextHour.AddHours(1),
                    CreatedBy       = CurrentUser.ID,
                    CreationTime    = DateTime.Now,
                    DiscountPercent = client.DiscountCard != null ? client.DiscountCard.DiscountPercent : 0m,
                    Price           = 0m,
                    Discount        = 0m,
                    ToPay           = 0m,
                    StateID         = (int)AppointmentState.Active
                };

                _dc.Appointments.Add(_data);
            };

            Details.CollectionChanged += Details_CollectionChanged;
            Duration = new DateTime(_data.StartTime.Year, _data.StartTime.Month, _data.StartTime.Day, (int)_data.EndTime.Subtract(_data.StartTime).TotalHours, 0, 0);
        }