Subversion Repository Public Repository

17001_SKYPRO

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
using Sky.Core.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;
using Sky.Core.Utilities;
using Sky.Core;

namespace Sky.Reports.Forms
 {
    public partial class frmScheduler : SkyForm
    {
        SQLDbConnection cnndata;
        public frmScheduler()
        {
            InitializeComponent();
            cnndata = new SQLDbConnection();
            cnndata.conn.ConnectionString = Config.ConnectionString;
            schedulerControl1.GroupType = SchedulerGroupType.Resource;
            schedulerControl1.DayView.TimeScale = new TimeSpan(0, 15, 0);
            schedulerControl1.DayView.VisibleTime = new TimeOfDayInterval(new TimeSpan(8, 00, 0), new TimeSpan(22, 00, 0));
            schedulerControl1.Start = DateTime.Now;
            // show date from now to now + 7
            schedulerControl1.LimitInterval = new TimeInterval(DateTime.Now, DateTime.Now.AddDays(7));
            DayView view = (DayView)this.schedulerControl1.ActiveView;
            view.TimeRulers[0].ShowMinutes = true;
            //schedulerControl1.CustomizeDateNavigationBarCaption += scheduler_CustomizeDateNavigationBarCaption;
            schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("ApptAddInfo", "AdditionalInfo", FieldValueType.String));
            schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("ServiceInfo", "ServiceAddInfo", FieldValueType.String));
            schedulerStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("TimeInfo", "TimeAddInfo", FieldValueType.String));
            schedulerControl1.ActiveView.LayoutChanged();
        }

        private void frmScheduler_Load(object sender, EventArgs e)
        {
            try {
                string sql = "select TOP 10 * from DM_NhanVien";
                cnndata.openConnection();
                DataSet ds = cnndata.getData(sql);
                //this.resourcesTableAdapter()
                //this.schedulerControl1.Storage.Resources = 

                List<EFResource> list = new List<EFResource>();
                EFResource item = null;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        item = new EFResource();
                        item.UniqueID = Convert.ToInt32(row["Id"].ToString());
                        item.ResourceID = Convert.ToInt64(row["Code"].ToString());

                        item.ResourceName = row["Ten"].ToString();


                        list.Add(item);
                    }
                }
                schedulerControl1.Storage.Resources.DataSource = list;
                //schedulerControl1.Storage.Resources.DataSource
                // Mappings
                //// Required mapping resource.
                this.schedulerControl1.Storage.Resources.Mappings.Id = "ResourceID";
                this.schedulerControl1.Storage.Resources.Mappings.ParentId = "ResourceID";
                this.schedulerControl1.Storage.Resources.Mappings.Caption = "ResourceName";
                //this.schedulerControl1.Storage.Resources.Mappings. = "ResourceName";
                //this.schedulerControl1.Storage.Resources.Mappings.

                // Appointment
                sql = "select x.*, y.Ten from Solichhen x join DM_HangHoa y on x.DichVuHenCode = y.Code ";
                ds = cnndata.getData(sql);
                List<EFAppointment> listAP = new List<EFAppointment>();
                EFAppointment itemAP = null;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string gio = "";
                    
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        itemAP = new EFAppointment();
                        itemAP.UniqueID = String.IsNullOrEmpty((row["Id"].ToString())) ? 0 : Convert.ToInt32(row["Id"].ToString());
                        itemAP.ResourceID = String.IsNullOrEmpty((row["NhanVienTuVanCode"].ToString()))? 0 : Convert.ToInt64(row["NhanVienTuVanCode"].ToString());
                        itemAP.Location = row["DiaDiem"].ToString();
                        itemAP.Subject = row["Chung_Tu"].ToString();
                        itemAP.Customer = row["KhachHang"].ToString();
                        itemAP.Services = row["Ten"].ToString();
                        itemAP.Time = row["GioHen"].ToString();
                        string[] gioS= itemAP.Time.Split(',');
                        itemAP.StartDate = Convert.ToDateTime(row["NgayHen"].ToString().Split(' ')[0] + " " + gioS[0]);
                        itemAP.EndDate = Convert.ToDateTime(row["NgayHen"].ToString().Split(' ')[0] + " " + gioS[1]);
                        itemAP.Description = row["GhiChu"].ToString();
                        listAP.Add(itemAP);
                    }
                }
                Appointment apt = null;
                for (int i = 0; i< listAP.Count; i++)
                {
                    apt = schedulerControl1.Storage.CreateAppointment(AppointmentType.Normal);
                    //apt.Subject = listAP[i].Subject;
                    apt.CustomFields["ApptAddInfo"] = "Địa điểm: " +listAP[i].Location;
                    apt.CustomFields["ServiceInfo"] = "DV: " + listAP[i].Services;
                    //apt.Location = listAP[i].Location;
                    apt.Start = listAP[i].StartDate;
                    apt.CustomFields["TimeInfo"] = "Thời gian: "+listAP[i].Time;
                    apt.End = listAP[i].EndDate;
                    apt.Subject ="KH: "+ listAP[i].Customer;
                    apt.ResourceId = listAP[i].ResourceID;
                    
                    schedulerControl1.Storage.Appointments.Add(apt);
                }

            }
            catch (Exception ex)
            {
                SkyConvert.ThongBaoLoiTht(ex.HResult, ex.Message);
            }
            finally
            {
                cnndata.closeConnection();
            }


        }

        private void schedulerControl1_EditAppointmentFormShowing(object sender, AppointmentFormEventArgs e)
        {
            DevExpress.XtraScheduler.SchedulerControl scheduler = ((DevExpress.XtraScheduler.SchedulerControl)(sender));
            Sky.Reports.Forms.CustomAppointmentForm form = new Sky.Reports.Forms.CustomAppointmentForm(scheduler, e.Appointment, e.OpenRecurrenceForm);
            try
            {
                e.DialogResult = form.ShowDialog();
                e.Handled = true;
            }
            finally
            {
                form.Dispose();
            }

        }

        private void schedulerControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
        {
            // Check if it's the default menu of a Scheduler.
            if (e.Menu.Id == SchedulerMenuItemId.AppointmentMenu)
            {
                //e.Menu.DisableMenuItem(SchedulerMenuItemId.EditSeries);
                // Remove unnecessary items.
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.EditSeries);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.StatusSubMenu);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.LabelSubMenu);
                // Find the "New Appointment" menu item and rename it.
                SchedulerMenuItem item = e.Menu.GetMenuItemById(SchedulerMenuItemId.OpenAppointment, false);
                if (item != null) item.Caption = "Đổi lịch";

                // Find the "New All Day Event" menu item and rename it.
                item = e.Menu.GetMenuItemById(SchedulerMenuItemId.DeleteAppointment, false);
                if (item != null) item.Caption = "Hủy lịch hẹn";

                SchedulerMenuItem myMenu = new SchedulerMenuItem("Đã tới", new EventHandler(MyMenuItemClick));
                e.Menu.Items.Add(myMenu);
            } else if ( e.Menu.Id == SchedulerMenuItemId.DefaultMenu)
            {
                // Hide the "Change View To" menu item.
                SchedulerPopupMenu itemChangeViewTo = e.Menu.GetPopupMenuById(SchedulerMenuItemId.SwitchViewMenu);
                itemChangeViewTo.Visible = false;

                // Remove unnecessary items.
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.GotoDate);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.GotoToday);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.GotoDate);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.NewRecurringEvent);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.NewAllDayEvent);
                e.Menu.RemoveMenuItem(SchedulerMenuItemId.NewRecurringAppointment);

                // Find the "New Appointment" menu item and rename it.
                SchedulerMenuItem item = e.Menu.GetMenuItemById(SchedulerMenuItemId.NewAppointment);
                if (item != null) item.Caption = "Thêm lịch hẹn";

            }
        }
        private void MyMenuItemClick(object sender, EventArgs e)
        {
            //MessageBox.Show.(schedulerControl1)
            Appointment apt = sender as Appointment;
            //MessageBox.Show ("hop.nt: " + apt.Description);
            String sql = "update SoLichHen set DaDen = '1' where ";
        }

        private void schedulerControl1_InitAppointmentDisplayText(object sender, AppointmentDisplayTextEventArgs e)
        {
            
            if (e.ViewInfo is VerticalAppointmentViewInfo && e.Appointment.CustomFields["ApptAddInfo"] != null)
            {
                e.Text = e.Appointment.Subject + "\r\n";
                e.Text += "------\r\n";e.Text += e.Appointment.CustomFields["ApptAddInfo"].ToString();
            }
            
            if (e.ViewInfo is VerticalAppointmentViewInfo && e.Appointment.CustomFields["ServiceInfo"] != null)
            {
                e.Text = e.Appointment.Subject + "\r\n";
                e.Text += "------\r\n"; e.Text += e.Appointment.CustomFields["ServiceInfo"].ToString();
            }
            if (e.ViewInfo is VerticalAppointmentViewInfo && e.Appointment.CustomFields["TimeInfo"] != null)
            {
                e.Text = e.Appointment.Subject + "\r\n";
                e.Text += "-----------\r\n"; e.Text += e.Appointment.CustomFields["TimeInfo"].ToString();
            }
        }

        private void schedulerControl1_AllowAppointmentEdit(object sender, AppointmentOperationEventArgs e)
        {
            MessageBox.Show("Custom!!!");
        }

        //public static void scheduler_CustomizeDateNavigationBarCaption(object sender, CustomizeDateNavigationBarCaptionEventArgs e)
        //{
        //    e.Caption = String.Format("Displaying dates from {0:D} to {1:D}", e.Interval.Start.Date, e.Interval.End.Date);
        //}
    }

    public class EFResource
    {
        public int UniqueID { get; set; }
        public long ResourceID { get; set; }
        public string ResourceName { get; set; }
        public int Color { get; set; }
    }
    public class EFAppointment
    {
        public int UniqueID { get; set; }
        public int Type { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public bool AllDay { get; set; }
        public string Subject { get; set; }
        public string Location { get; set; }
        public string Description { get; set; }
        public int Status { get; set; }
        public string Customer { get; set; }
        public string Time { get; set; }
        public string Services { get; set; }
        public long ResourceID { get; set; }
        public string ReminderInfo { get; set; }
        public string RecurrenceInfo { get; set; }
    }
}

Commits for 17001_SKYPRO/trunk/03.Source/SkySolution/Sky.Reports/Forms/frmScheduler.cs

Diff revisions: vs.
Revision Author Commited Message
241 Diff Diff hopnguyenhaui picture hopnguyenhaui Sat 08 Jul, 2017 07:57:03 +0000
240 Diff Diff hopnguyenhaui picture hopnguyenhaui Sat 08 Jul, 2017 03:54:09 +0000
239 Diff Diff hopnguyenhaui picture hopnguyenhaui Sat 08 Jul, 2017 02:04:54 +0000
238 Diff Diff hopnguyenhaui picture hopnguyenhaui Thu 06 Jul, 2017 17:32:45 +0000
237 hopnguyenhaui picture hopnguyenhaui Thu 06 Jul, 2017 17:23:12 +0000

scheduler