/// <summary>
    /// Imports Events, read from the iCalendar file, in RadScheduler.
    /// </summary>
    /// <param name="events">An <seealso cref="IList" /> of <seealso cref="Event" /> objects
    /// holding data for Event components.</param>
    /// <returns></returns>
    public static IEnumerable <AppointmentInfo> ImportEvents(IUniqueComponentList <IEvent> events)
    {
        List <AppointmentInfo> appointments = new List <AppointmentInfo>();

        foreach (Event eventComponent in events)
        {
            if ((eventComponent.Start != null) &&
                (eventComponent.End != null))
            {
                string          summary            = eventComponent.Summary ?? String.Empty;
                DateTime        startDate          = eventComponent.Start.Local;
                DateTime        endDate            = eventComponent.End.Local;
                string          recurrenceRule     = GetSchedulerRecurrenceRule(startDate, endDate, eventComponent);
                string          recurrenceParentID = null;
                string          description        = eventComponent.Description ?? String.Empty;
                string          reminder           = eventComponent.Alarms.Count > 0 ? new Reminder(eventComponent.Alarms[0].Trigger.Duration.Value.Duration()).ToString() : String.Empty;
                AppointmentInfo appInfo            = new AppointmentInfo(
                    summary,
                    startDate,
                    endDate,
                    recurrenceRule,
                    recurrenceParentID,
                    reminder);
                appInfo.Description = description;
                appointments.Add(appInfo);
            }
        }
        return(appointments);
    }
    /// <summary>
    /// Imports Journals, read from the iCalendar file, as All Day events in RadScheduler.
    /// </summary>
    /// <param name="todos">An <see cref="IList"/> of <seealso cref="Journal"/> objects holding data for
    /// Journal components.</param>
    public static IEnumerable <AppointmentInfo> ImportJournals(ICalendarObjectList <IJournal> journals)
    {
        List <AppointmentInfo> appointments = new List <AppointmentInfo>();

        foreach (Journal journal in journals)
        {
            if (journal.Start != null)
            {
                string   summary   = journal.Summary ?? String.Empty;
                DateTime startDate = journal.Start.Local;
                //Import Journals as All Day events as they do not have End Date.
                DateTime endDate        = startDate.AddDays(1);
                string   recurrenceRule = GetSchedulerRecurrenceRule(startDate, endDate, journal);
                //Recurrence Exceptions are not currently supported as they can be defined
                //in varios ways and should be handled specifically.
                string          recurrenceParentID = null;
                string          description        = journal.Description ?? String.Empty;
                string          reminder           = journal.Alarms.Count > 0 ? new Reminder(journal.Alarms[0].Trigger.Duration.Value.Duration()).ToString() : String.Empty;
                AppointmentInfo appInfo            = new AppointmentInfo(
                    summary,
                    startDate,
                    endDate,
                    recurrenceRule,
                    recurrenceParentID,
                    reminder);
                appInfo.Description = description;
                appointments.Add(appInfo);
            }
        }
        return(appointments);
    }
Beispiel #3
0
        private void chkPlayOnce_CheckedChanged(object sender, EventArgs e)
        {
            if (isRecurrence)
            {
                return;
            }
            dtEnd.Enabled       = !chkPlayOnce.Checked;
            timeEnd.Enabled     = !chkPlayOnce.Checked;
            checkAllDay.Enabled = !chkPlayOnce.Checked;
            if (chkPlayOnce.Checked)
            {
                checkAllDay.Checked = false;
            }
            appInfo = appConverter.Convert(apt);

            controller.Start = dtStart.DateTime.Date + timeStart.Time.TimeOfDay;
            double length = Convert.ToDouble(appInfo.Target.Length) / 3600;

            if (chkPlayOnce.Checked)
            {
                controller.End = controller.Start.AddSeconds(appInfo.Target.Length);
            }
            else
            {
                controller.End = controller.Start + apt.Duration;
            }
            //dtStart.EditValue = controller.Start.Date;
            //dtEnd.EditValue = controller.End.Date;
            //timeStart.EditValue = controller.Start.TimeOfDay;
            //timeEnd.EditValue = controller.End.TimeOfDay;
            UpdateIntervalControls();
        }
Beispiel #4
0
        void UpdateForm()
        {
            SuspendUpdate();
            try
            {
                txSubject.Text = controller.Subject;
                lblType.Text   = controller.Description;

                dtStart.DateTime = controller.Start.Date;
                dtEnd.DateTime   = controller.End.Date;

                timeStart.Time      = DateTime.MinValue.AddTicks(controller.Start.TimeOfDay.Ticks);
                timeEnd.Time        = DateTime.MinValue.AddTicks(controller.End.TimeOfDay.Ticks);
                checkAllDay.Checked = controller.AllDay;
                AppointmentInfo info = Array.Find <AppointmentInfo>(scheCtrl.Model.Items, p => { return(p.Subject == controller.Subject); });
                if (info != null)
                {
                    checkEdit1.Checked  = info.ExactTiming;
                    chkPlayOnce.Checked = info.PlayMessageOnce;
                    dtEnd.Enabled       = !info.PlayMessageOnce;
                    timeEnd.Enabled     = !info.PlayMessageOnce;
                    checkAllDay.Enabled = !info.PlayMessageOnce;
                }
            }
            finally
            {
                ResumeUpdate();
            }
            UpdateIntervalControls();
        }
Beispiel #5
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            // Required to check appointment's conflicts.
            if (!controller.IsConflictResolved())
            {
                return;
            }
            //if (apt.RecurrenceInfo != null)
            //{

            controller.Subject = txSubject.Text;
            controller.AllDay  = this.checkAllDay.Checked;
            //controller.
            controller.Start = this.dtStart.DateTime.Date + this.timeStart.Time.TimeOfDay;
            controller.End   = this.dtEnd.DateTime.Date + this.timeEnd.Time.TimeOfDay;
            AppointmentInfo info = Array.Find <AppointmentInfo>(scheCtrl.Model.Items, p => { return(p.Subject == controller.Subject); });

            if (info != null)
            {
                info.ExactTiming     = checkEdit1.Checked;
                info.PlayMessageOnce = chkPlayOnce.Checked;
            }
            //if(info.PlayMessageOnce)
            //    controller.End = controller.Start + apt.
            // Save all changes made to the appointment edited in a form.
            controller.ApplyChanges();
            //}
        }
            public async Task <Unit> Handle(Appointment request, CancellationToken cancellationToken)
            {
                if (request.DateTimeOfAppointment < DateTime.Now)
                {
                    throw new Exception("Date and time of appointment should be later than today's date and time");
                }
                else
                {
                    var appointment = new AppointmentInfo
                    {
                        FirstName             = request.FirstName,
                        LastName              = request.LastName,
                        Address               = request.Address,
                        ContactNumber         = request.ContactNumber,
                        Email                 = request.Email,
                        CarMake               = request.CarMake,
                        CarModel              = request.CarModel,
                        CarYear               = request.CarYear,
                        IsMaintenance         = request.IsMaintenance,
                        DateTimeOfAppointment = request.DateTimeOfAppointment
                    };

                    _context.AppointmentInfos.Add(appointment);

                    var success = await _context.SaveChangesAsync() > 0;

                    if (success)
                    {
                        return(Unit.Value);
                    }

                    throw new Exception("Problem saving changes");
                }
            }
Beispiel #7
0
        public int Insert(AppointmentInfo appointmentInfo)
        {
            var appointmentId = 0;

            IDataParameter[] parms = null;

            var sqlInsert = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(appointmentInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        appointmentId = ExecuteNonQueryAndReturnId(trans, sqlInsert, parms);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(appointmentId);
        }
Beispiel #8
0
        protected override void OnPeforming()
        {
            base.OnPeforming();

            AppointmentInfo appointment = new AppointmentInfo();

            Scheduler.Add(appointment);

            MessageInfo item  = new MessageInfo();
            ShapeLabel  label = new ShapeLabel();

            ShapeLayer layer = new ShapeLayer(label);

            layer.EmphasisEffect.StartTime = 0;
            layer.EmphasisEffect.EndTime   = 8;

            item.Add(layer);
            item.Length = 8;

            appointment.Target   = item;
            appointment.AllDay   = true;
            appointment.Subject  = item.Name;
            appointment.StatusId = 0;
            double length = Convert.ToDouble(item.Length) / 3600;

            appointment.Duration    = TimeSpan.FromHours(length);
            appointment.End         = appointment.Start.AddSeconds(item.Length);
            appointment.Description = item.Type.ToString();
        }
Beispiel #9
0
        /// <summary>
        /// Gets an appointment
        /// </summary>
        /// <param name="lscId"></param>
        /// <param name="lscName"></param>
        /// <param name="id"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public AppointmentInfo GetAppointment(int lscId, string lscName, int id, string connectionString)
        {
            SqlParameter[]  parms       = { new SqlParameter("@Id", id) };
            AppointmentInfo appointment = null;

            SqlHelper.TestConnection(connectionString);
            using (var rdr = SqlHelper.ExecuteReader(connectionString, CommandType.Text, SqlText.Sql_Appointment_Get, parms)) {
                if (rdr.Read())
                {
                    appointment              = new AppointmentInfo();
                    appointment.LscID        = lscId;
                    appointment.LscName      = lscName;
                    appointment.Id           = ComUtility.DBNullInt32Handler(rdr["Id"]);
                    appointment.StartTime    = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]);
                    appointment.EndTime      = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]);
                    appointment.LscIncluded  = ComUtility.DBNullInt32Handler(rdr["LscIncluded"]);
                    appointment.StaIncluded  = ComUtility.DBNullStringHandler(rdr["StaIncluded"]);
                    appointment.DevIncluded  = ComUtility.DBNullStringHandler(rdr["DevIncluded"]);
                    appointment.ProjectId    = ComUtility.DBNullStringHandler(rdr["ProjectId"]);
                    appointment.ProjectName  = ComUtility.DBNullStringHandler(rdr["ProjectName"]);
                    appointment.Status       = ComUtility.DBNullProjStatusHandler(rdr["Status"]);
                    appointment.CreaterId    = ComUtility.DBNullInt32Handler(rdr["CreaterId"]);
                    appointment.Creater      = ComUtility.DBNullStringHandler(rdr["Creater"]);
                    appointment.ContactPhone = ComUtility.DBNullStringHandler(rdr["ContactPhone"]);
                    appointment.CreatedTime  = ComUtility.DBNullDateTimeHandler(rdr["CreatedTime"]);
                }
            }
            return(appointment);
        }
        /// <summary>
        /// When Appointment changed will happen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void OnAppointmentChanged(object sender, PersistentObjectEventArgs e)
        {
            _innerCtrl.ChangedService.MarkChanged();
            try
            {
                base.OnAppointmentChanged(sender, e);
            }
            catch { }
            ControlService.NailImageBox.Image = null;

            AppointmentInfo appointment = _innerCtrl.appointConverter.Convert(e.Object as Appointment);

            ControlService.RefreshPropertyGrid(appointment);
            if (appointment.Target != null)
            {
                Color color = DataGate.FindColorByIndex(appointment.LabelId);
                //LibraryGroup.Current.SetColor(
                ControlService.LibraryTree.Controller.SetColor(appointment.Target, color);//.Refresh();
                ControlService.EnableCopyMenu(true);

                foreach (Appointment app in Appointments.Items)
                {
                    if (app.Subject == appointment.Subject && app.Description.Replace(" ", "") == appointment.Description)
                    {
                        app.LabelId = appointment.LabelId;
                    }
                }
            }
        }
Beispiel #11
0
        public async Task <IActionResult> Edit(int id, [Bind("AppointmentID,HostUser,GuestUser,DatenTime,Subject,Status,HostUserID")] AppointmentInfo appointmentInfo)
        {
            if (id != appointmentInfo.AppointmentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(appointmentInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AppointmentInfoExists(appointmentInfo.AppointmentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HostUserID"] = new SelectList(_context.Users, "UserId", "EmailID", appointmentInfo.HostUserID);
            return(View(appointmentInfo));
        }
Beispiel #12
0
        private async void EditItemButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int             AppointmentInfo = ((AppointmentInfo)TransactionList.SelectedItem).AppointmentID;
                AppointmentInfo infoObject      = new AppointmentInfo();
                infoObject       = conn.Find <AppointmentInfo>(AppointmentInfo);
                _EventName.Text  = infoObject.EventName;
                _Location.Text   = infoObject.Location;
                _DatePicker.Date = Convert.ToDateTime(infoObject.EventDate);
                _StartTime.Time  = Convert.ToDateTime(infoObject.StartTime).TimeOfDay;
                _EndTime.Time    = Convert.ToDateTime(infoObject.EndTime).TimeOfDay;


                //switched out the add new entry button for the save edited button
                AddButton.Visibility  = Visibility.Collapsed;
                SaveButton.Visibility = Visibility.Visible;
                // Hides the sql List so that the selection can't be changed while editing
                TransactionList.Visibility = Visibility.Collapsed;
            }
            catch (NullReferenceException)
            {
                MessageDialog ClearDialog = new MessageDialog("Please select the item to Edit", "Oops..!");
                await ClearDialog.ShowAsync();
            }
        }
Beispiel #13
0
        public List <AppointmentInfo> GetAppointmentInfoListByKeywordId(int publishmentSystemId, int keywordId)
        {
            var appointmentInfoList = new List <AppointmentInfo>();

            string sqlWhere =
                $"WHERE {AppointmentAttribute.PublishmentSystemId} = {publishmentSystemId} AND {AppointmentAttribute.IsDisabled} <> '{true}'";

            if (keywordId > 0)
            {
                sqlWhere += $" AND {AppointmentAttribute.KeywordId} = {keywordId}";
            }

            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var appointmentInfo = new AppointmentInfo(rdr);
                    appointmentInfoList.Add(appointmentInfo);
                }
                rdr.Close();
            }

            return(appointmentInfoList);
        }
 /// <summary>
 /// Imports Events, read from the iCalendar file, in RadScheduler.
 /// </summary>
 /// <param name="events">An <seealso cref="IList" /> of <seealso cref="Event" /> objects
 /// holding data for Event components.</param>
 /// <returns></returns>
 public static IEnumerable<AppointmentInfo> ImportEvents(IUniqueComponentList<IEvent> events)
 {
     List<AppointmentInfo> appointments = new List<AppointmentInfo>();
     foreach (Event eventComponent in events)
     {
         if ((eventComponent.Start != null) &&
             (eventComponent.End != null))
         {
             string summary = eventComponent.Summary ?? String.Empty;
             DateTime startDate = eventComponent.Start.Local;
             DateTime endDate = eventComponent.End.Local;
             string recurrenceRule = GetSchedulerRecurrenceRule(startDate, endDate, eventComponent);
             string recurrenceParentID = null;
             string description = eventComponent.Description ?? String.Empty;
             string reminder = eventComponent.Alarms.Count > 0 ? new Reminder(eventComponent.Alarms[0].Trigger.Duration.Value.Duration()).ToString() : String.Empty;
             AppointmentInfo appInfo = new AppointmentInfo(
                 summary,
                 startDate,
                 endDate,
                 recurrenceRule,
                 recurrenceParentID,
                 reminder);
             appInfo.Description = description;
             appointments.Add(appInfo);
         }
     }
     return appointments;
 }
 /// <summary>
 /// Imports the todos.
 /// </summary>
 /// <param name="todos">The todos.</param>
 /// <returns></returns>
 public static IEnumerable<AppointmentInfo> ImportTodos(IUniqueComponentList<ITodo> todos)
 {
     List<AppointmentInfo> appointments = new List<AppointmentInfo>();
     foreach (Todo todo in todos)
     {
         if (todo.Start != null)
         {
             string summary = todo.Summary ?? String.Empty;
             DateTime startDate = todo.Start.Local;
             //Import To-Dos as All Day events as they do not have End Date.
             DateTime endDate = startDate.AddDays(1);
             string recurrenceRule = GetSchedulerRecurrenceRule(startDate, endDate, todo);
             //Recurrence Exceptions are not currently supported as they can be defined
             //in varios ways and should be handled specifically.
             string recurrenceParentID = null;
             string description = todo.Description ?? String.Empty;
             string reminder = todo.Alarms.Count > 0 ? new Reminder(todo.Alarms[0].Trigger.Duration.Value.Duration()).ToString() : String.Empty;
             AppointmentInfo appInfo = new AppointmentInfo(
                 summary,
                 startDate,
                 endDate,
                 recurrenceRule,
                 recurrenceParentID,
                 reminder);
             appInfo.Description = description;
             appointments.Add(appInfo);
         }
     }
     return appointments;
 }
    /// <summary>
    /// Creates new AppointmentInfo
    /// </summary>
    /// <returns>True if appointment was successfully created, false otherwise</returns>
    private void InsertNewAppointment()
    {
        try
        {
            // prepare appointment
            var appointment = new AppointmentInfo()
            {
                AppointmentPatientFirstName   = FirstName.Value,
                AppointmentPatientLastName    = LastName.Value,
                AppointmentPatientEmail       = Email.Value,
                AppointmentPatientBirthDate   = DateTime.ParseExact(DateOfBirth.Value, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture),
                AppointmentDate               = DateTime.ParseExact(DateOfAppointment.Value, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture),
                AppointmentDoctorID           = ValidationHelper.GetInteger(SelectDoctor.SelectedValue, 0),
                AppointmentPatientPhoneNumber = TelephoneNumber.Value
            };

            // insert appointment
            AppointmentInfoProvider.SetAppointmentInfo(appointment); // or appointment.Insert();

            // Shows successful message to user
            ShowSuccessMessage();

            // Hide form
            plcAppointmentForm.Visible = false;
        }
        catch (Exception ex)
        {
            // log exception to Event log
            EventLogProvider.LogException("DoctorsAppointment", "CREATE", ex);

            // show error message to user
            ShowErrors(ex.Message);
        }
    }
Beispiel #17
0
        protected void ButtonAddAppointment_Click(object sender, EventArgs e)
        {
            List <Doctor> doctors = getDoctors();

            Doctor doctor = doctors[DropDownListPatients.SelectedIndex];

            DateTime date = getRequestedAppointmentTime();

            AppointmentInfo appointment = new AppointmentInfo(
                TextBoxDepartment.Text,
                getPatientID(),
                doctor.DoctorID,
                date,
                TextBoxPurpose.Text
                );

            if (!AppointmentManager.IsAppointmentAvailable(appointment))
            {
                LabelAddStatus.Text = "That appointment slot is not available, please select a different time/date.";
                return;
            }

            bool scheduleSuccess = AppointmentManager.CreateAppointment(appointment);

            if (scheduleSuccess)
            {
                LabelAddStatus.Text = "Your appointment has been created.";
            }
            else
            {
                LabelAddStatus.Text = "There was an error while scheduling your appointment, please try again later.";
            }
        }
Beispiel #18
0
        public int Insert(AppointmentInfo appointmentInfo)
        {
            var appointmentID = 0;

            IDataParameter[] parms = null;

            var SQL_INSERT = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(appointmentInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        ExecuteNonQuery(trans, SQL_INSERT, parms);

                        appointmentID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, TABLE_NAME);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(appointmentID);
        }
Beispiel #19
0
        public List <AppointmentInfo> GetAppointmentInfoListByKeywordID(int publishmentSystemID, int keywordID)
        {
            var appointmentInfoList = new List <AppointmentInfo>();

            string SQL_WHERE =
                $"WHERE {AppointmentAttribute.PublishmentSystemID} = {publishmentSystemID} AND {AppointmentAttribute.IsDisabled} <> '{true}'";

            if (keywordID > 0)
            {
                SQL_WHERE += $" AND {AppointmentAttribute.KeywordID} = {keywordID}";
            }

            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    var appointmentInfo = new AppointmentInfo(rdr);
                    appointmentInfoList.Add(appointmentInfo);
                }
                rdr.Close();
            }

            return(appointmentInfoList);
        }
Beispiel #20
0
        public void Update(AppointmentInfo appointmentInfo)
        {
            IDataParameter[] parms = null;
            var SQL_UPDATE         = BaiRongDataProvider.TableStructureDao.GetUpdateSqlString(appointmentInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

            ExecuteNonQuery(SQL_UPDATE, parms);
        }
        /// <summary>
        /// Function: Convert AppointmentInfo to ScheduleItem
        /// Author  : Jerry Xu
        /// Date    : 2008-12-6
        /// </summary>
        /// <param name="appointment">AppointmentInfo</param>
        /// <returns>ScheduleItem</returns>
        private ScheduleItem ConvertScheduleItem(AppointmentInfo appointment)
        {
            ScheduleItem item = new ScheduleItem();

            item.DisplayContent = ConvertLibrary(appointment.Target);
            item.Timing         = ConvertAppointmentInfo(appointment);
            return(item);
        }
Beispiel #22
0
        //saves the edited info over the existing info
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_EventName.Text.ToString() == "" || _Location.Text.ToString() == "" || _DatePicker.ToString() == "" || _StartTime.ToString() == "" || _EndTime.ToString() == "")
                {
                    MessageDialog dialog = new MessageDialog("All Fields must be entered", "Oops..!");
                    await dialog.ShowAsync();
                }
                else if (_DatePicker.Date.Date < currentTime.Date)
                {
                    MessageDialog dialog = new MessageDialog("Check the date", "Oops..!");
                    await dialog.ShowAsync();
                }
                else if ((_DatePicker.Date.Date == currentTime.Date) && (_StartTime.Time < currentTime.TimeOfDay))
                {
                    MessageDialog dialog = new MessageDialog("Check the Start Time", "Oops..!");
                    await dialog.ShowAsync();
                }
                else if (_StartTime.Time >= _EndTime.Time)
                {
                    MessageDialog dialog = new MessageDialog("Check the End Time", "Oops..!");
                    await dialog.ShowAsync();
                }
                else
                {
                    AppointmentInfo temp = ((AppointmentInfo)TransactionList.SelectedItem);

                    temp.EventName = _EventName.Text;
                    temp.Location  = _Location.Text;
                    temp.EventDate = _DatePicker.Date.ToString("yyyy/MM/dd");
                    temp.StartTime = _StartTime.Time.ToString();
                    temp.EndTime   = _EndTime.Time.ToString();

                    conn.Update(temp);
                    // Resets the UI when edit is complete
                    AddButton.Visibility       = Visibility.Visible;
                    SaveButton.Visibility      = Visibility.Collapsed;
                    TransactionList.Visibility = Visibility.Visible;

                    Results();
                    ClearFields();
                }
            }
            catch (Exception ex)
            {   // Exception to display when amount is invalid or not numbers
                if (ex is FormatException)
                {
                    MessageDialog dialog = new MessageDialog("You forgot to enter the data or entered an invalid data", "Oops..!");
                    await dialog.ShowAsync();
                }
                else
                {
                }
            }
        }
Beispiel #23
0
 private void LoadHistory()
 {
     if (lvEnrollment.SelectedItems.Count > 0)
     {
         AppointmentInfo.RegNo = lblReg.Text = lvEnrollment.SelectedItems[0].Text;
         myA = new AppointmentInfo();
         myA.lvAppointmentByReg(lvAppointments);
         myA = null;
     }
 }
Beispiel #24
0
    protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e)
    {
        // Eliminar la cita
        int id = (int)e.Appointment.ID;

        appointment = CntAriCli.GetAppointment(id, ctx);
        ctx.Delete(appointment);
        ctx.SaveChanges();
        RadAjaxManager1.ResponseScripts.Add("refreshScheduler();");
    }
Beispiel #25
0
        /// <summary>
        /// convert AppointmentInfo to Appointment
        /// </summary>
        /// <param name="proxy"></param>
        /// <returns></returns>
        public static Appointment Convert(AppointmentInfo proxy)
        {
            if (proxy == null)
            {
                return(null);
            }
            Appointment appointment;

            if (proxy.RecurrenceInfo != null)
            {
                appointment = new Appointment(AppointmentType.Pattern);
            }
            else
            {
                appointment = new Appointment();
            }
            appointment.Subject     = proxy.Subject;
            appointment.Start       = proxy.Start;
            appointment.AllDay      = proxy.AllDay;
            appointment.Description = proxy.Description;
            appointment.Duration    = proxy.Duration;

            appointment.End         = proxy.End;
            appointment.HasReminder = proxy.HasReminder;
            //appointment.HasExceptions = proxy.HasExceptions;
            //appointment.IsException=proxy.IsException ;
            //appointment.IsRecurring = false;
            appointment.LabelId              = proxy.LabelId;
            appointment.Location             = proxy.Location;
            appointment.ResourceId           = proxy.ResourceId;
            appointment.CustomFields["Only"] = proxy.CustomFilds;

            appointment.StatusId = proxy.StatusId;
            if (proxy.RecurrenceInfo != null)
            {
                RecurrenceInfo recurrence = appointment.RecurrenceInfo;
                recurrence.AllDay          = proxy.RecurrenceInfo.AllDay;
                recurrence.DayNumber       = proxy.RecurrenceInfo.DayNumber;
                recurrence.Start           = proxy.RecurrenceInfo.Start;
                recurrence.Duration        = proxy.RecurrenceInfo.Duration;
                recurrence.End             = proxy.RecurrenceInfo.End;
                recurrence.Month           = proxy.RecurrenceInfo.Month;
                recurrence.OccurrenceCount = proxy.RecurrenceInfo.OccurrenceCount;
                recurrence.Periodicity     = proxy.RecurrenceInfo.Periodicity;
                recurrence.Range           = (RecurrenceRange)proxy.RecurrenceInfo.Range;

                recurrence.Type        = (RecurrenceType)proxy.RecurrenceInfo.Type;
                recurrence.WeekDays    = (WeekDays)proxy.RecurrenceInfo.WeekDays;
                recurrence.WeekOfMonth = (WeekOfMonth)proxy.RecurrenceInfo.WeekOfMonth;

                //AddRecurrenceInfo(appointment, recurrence);
            }

            return(appointment);
        }
Beispiel #26
0
        void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var appointmentInfo = new AppointmentInfo(e.Item.DataItem);

                var ltlItemIndex             = e.Item.FindControl("ltlItemIndex") as Literal;
                var ltlTitle                 = e.Item.FindControl("ltlTitle") as Literal;
                var ltlKeywords              = e.Item.FindControl("ltlKeywords") as Literal;
                var ltlStartDate             = e.Item.FindControl("ltlStartDate") as Literal;
                var ltlEndDate               = e.Item.FindControl("ltlEndDate") as Literal;
                var ltlContentIsSingle       = e.Item.FindControl("ltlContentIsSingle") as Literal;
                var ltlPvCount               = e.Item.FindControl("ltlPVCount") as Literal;
                var ltlUserCount             = e.Item.FindControl("ltlUserCount") as Literal;
                var ltlIsEnabled             = e.Item.FindControl("ltlIsEnabled") as Literal;
                var ltlAppointmentContentUrl = e.Item.FindControl("ltlAppointmentContentUrl") as Literal;
                var ltlPreviewUrl            = e.Item.FindControl("ltlPreviewUrl") as Literal;
                var ltlEditUrl               = e.Item.FindControl("ltlEditUrl") as Literal;

                ltlItemIndex.Text       = (e.Item.ItemIndex + 1).ToString();
                ltlTitle.Text           = appointmentInfo.Title;
                ltlKeywords.Text        = DataProviderWx.KeywordDao.GetKeywords(appointmentInfo.KeywordId);
                ltlStartDate.Text       = DateUtils.GetDateAndTimeString(appointmentInfo.StartDate);
                ltlEndDate.Text         = DateUtils.GetDateAndTimeString(appointmentInfo.EndDate);
                ltlContentIsSingle.Text = appointmentInfo.ContentIsSingle == true ? "单预约" : "多预约";
                ltlPvCount.Text         = appointmentInfo.PvCount.ToString();
                ltlUserCount.Text       = appointmentInfo.UserCount.ToString();
                ltlIsEnabled.Text       = StringUtils.GetTrueOrFalseImageHtml(!appointmentInfo.IsDisabled);

                var urlAppointmentContent = PageAppointmentContent.GetRedirectUrl(PublishmentSystemId, appointmentInfo.Id);
                ltlAppointmentContentUrl.Text = $@"<a href=""{urlAppointmentContent}"">预约查看</a>";

                var itemId = 0;
                if (appointmentInfo.ContentIsSingle)
                {
                    itemId = DataProviderWx.AppointmentItemDao.GetItemId(PublishmentSystemId, appointmentInfo.Id);
                }

                var urlPreview = AppointmentManager.GetIndexUrl(PublishmentSystemInfo, appointmentInfo.Id, string.Empty);
                if (appointmentInfo.ContentIsSingle)
                {
                    urlPreview = AppointmentManager.GetItemUrl(PublishmentSystemInfo, appointmentInfo.Id, itemId, string.Empty);
                }
                //urlPreview = BackgroundPreview.GetRedirectUrlToMobile(urlPreview);
                //ltlPreviewUrl.Text = $@"<a href=""{urlPreview}"" target=""_blank"">预览</a>";

                var urlEdit = PageAppointmentMultipleAdd.GetRedirectUrl(PublishmentSystemId, appointmentInfo.Id, itemId);
                if (appointmentInfo.ContentIsSingle)
                {
                    urlEdit = PageAppointmentSingleAdd.GetRedirectUrl(PublishmentSystemId, appointmentInfo.Id, itemId);
                }
                ltlEditUrl.Text = $@"<a href=""{urlEdit}"">编辑</a>";
            }
        }
Beispiel #27
0
        public async Task <IActionResult> Create([Bind("AppointmentID,HostUser,GuestUser,DatenTime,Subject,Status,HostUserID")] AppointmentInfo appointmentInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(appointmentInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HostUserID"] = new SelectList(_context.Users, "UserId", "EmailID", appointmentInfo.HostUserID);
            return(View(appointmentInfo));
        }
Beispiel #28
0
        public async Task <Response> AddAppointment(List <DayOfWeek> days, List <TimeOfDay> times, List <String> symptoms, String notes)
        {
            var dataHandler = ApplicationCore.Container.Resolve <IAppointmentAPI>();
            var request     = new AppointmentInfo();

            request.DoctorId       = Convert.ToInt32(DoctorId);
            request.RequestedDays  = days;
            request.RequestedTimes = times;
            request.Topics         = symptoms;
            request.Notes          = notes;

            return(await dataHandler.AddAppointment(request));
        }
Beispiel #29
0
 private void DeleteInfo()
 {
     if ((Interactive.LInfoWarning("Are you sure you want to Delete ?", "Appointment") == DialogResult.Yes))
     {
         myA = new AppointmentInfo();
         AppointmentInfo.AppointmentID = Convert.ToInt64(lblAppointmentID.Text);
         if (myA.RemoveAppointment())
         {
             LoadHistory();
             LiveClear();
         }
         return;
     }
 }
        private SchedulerEvent ToScheduleEvent(AppointmentInfo app)
        {
            var result = new SchedulerEvent();

            result.CustomerName  = $"{app.CustomerFirstName} {app.CustomerLastName}";
            result.ServiceName   = $"{app.ServiceName}";
            result.Start_date    = app.AppointmentDate;
            result.End_date      = app.AppointmentDate.AddMinutes(app.AppointmentDuration);
            result.AppointmentId = app.AppointmentId;
            result.ServiceId     = app.ServiceId;
            result.StageType     = app.CalendarStageType;
            result.StageId       = app.StageId;
            result.ProcessId     = app.ProcessId;
            return(result);
        }
Beispiel #31
0
        public bool TryShowAppointment(AppointmentInfo appointmentInfo)
        {
            var app = GetAppointmentsInRange(_calendarFolder, appointmentInfo.FromDateTime.AddMinutes(-5), appointmentInfo.FromDateTime.AddMinutes(5));

            foreach (AppointmentItem item in app)
            {
                if (GetAppointmentInfo(item) == appointmentInfo)
                {
                    item.Display(false);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #32
0
        public void Save(AppointmentInfoProxy proxy)
        {
            if (proxy.EmployeeId == Guid.Empty)
            {
                throw new UserException("Изберете служител");
            }

            if (proxy.PartnerId == Guid.Empty)
            {
                throw new UserException("Изберете партньор");
            }

            if (proxy.TypeId == Guid.Empty)
            {
                throw new UserException("Изберете тип");
            }

            if (proxy.Date == DateTime.MinValue)
            {
                throw new UserException("Изберете дата");
            }

            if (proxy.Count <= 0)
            {
                throw new UserException("Невалиден брой");
            }

            try
            {
                var repo            = this.RepoFactory.Get <AppointmentInfoRepository>();
                var appointmentInfo = new AppointmentInfo
                {
                    Id         = Guid.NewGuid(),
                    EmployeeId = proxy.EmployeeId,
                    PartnerId  = proxy.PartnerId,
                    TypeId     = proxy.TypeId,
                    Date       = proxy.Date,
                    Count      = proxy.Count
                };

                repo.Add(appointmentInfo);
                repo.SaveChanges();
            }
            catch (Exception)
            {
                throw new UserException("Грешка при записването на ангажиментът");;
            }
        }
Beispiel #33
0
 public static string GetAppointmentSubject(AppointmentInfo app)
 {
     string profesional = "";
     if (app.Professional != null)
         profesional = app.Professional.FullName;
     string frn = app.Patient.OftId.ToString();
     if (app.Arrival == null || NullDateTime(app.Arrival))
         return String.Format("{0} ({1} | {2}) [{3}] NH:{4}",
             app.Patient.FullName, app.AppointmentType.Name, app.Comments, profesional, frn);
     else
         return String.Format("{0} ({1} | {2}) [{3}] NH:{5} [{4:HH:mm:ss}]",
             app.Patient.FullName, app.AppointmentType.Name, app.Comments, profesional, app.Arrival, frn);
 }
Beispiel #34
0
 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
         Response.Redirect("Default.aspx");
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         user = CntAriCli.GetUser(user.UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "visit"
                         select p).FirstOrDefault<Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
     }
     // cheks if is call from another form
     if (Request.QueryString["Type"] != null)
         type = Request.QueryString["Type"];
     // read patient information
     if (Request.QueryString["PatientId"] != null)
     {
         patientId = int.Parse(Request.QueryString["PatientId"]);
         patient = CntAriCli.GetPatient(patientId, ctx);
     }
     if (Request.QueryString["VisitId"] != null)
     {
         visitId = Int32.Parse(Request.QueryString["VisitId"]);
         visit = CntAriCli.GetVisit(visitId, ctx);
         patient = visit.Patient;
         patientId = patient.PersonId;
         string title = "";
         if (visit.VisitReason != null)
         {
             title = String.Format("{0} ({1:dd/MM/yyyy}) {2}",
                 visit.VisitReason.Name,
                 visit.VisitDate,
                 visit.Patient.FullName);
         }
         else
         {
             title = String.Format("{0} ({1:dd/MM/yyyy})",
                 visit.Patient.FullName,
                 visit.VisitDate);
         }
         lblTitle.Text = title;
         this.Title = title;
     }
     else
     {
         lblTitle.Text = "Nueva visita";
     }
     if (Request.QueryString["AppointmentId"] != null)
     {
         appinfId = int.Parse(Request.QueryString["AppointmentId"]);
         appinf = CntAriCli.GetAppointment(appinfId, ctx);
     }
     if (Request.QueryString["Caller"] != null)
     {
         caller = Request.QueryString["Caller"];
     }
 }
Beispiel #35
0
        public static void ImportAppointmentInfo(OleDbConnection con, AriClinicContext ctx)
        {
            //(1) Borramos las citas anteriores.
            //ctx.Delete(ctx.AppointmentInfos);

            //(2) Leer las agendas OFT y darlas de alta en AriClinic
            string sql = "SELECT * FROM Citas";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConCitas");

            int nreg = ds.Tables["ConCitas"].Rows.Count;
            int reg = 0;
            int i2 = 0;
            int i3 = 0;
            int i4 = 0;
            foreach (DataRow dr in ds.Tables["ConCitas"].Rows)
            {
                i3++;
                reg++;
                Console.WriteLine("Citas {0:#####0} de {1:#####0} {2}", reg, nreg, "CITAS");
                int id = (int)dr["NumHis"];
                Patient patient = (from p in ctx.Patients
                                   where p.OftId == id
                                   select p).FirstOrDefault<Patient>();
                id = (int)dr["IdLibCit"];
                Diary diary = (from d in ctx.Diaries
                               where d.OftId == id
                               select d).FirstOrDefault<Diary>();
                DateTime dt = (DateTime)dr["Fecha"];
                DateTime ht = (DateTime)dr["Hora"];
                DateTime dd = new DateTime(dt.Year, dt.Month, dt.Day, ht.Hour, ht.Minute, ht.Second);
                AppointmentInfo app = (from a in ctx.AppointmentInfos
                                       where a.Diary.DiaryId == diary.DiaryId
                                       && a.Patient.PersonId == patient.PersonId
                                       && a.BeginDateTime == dd
                                       select a).FirstOrDefault<AppointmentInfo>();
                if (app == null)
                {
                    app = new AppointmentInfo();
                    ctx.Add(app);
                }
                id = (int)dr["IdTipCit"];
                app.AppointmentType = (from at in ctx.AppointmentTypes
                                       where at.OftId == id
                                       select at).FirstOrDefault<AppointmentType>();
                app.Diary = diary;
                app.Patient = patient;
                id = (int)dr["IdMed"];
                app.Professional = (from pr in ctx.Professionals
                                    where pr.OftId == id
                                    select pr).FirstOrDefault<Professional>();

                i4++;

                app.BeginDateTime = dd;
                ht = (DateTime)dr["HrFin"];
                dd = new DateTime(dt.Year, dt.Month, dt.Day, ht.Hour, ht.Minute, ht.Second);
                app.EndDateTime = dd;
                ht = (DateTime)dr["Durac"];
                app.Duration = ht.Minute;
                if (app.Patient != null)
                {
                    i2++;
                    app.Subject = CntAriCli.GetAppointmentSubject(app);
                }
                else
                {
                    app.Subject = "SIN PACIENTE";
                }
                ctx.SaveChanges();
            }

        }
Beispiel #36
0
    protected void Page_Init(object sender, EventArgs e)
    {
        ctx = new AriClinicContext("AriClinicContext");
        // security control, it must be a user logged
        if (Session["User"] == null)
            Response.Redirect("Default.aspx");
        else
        {
            user = (User)Session["User"];
            user = CntAriCli.GetUser(user.UserId, ctx);
            Process proc = (from p in ctx.Processes
                            where p.Code == "visit"
                            select p).FirstOrDefault<Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
            if (user.Professionals.Count > 0)
            {
                professional = user.Professionals[0];
                LoadComboProfesional(professional);
            }
        }

        // 
        if (Request.QueryString["VisitId"] != null)
        {
            visitId = Int32.Parse(Request.QueryString["VisitId"]);
            visit = CntAriCli.GetVisit(visitId, ctx);
            LoadData(visit);
        }
        else
        {
            rdpVisitDate.SelectedDate = DateTime.Now;
            // load professional
            if (Session["Professional"] != null) LoadComboProfesional((Professional)Session["Professional"]);
            // called from an appointment?
            if (Request.QueryString["AppointmentId"] != null) 
            {
                app = CntAriCli.GetAppointment(int.Parse(Request.QueryString["AppointmentId"]), ctx);
                if (app != null)
                {
                    Patient pat = app.Patient;
                    rdcPatient.Items.Clear();
                    rdcPatient.Items.Add(new RadComboBoxItem(pat.FullName, pat.PersonId.ToString()));
                    rdcPatient.SelectedValue = pat.PersonId.ToString();
                    //
                    rdpVisitDate.SelectedDate = app.BeginDateTime;
                    //
                    LoadComboProfesional(app.Professional);
                    //
                    AppointmentType appt = app.AppointmentType;
                    rdcAppointmentType.Items.Clear();
                    rdcAppointmentType.Items.Add(new RadComboBoxItem(appt.Name, appt.AppointmentTypeId.ToString()));
                    rdcAppointmentType.SelectedValue = appt.AppointmentTypeId.ToString();
                    //
                    fromAppointment = true;
                }
            }
        }
        //
        if (Request.QueryString["PatientId"] != null)
        {
            patientId = int.Parse(Request.QueryString["PatientId"]);
            patient = CntAriCli.GetPatient(patientId, ctx);
            // fix rdc with patient
            rdcPatient.Items.Clear();
            rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName,patient.PersonId.ToString()));
            rdcPatient.SelectedValue = patient.PersonId.ToString();
            rdcPatient.Enabled = false;
        }
        //
        if (Request.QueryString["Type"] != null)
        {
            type = Request.QueryString["Type"];
            if (type == "InTab")
            {
                HtmlControl tt = (HtmlControl)this.FindControl("TitleArea");
                tt.Attributes["class"] = "ghost";
            }
        }
        if (Request.QueryString["Caller"] != null)
        {
            caller = Request.QueryString["Caller"];
        }
    }
 protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
 {
     string estado = e.Appointment.Description;
     int id = (int)e.Appointment.ID;
     appointment = CntAriCli.GetAppointment(id, ctx);
     //Modificamos la apariencia según el estado
     switch (estado)
     {
         case "0":
             // Citado dejamos el item como está
             e.Appointment.CssClass = "rsCategoryWhite";
             break;
         case "1":
             // Programada
             e.Appointment.CssClass = "rsCategoryBlue"; //rsCategoryRed
             break;
         case "2":
             // Sala de espera
             e.Appointment.CssClass = "rsCategoryPink"; //rsCategoryGreen
             break;
         case "3":
             // Atendido
             e.Appointment.CssClass = "rsCategoryGreen"; //rsCategoryYellow
             break;
         case "4":
             e.Appointment.CssClass = "rsCategoryYellow";
             break;
         case "5":
             // No presentado / Sin hora?
             e.Appointment.CssClass = "rsCategoryOrange"; //rsCategoryBlue
             break;
         default:
             break;
     }
     // now we charge the new description
     e.Appointment.Description = CntAriCli.GetAppointmentDescription(appointment, ctx); // change?
     e.Appointment.ToolTip = String.Format("CITA PROGRAMADA desde la {0:HH:mm} hasta las {1:HH:mm}", appointment.BeginDateTime, appointment.EndDateTime);
 }
Beispiel #38
0
 public static string GetAppointmentDescription(AppointmentInfo app, AriClinicContext ctx)
 {
     Parameter par = CntAriCli.GetParameter(ctx);
     string description = "";
     if (par.AppointmentExtension)
         description = String.Format("FRN:{0} - {1}", app.Patient.OftId, CntAriCli.GetInsuranceData(app.Patient, ctx));
     return description;
 }
 /// <summary>
 /// As its name suggest if there isn't an object
 /// it'll create it. If exists It modifies it.
 /// </summary>
 /// <returns></returns>
 protected bool CreateChange()
 {
     if (!DataOk())
         return false;
     if (app == null)
     {
         app = new AppointmentInfo();
         UnloadData(app);
         ctx.Add(app);
         ctx.SaveChanges();
     }
     else
     {
         UnloadData(app);
         ctx.SaveChanges();
     }
     return true;
 }
 protected void LoadData(AppointmentInfo app)
 {
     LoadStatusCombo(app);
     if (professional != null)
     {
         LoadProfessionalCombo(professional);
     }
     if (app == null) return; // There isn't any agenda to show
     txtAppointmentId.Text = String.Format("{0:00000000}", app.AppointmentId);
     LoadPatientCombo(app.Patient);
     LoadDiaryCombo(app.Diary);
     LoadAppointmentTypeCombo(app.AppointmentType);
     LoadProfessionalCombo(app.Professional);
     rddtBeginDateTime.SelectedDate = app.BeginDateTime;
     rddtEndDateTime.SelectedDate = app.EndDateTime;
     // arrival could be null in two different ways
     if (app.Arrival != null && !CntAriCli.NullDateTime(app.Arrival))
         rddtArrival.SelectedDate = app.Arrival;
     txtDuration.Text = app.Duration.ToString();
     txtSubject.Text = app.Subject;
     txtDescription.Text = CntAriCli.GetAppointmentDescription(app, ctx);
     txtComments.Text = app.Comments;
     //
     string command = String.Format("return ViewHisAdm({0});", app.Patient.PersonId);
     btnMedicalRecord.OnClientClick = command;
     btnMedicalRecord.Visible = true;
     //
     if (app != null && app.BaseVisits.Count > 0)
     {
         command = String.Format("return EditVisit({0});", app.BaseVisits[0].VisitId);
     }
     else
     {
         command = String.Format("return CreateVisit({0});", app.AppointmentId);
     }
     btnVisit.OnClientClick = command;
     btnVisit.Visible = true;
 }
 protected void UnloadData(AppointmentInfo app)
 {
     app.Patient = CntAriCli.GetPatient(int.Parse(rdcPatient.SelectedValue), ctx);
     app.Diary = CntAriCli.GetDiary(int.Parse(rdcDiary.SelectedValue), ctx);
     app.Professional = CntAriCli.GetProfessional(int.Parse(rdcProfessional.SelectedValue), ctx);
     app.AppointmentType = CntAriCli.GetAppointmentType(int.Parse(rdcAppointmentType.SelectedValue), ctx);
     app.BeginDateTime = (DateTime)rddtBeginDateTime.SelectedDate;
     app.EndDateTime = (DateTime)rddtEndDateTime.SelectedDate;
     app.Duration = int.Parse(txtDuration.Text);
     app.Status = ddlStatus.SelectedValue;
     if (rddtArrival.SelectedDate != null)
         app.Arrival = (DateTime)rddtArrival.SelectedDate;
     else
         app.Arrival = DateTime.Parse("01/01/0001 00:00:00");
     app.Subject = CntAriCli.GetAppointmentSubject(app);
     app.Comments = txtComments.Text;
 }
    protected void Page_Init(object sender, EventArgs e)
    {
        ctx = new AriClinicContext("AriClinicContext");
        // security control, it must be a user logged
        if (Session["User"] == null)
            Response.Redirect("Default.aspx");
        else
        {
            user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
            user = CntAriCli.GetUser(user.UserId, ctx);
            Process proc = (from p in ctx.Processes
                            where p.Code == "appointment"
                            select p).FirstOrDefault<Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
            if (user.Professionals.Count > 0)
                professional = user.Professionals[0];
        }
        if (Request.QueryString["DiaryId"] != null)
        {
            // Diary passed
            Diary dia = CntAriCli.GetDiary(int.Parse(Request.QueryString["DiaryId"]), ctx);
            if (dia != null)
            {
                LoadDiaryCombo(dia);
            }
        }
        if (Request.QueryString["PatientId"] != null)
        {
            // Patient passed
            Patient pat = CntAriCli.GetPatient(int.Parse(Request.QueryString["PatientId"]), ctx);
            LoadPatientCombo(pat);
        }
        if (Request.QueryString["AppointmentId"] != null)
        {
            appId = int.Parse(Request.QueryString["AppointmentId"]);
            app = CntAriCli.GetAppointment(appId, ctx);
        }

        LoadData(app);

        // Must be check after load data.
        if (Request.QueryString["BeginDateTime"] != null)
        {
            beginDateTime = GetCorrectDateTime(Request.QueryString["BeginDateTime"]);
            rddtBeginDateTime.SelectedDate = beginDateTime;
        }
        if (Request.QueryString["EndDateTime"] != null)
        {
            endDateTime = GetCorrectDateTime(Request.QueryString["EndDateTime"]);
            rddtEndDateTime.SelectedDate = endDateTime;
            // TODO: Recalculate duration.
        }
        // Appointement moved
        if (beginDateTime != null && app != null)
        {
            DateTime bt = (DateTime)beginDateTime;
            DateTime et = bt.AddMinutes(app.Duration);
            rddtEndDateTime.SelectedDate = et;
        }
        // Appintment resized
        if (beginDateTime != null && endDateTime != null)
        {
            DateTime bt = (DateTime)beginDateTime;
            DateTime et = (DateTime)endDateTime;
            TimeSpan t = et.Subtract(bt);
            int d = t.Minutes + (t.Hours * 60);
            txtDuration.Text = d.ToString();
        }
    }
 protected void LoadStatusCombo(AppointmentInfo app)
 {
     // Status are hard coded
     ddlStatus.Items.Clear(); // erase all previous codes
     ddlStatus.Items.Add(new ListItem( "Programada","1"));
     ddlStatus.Items.Add(new ListItem("Sala de espera","2"));
     ddlStatus.Items.Add(new ListItem("Atendida", "3"));
     ddlStatus.Items.Add(new ListItem("No presentado","4"));
     ddlStatus.Items.Add(new ListItem("Sin hora", "5"));
     if (app != null)
     {
         ddlStatus.SelectedValue = app.Status;
     }
     else
     {
         // By default an appointment is scheduled
         ddlStatus.SelectedValue = "1";
     }
 }