Example #1
0
        private void calendar1_ItemCreated(object sender, System.Windows.Forms.Calendar.CalendarItemCancelEventArgs e)
        {
            var start = Convert.ToDateTime(e.Item.Date).ToString("yyyy-MM-dd") + "T" + Convert.ToDateTime(e.Item.Date).ToString("HH:mm:ss");
            var end   = Convert.ToDateTime(e.Item.EndDate).ToString("yyyy-MM-dd") + "T" + Convert.ToDateTime(e.Item.EndDate).ToString("HH:mm:ss");

            using (ScheduleDialog form = new ScheduleDialog(start, end, e.Item.Date.ToString()))
            {
                DialogResult dr = form.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    LoadingCalendar("Status");
                    monthView1_SelectionChanged(null, null);
                }
            }
        }
        private void calendar1_ItemDeleting(object sender, CalendarItemCancelEventArgs e)
        {
            Visit visit1 = new Visit(Convert.ToInt32(e.Item.ID), userID);

            if (!visit1.canEditPlan)
            {
                MessageBox.Show("Невозможно удалить план в прошлом", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                e.Cancel = true;
                return;
            }

            if ((visit1.CommRD != "") && (globalData.UserAccess > 4))
            {
                MessageBox.Show("С комментариями руководителя нельзя удалить план", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                e.Cancel = true;
            }
            else
            {
                visit1.Delete();
                globalData.update = true;
            }
        }
Example #3
0
 protected virtual void OnItemEdited(CalendarItemCancelEventArgs e)
 {
     if (ItemTextEdited != null)
     {
         ItemTextEdited(this, e);
     }
 }
Example #4
0
 protected virtual void OnItemDeleting(CalendarItemCancelEventArgs e)
 {
     if (ItemDeleting != null)
     {
         ItemDeleting(this, e);
     }
 }
Example #5
0
        /// <summary>
        /// Deletes the currently selected item
        /// </summary>
        private void DeleteSelectedItems()
        {
            Stack<CalendarItem> toDelete = new Stack<CalendarItem>();

            foreach (CalendarItem item in Items)
            {
                if (item.Selected)
                {
                    CalendarItemCancelEventArgs evt = new CalendarItemCancelEventArgs(item);

                    OnItemDeleting(evt);

                    if (!evt.Cancel)
                    {
                        toDelete.Push(item);
                    }
                }
            }

            if (toDelete.Count  > 0)
            {
                while (toDelete.Count > 0)
                {
                    CalendarItem item = toDelete.Pop();

                    Items.Remove(item);

                    OnItemDeleted(new CalendarItemEventArgs(item));
                }

                Renderer.PerformItemsLayout();
            }
        }
Example #6
0
 private void calendar1_ItemCreated(object sender, CalendarItemCancelEventArgs e)
 {
     _items.Add(e.Item);
 }
Example #7
0
 private void calProveedor_ItemCreating(object sender, CalendarItemCancelEventArgs e)
 {
     /* e.Cancel = true;
     if (this.mvCalendarioProveedor.SelectionStart > new DateTime(2000, 01, 01))
     {
         CargarItemsACalendario(this.mvCalendarioProveedor.SelectionStart, this.mvCalendarioProveedor.SelectionEnd);
     }
     else
     {
         CargarItemsACalendario(DateTime.Today, DateTime.Today.AddDays(6));
     }
     */
 }
Example #8
0
 private void calendar1_ItemTextEditing(object sender, CalendarItemCancelEventArgs e)
 {
 }
Example #9
0
        /// <summary>
        /// Finalizes editing the <see cref="EditModeItem"/>.
        /// </summary>
        /// <param name="cancel">Value indicating if edition of item should be canceled.</param>
        public void FinalizeEditMode(bool cancel)
        {
            if (!EditMode || EditModeItem == null || _finalizingEdition) return;

            _finalizingEdition = true;

            string cancelText = _editModeItem.Text;
            CalendarItem itemBuffer = _editModeItem;
            _editModeItem = null;
            CalendarItemCancelEventArgs evt = new CalendarItemCancelEventArgs(itemBuffer);

            if(!cancel)
                itemBuffer.Text = TextBox.Text.Trim();

            if (TextBox != null)
            {
                TextBox.Visible = false;
                Controls.Remove(TextBox);
                TextBox.Dispose();
            }
            
            if(_editModeItem != null)
                Invalidate(itemBuffer);

            _textBox = null;

            if (_creatingItem)
            {
                OnItemCreated(evt);
            }
            else
            {
                OnItemEdited(evt);
            }

            if (evt.Cancel)
            {
                itemBuffer.Text = cancelText;
            }


            _creatingItem = false;
            _finalizingEdition = false;

            if (State == CalendarState.EditingItemText)
            {
                SetState(CalendarState.Idle);
            }
        }
Example #10
0
 private void calendar1_ItemCreated(object sender, CalendarItemCancelEventArgs e)
 {
     _items.Add(e.Item);
     //if (e.Item.Text.Length > 0)
     //{
     e.Item.Tag = maxIdOfCalendarItem;
     List<string> values = new List<string> { maxIdOfCalendarItem.ToString(), UserName, Helper.ConvertToDatetimeSql(e.Item.StartDate), Helper.ConvertToDatetimeSql(e.Item.EndDate), e.Item.Text, "0" };
     db.InsertRowToTable("calendar", DatabaseContants.columnsCalendar, values);
     //MessageBox.Show("s");
     //}
     maxIdOfCalendarItem = Helper.SearchMaxValueOfTable(db,"calendar", "IdCalendar", "DESC");
 }
Example #11
0
        private void calendar1_ItemCreated(object sender, CalendarItemCancelEventArgs e)
        {
            Turno objTurno = new Turno();
            // SE CREA EL TURNO
            // NO HA SIDO AVISADO - NO HA ASISTIDO

            objTurno.setDni(e.Item.Text);
            objTurno.setFecha(e.Item.Date);
            objTurno.setDuracion(e.Item.Duration);
            objTurno.setMatricula(this.vOutlookNavPane1.SelectedItem.Text);
            objTurno.setAviso(0);
            objTurno.setAsistencia(0);

            if (objTurno.ExisteTurno())
            {
                // EL TURNO YA FUE DADO
                MessageBox.Show("El turno se dio a otro paciente.", "Advertencia");
                this.calendar1.Items.Remove(e.Item);
            }
            else
            {
                // EL TURNO ESTA LIBRE
                objTurno.NuevoTurno();
            }
            this.llenarSelectivo();
        }
 private void calendar1_ItemCreated_1(object sender, CalendarItemCancelEventArgs e)
 {
     MessageBox.Show(e.Item.Date +" "+ e.Item.Duration +" "+ e.Item.Text ,"Datos Turno Creado");
 }
Example #13
0
 private void calendar1_ItemDeleting(object sender, CalendarItemCancelEventArgs e)
 {
     e.Cancel=true;
 }
Example #14
0
 private void calendar1_ItemCreating(object sender, CalendarItemCancelEventArgs e)
 {
     /*
     e.Cancel=true;
     if (this.mVCobrarCredito.SelectionStart > new DateTime(2000, 01, 01))
     {
         CargarClientesaCalendario(this.mVCobrarCredito.SelectionStart, this.mVCobrarCredito.SelectionEnd);
     }
     else
     {
         CargarClientesaCalendario(DateTime.Today, DateTime.Today.AddDays(6));
     }
     */
 }
Example #15
0
        /// <summary>
        /// Activates the edit mode on the specified item
        /// </summary>
        /// <param name="item"></param>
        public void ActivateEditMode(CalendarItem item)
        {
            CalendarItemCancelEventArgs evt = new CalendarItemCancelEventArgs(item);

            if (!_creatingItem)
            {
                OnItemEditing(evt);
            }

            if (evt.Cancel)
            {
                return;
            }

            _editModeItem = item;
            TextBox = new CalendarTextBox(this);
            TextBox.KeyDown += new KeyEventHandler(TextBox_KeyDown);
            TextBox.LostFocus += new EventHandler(TextBox_LostFocus);
            Rectangle r = item.Bounds;
            r.Inflate(-2, -2);
            TextBox.Bounds = r;
            TextBox.BorderStyle = BorderStyle.None;
            TextBox.Text = item.Text;
            TextBox.Multiline = true;

            Controls.Add(TextBox);
            TextBox.Visible = true;
            TextBox.Focus();
            TextBox.SelectionStart = TextBox.Text.Length;

            SetState(CalendarState.EditingItemText);
        }
Example #16
0
        /// <summary>
        /// Creates a new item on the current selection. 
        /// If there's no selection, this will be ignored.
        /// </summary>
        /// <param name="itemText">Text of the item</param>
        /// <param name="editMode">If <c>true</c> activates the edit mode so user can edit the text of the item.</param>
        public void CreateItemOnSelection(string itemText, bool editMode)
        {
            if (SelectedElementEnd == null || SelectedElementStart == null) return;

            CalendarTimeScaleUnit unitEnd = SelectedElementEnd as CalendarTimeScaleUnit;
            CalendarDayTop dayTop = SelectedElementEnd as CalendarDayTop;
            CalendarDay day = SelectedElementEnd as CalendarDay;
            TimeSpan duration = unitEnd != null ? unitEnd.Duration : new TimeSpan(23, 59, 59);
            CalendarItem item = new CalendarItem(this);

            DateTime dstart = SelectedElementStart.Date;
            DateTime dend = SelectedElementEnd.Date;

            if (dend.CompareTo(dstart) < 0)
            {
                DateTime dtmp = dend;
                dend = dstart;
                dstart = dtmp;
            }

            item.StartDate = dstart;
            item.EndDate = dend.Add(duration);
            item.Text = itemText;

            CalendarItemCancelEventArgs evtA = new CalendarItemCancelEventArgs(item);

            OnItemCreating(evtA);

            if (!evtA.Cancel)
            {
                Items.Add(item);

                if (editMode)
                {
                    _creatingItem = true;
                    ActivateEditMode(item);
                }
            }

            
        }
Example #17
0
 private void calendar1_ItemTextEdited(object sender, CalendarItemCancelEventArgs e)
 {
     // e.Item.Tag = // set id
     Helper.UpdateRowToTableCalendar(db, "calendar", new List<string> { "Text" }, new List<string> { e.Item.Text }, e.Item.Tag.ToString(), UserName);
 }
Example #18
0
 private void Calendar_ItemCreating(object sender, CalendarItemCancelEventArgs e)
 {
     e.Cancel = true; // cancel new item creation by user on calendar.
 }
Example #19
0
        private void calendar_ItemCreating(object sender, System.Windows.Forms.Calendar.CalendarItemCancelEventArgs e)
        {
            if (e.Item.IsOnDayTop)
            {
                e.Cancel = true;
                return;
            }


            try
            {
                CallFrm frm = new CallFrm();

                frm.Date = e.Item.StartDate;
                frm.Time = e.Item.StartDate;

                switch (e.Item.StartDate.Hour)
                {
                case 0:
                    frm.Time = frm.Time.AddHours(6);
                    break;

                case 1:
                    frm.Time = frm.Time.AddHours(11);
                    break;

                case 2:
                    frm.Time = frm.Time.AddHours(13);
                    break;

                case 3:
                    frm.Time = frm.Time.AddHours(15);
                    break;
                }

                frm.ServiceUser = ServiceUser;

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Call call = CallManager.Instance.NewCall();

                    call.duration_mins    = frm.Duration;
                    call.time             = frm.Time;
                    call.required_workers = frm.WorkerCount;
                    call.ServiceUser      = ServiceUser;
                    call.flag             = frm.Flag;
                    call.notes            = frm.Notes;
                    call.traveltime_mins  = frm.TravelTime;

                    CallManager.Instance.Calls.Add(call);

                    ServiceUser.Calls.Add(call);

                    //now refresh the calendar items on this calendar only
                    Refresh();

                    //refresh the lists and headers
                    ServiceUserManager.Instance.RefreshLists(false, false, false);
                    ServiceUserManager.Instance.RefreshHeaders();

                    //<DEP>refresh worker calendar that has this call on
                    //WorkerManager.Instance.RefreshCalendars(call.time);
                }

                frm.Dispose();
            }
            catch (Exception ex)
            {
                Cura.Common.Common.LogError("Error Creating New Call", ex);
            }

            e.Cancel = true;
        }