Ejemplo n.º 1
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedItem == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            Call call = SelectedItem;

            try
            {
                CallFrm frm = new CallFrm()
                {
                    ID          = call.ID,
                    Flag        = call.flag,
                    Notes       = call.notes,
                    Date        = call.time,
                    Duration    = call.duration_mins,
                    Time        = call.time,
                    WorkerCount = call.required_workers,
                    ServiceUser = ServiceUser,
                    TravelTime  = call.traveltime_mins,
                    Title       = "Edit Call"
                };

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    //add this user to the database

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

                    //attempt to save
                    try
                    {
                        call.MarkForSave = true;
                    }
                    catch (Exception ex)
                    {
                        Cura.Common.Common.LogError("Error Occured While Trying To Save This Call", ex);
                    }

                    //refresh items on this calendar
                    RefreshItems();

                    //refresh items on the worker calendar
                    WorkerManager.Instance.RefreshCalendars(call.time);
                }
                frm.Dispose();
            }
            catch (Exception ex)
            {
                Cura.Common.Common.LogError("Error Creating New Worker", ex);
            }
        }
Ejemplo n.º 2
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;
        }