public void LoadUI(Event e) { if (e != null) { this.UILoop.IsChecked = e.loop; this.UITimeBegin.curDate = e.Begin; this.UITimeEnd.curDate = e.End; this.UITitle.Text = "Sửa lịch chiếu"; MTC_Server.Code.User.UserData tmpUser = e.User; this.UIUser.SelectedItem = new DataAutoComplete() { key = tmpUser.ID.ToString(), label = tmpUser.Full_Name }; MTC_Server.Code.Device.DeviceData tmpDevice = e.Device; this.UIDevice.SelectedItem = new DataAutoComplete() { key = tmpDevice.ID.ToString(), label = tmpDevice.IP }; this.UIComment.Text = e.Content; } else { this.UILoop.IsChecked = false; this.UITitle.Text = "Thêm lịch chiếu"; this.UIComment.Text = string.Empty; this.UIUser.SelectedItem = null; if (this.ParentEvent == null) this.UIDevice.SelectedItem = null; this.UITimeBegin.curDate = DateTime.Now; this.UITimeEnd.curDate = DateTime.Now.AddMinutes(1); } }
void UICalendar_LinkEvent(object sender, Event e) { if (e != null) { UIViewPlaylist.Event = e; UIViewPlaylist.showViewInput(); } }
void UICalendar_SelectEvent(object sender, Event e) { if (e != null) { UIViewPlaylist.Event = e; UIViewPlaylist.showPlaylist(); } }
void UICalendar_EditChildEvent(object sender, Event e) { if (e != null) { UIAddEvent UI = new UIAddEvent(); UI.Width = 1366; UI.Height = 668; UI.setLeft(0); UI.setTop(0); UI.CloseEvent += CloseAddEvent; UI.Event = e; this.UIRoot.Children.Add(UI); } }
private void SaveButtonClick(object sender, MouseButtonEventArgs e) { if(!App.curUser.Permision.mana_schedule) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = "* Bạn không có quyền thực hiện chức năng này!"; return; } if (this.UITimeEnd <= this.UITimeBegin) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = "* Thời gian bắt đầu phải nhỏ hơn thời gian kết thúc"; return; } if (this.UIComment.isEmpty()) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = "* Tên lịch chiếu không được để trống"; return; } if (this.UIUser.SelectedItem == null) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = "* Hãy nhập tên User bạn muốn đặt lịch"; return; } if (this.UIDevice.SelectedItem == null) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = "* Hãy nhập IP thiết bị bạn muốn đặt lịch"; return; } #region Validate Event tmp = new Event(); tmp.Content = this.UIComment.Text; tmp.Begin = UITimeBegin.Time; tmp.End = UITimeEnd.Time; tmp.device_id = Convert.ToInt32(this.UIDevice.SelectedItem.key); tmp.parent_id = (this.ParentEvent == null) ? 0 : this.ParentEvent.Id; tmp.user_id = Convert.ToInt32(this.UIUser.SelectedItem.key); tmp.loop = this.UILoop.IsChecked.Value; if (this.ParentEvent != null) { if (this.ParentEvent.loop && tmp.loop) { if (this.ParentEvent.Begin.TimeOfDay > tmp.Begin.TimeOfDay) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Thời gian bắt đầu phải lớn hơn {0:HH:mm:ss}", this.ParentEvent.Begin); return; } else if (this.ParentEvent.End.TimeOfDay < tmp.End.TimeOfDay) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Thời gian kết thúc phải nhỏ hơn {0:HH:mm:ss}", this.ParentEvent.End); return; } } else if (this.ParentEvent.loop && !tmp.loop) { if (tmp.Begin.Date != tmp.End.Date) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Ngày bắt đầu phải bằng ngày kết thúc"); return; } else if (this.ParentEvent.Begin.TimeOfDay > tmp.Begin.TimeOfDay) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Thời gian bắt đầu phải lớn hơn {0:HH:mm:ss} {1:dd/MM/yyyy}", this.ParentEvent.Begin, tmp.Begin); return; } else if (this.ParentEvent.End.TimeOfDay < tmp.End.TimeOfDay) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Thời gian kết thúc phải nhỏ hơn {0:HH:mm:ss} {1:dd/MM/yyyy}", this.ParentEvent.End, tmp.Begin); return; } } else if (!this.ParentEvent.loop && tmp.loop) { if (this.ParentEvent.Begin.Date == this.ParentEvent.End.Date && this.ParentEvent.Begin.TimeOfDay > tmp.Begin.TimeOfDay) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Thời gian bắt đầu phải lớn hơn {0:HH:mm:ss}", this.ParentEvent.Begin); return; } else if (this.ParentEvent.Begin.Date == this.ParentEvent.End.Date && this.ParentEvent.End.TimeOfDay < tmp.End.TimeOfDay) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Thời gian kết thúc phải nhỏ hơn {0:HH:mm:ss}", this.ParentEvent.End); return; } } else { if (this.ParentEvent.Begin > tmp.Begin) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Thời gian bắt đầu phải lớn hơn {0:HH:mm:ss dd/MM/yyyy}", this.ParentEvent.Begin); return; } else if (this.ParentEvent.End < tmp.End) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Thời gian kết thúc phải nhỏ hơn {0:HH:mm:ss dd/MM/yyyy}", this.ParentEvent.End); return; } } } this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 38, 400); UIErr.Animation_Opacity_View_Frame(false, null, 300); UIErr.Text = string.Empty; #endregion if (this.e == null) { #region Insert Event int result = Event.Insert(tmp); if (result != 1) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Không thể thêm lịch phát vào khoảng thời gian này."); return; } else { if (this.CloseEvent != null) { this.CloseEvent(this, new CloseUIEventData() { Data = tmp }); } } #endregion Insert Event } else { #region Edit Event tmp.Id = this.e.Id; tmp.parent_id = this.e.parent_id; int result = tmp.Save(); if (result != 1) { this.UIContent.Animation_Translate_Frame(double.NaN, double.NaN, double.NaN, 67, 500); UIErr.Animation_Opacity_View_Frame(true, null, 550); UIErr.Text = string.Format("* Không thể thêm lịch phát vào khoảng thời gian này."); return; } else { if (this.CloseEvent != null) { this.CloseEvent(this, new CloseUIEventData() { Data = tmp }); } } #endregion Edit Event } }
void UIE_EditEvent(object sender, Event e) { if (e != null) { if (EditChildEvent != null) { EditChildEvent(this, e); } } }
void UIE_AddChildEvent(object sender, Event e) { if (e != null) { if (AddChildEvent != null) { AddChildEvent(this, e); } } }
void UIE_SelectEvent(object sender, Event e) { if (e != null && SelectEvent!=null) { SelectEvent(this, e); } }
private void UIE_LinkEvent(object sender, Event e) { if (e != null && LinkEvent != null) { LinkEvent(this, e); } }
public static int Insert(Event e) { int result = 0; try { using (MySqlConnection conn = new MySqlConnection(App.setting.connectString)) { conn.Open(); string query = "`p_insert_schedule_device`"; using (MySqlCommand cmd = new MySqlCommand(query, conn)) { cmd.Parameters.Add(new MySqlParameter("@_device", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Input, Value = e.device_id }); cmd.Parameters.Add(new MySqlParameter("@_user", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Input, Value = e.user_id }); cmd.Parameters.Add(new MySqlParameter("@_parent", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Input, Value = e.parent_id }); cmd.Parameters.Add(new MySqlParameter("@_time_begin", MySqlDbType.DateTime) { Direction = System.Data.ParameterDirection.Input, Value = e.Begin }); cmd.Parameters.Add(new MySqlParameter("@_time_end", MySqlDbType.DateTime) { Direction = System.Data.ParameterDirection.Input, Value = e.End }); cmd.Parameters.Add(new MySqlParameter("@_loop", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Input, Value = e.loop }); cmd.Parameters.Add(new MySqlParameter("@_comment", MySqlDbType.VarChar, 100) { Direction = System.Data.ParameterDirection.Input, Value = e.Content }); cmd.Parameters.Add(new MySqlParameter("@result", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Output, Value = 0 }); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.ExecuteScalar(); result = Convert.ToInt32(cmd.Parameters["@result"].Value); }; conn.Close(); }; } catch (Exception ex) { Console.WriteLine(ex.GetBaseException().ToString()); } return result; }
public static void delete(Event e) { try { using (MySqlConnection conn = new MySqlConnection(App.setting.connectString)) { conn.Open(); string query = "`p_delete_schedule`"; using (MySqlCommand cmd = new MySqlCommand(query, conn)) { cmd.Parameters.Add(new MySqlParameter("@_s_id", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Input, Value = e.Id }); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.ExecuteScalar(); }; conn.Close(); }; } catch (Exception) { } }
public bool Add(ref Event E) { if (this.Mode == ModeGroup.None) { this.Events.Add(E); E.Left = this.Left; E.Width = this.Width; return true; } if (E.Id == 7) { Console.Write(E.Id); } if (this.Mode == ModeGroup.Vertical) { bool canAdd = true; foreach (Event e in this.Events) { double h = 0; int min = (e.BeginIndex <= E.BeginIndex) ? e.BeginIndex : E.BeginIndex; int max = (e.BeginIndex <= E.BeginIndex) ? E.BeginIndex : e.BeginIndex; for (int i = min; i < max; i++) { bool isEx = false; foreach (int j in ExpansionIndex) { if (i == j) { isEx = true; break; } } if (isEx) h += 120; else h += 60; } if (e.BeginIndex < E.BeginIndex || (e.BeginIndex == E.BeginIndex && e.Top <= E.Top)) { h -= e.Top; h += E.Top; if (e.Height >= h) { canAdd = false; break; } } else { h += e.Top; h -= E.Top; if (E.Height >= h) { canAdd = false; break; } } } if (canAdd) { this.Events.Add(E); E.Left = this.Left; E.Width = this.Width; return true; } } return false; }