Ejemplo n.º 1
0
 private void AddSessionToList(SessionModel sess)
 {
     ListViewItem res = new ListViewItem(listViewAutocollects.Items.Count.ToString());
     res.SubItems.Add(sess.Name);
     res.SubItems.Add(sess.TimeStart.ToShortTimeString());
     res.SubItems.Add(sess.Days);
     listViewAutocollects.Items.Add(res);
 }
Ejemplo n.º 2
0
        private void buttonAddSesion_Click(object sender, EventArgs e)
        {
            if (dateTimeInput.Value == new DateTime())
            {
                ToastNotification.Show(this, @"Ñhoose a time,please");
                return;
            }
            if (GetDaysStr() == "_______")
            {
                ToastNotification.Show(this, @"Ñhoose a day(s),please");
                return;
            }
            var sess = new SessionModel
            {
                Id = -1,
                Name = textBoxSesionName.Text == "" ? "Untitled session" : textBoxSesionName.Text,
                IsStartYesterday = true,
                Days = GetDaysStr(),
                TimeStart = dateTimeInput.Value,
                TimeEnd = new DateTime(),
            };

            //  ClientDatabaseManager.AddSessionForGroup(_groups.Find(oo => oo.GroupName == group).GroupId, sess);
            if (listBoxGroupName.SelectedItems.Count != 0)
            {
                if (listBoxGroupName.SelectedItems.Count == 1)
                {
                    AddSessionToList(sess);
                }
                for (int index = 0; index < listBoxGroupName.SelectedItems.Count; index++)
                {
                    var group = listBoxGroupName.SelectedItems[index];
                    if (index == 0)
                    {
                        ClientDatabaseManager.AddSessionForGroup(_groups.Find(oo => oo.GroupName == group).GroupId, sess);
                        _sessions = ClientDatabaseManager.GetSessions();
                        continue;
                    }
                    var currSes =
                        _sessions.Find(oo => oo.Name == sess.Name && oo.Days == sess.Days);
                    ClientDatabaseManager.AddSessionForGroup(_groups.Find(oo => oo.GroupName == group).GroupId,
                        currSes.Id);

                }
            }
            else
                ClientDatabaseManager.AddSessionForGroup(-1, sess);
            RefreshClik();
            textBoxSesionName.Text = "";
            dateTimeInput.Value = new DateTime();
            comboBoxAutoCollect.Items.Add(sess.Name + "(" + sess.Days + ")");
            _sessions = ClientDatabaseManager.GetSessions();
        }
Ejemplo n.º 3
0
 void EditListControl_AddSesion(SessionModel sesions)
 {
     AddDay(sesions.TimeStart,sesions.Days);
 }
Ejemplo n.º 4
0
        public static void AddSessionForGroup(int groupId, SessionModel sess)
        {
            var sql = "INSERT INTO " + TblSessions + " (Name, StartTime, EndTime, IsStartYesterday, Days) VALUES (";
            sql += "'" + sess.Name + "',";
            sql += "'" + sess.TimeStart.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture) + "',";
            sql += "'" + sess.TimeEnd.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture) + "',";
            sql += "" + sess.IsStartYesterday + ",";
            sql += "'" + sess.Days + "');COMMIT;";

            DoSql(sql);

            MySqlCommand cmd = _connectionToDb.CreateCommand();
            cmd.CommandText = "SELECT max(ID) FROM " + TblSessions + ";";
            var result = cmd.ExecuteScalar().ToString();
            var id = result == "" ? 0 : uint.Parse(result);

            var sql2 = "INSERT INTO " + TblSessionsForGroups + " (GroupId, SessionId) VALUES (";
            sql2 += groupId + " , " + id + ");COMMIT;";

            DoSql(sql2);
        }
Ejemplo n.º 5
0
 public static List<SessionModel> GetSessionsInGroup(int groupId)
 {
     var symbolsList = new List<SessionModel>();
     var sql = DAQueryBuilder.GetSessionsInGroupSql(groupId);
     var reader = GetReader(sql);
     if (reader != null)
     {
         while (reader.Read())
         {
             var session = new SessionModel
             {
                 Id = reader.GetInt32("Id"),
                 Name = reader.GetString("Name"),
                 IsStartYesterday = reader.GetBoolean("IsStartYesterday"),
                 TimeStart = reader.GetDateTime("StartTime"),
                 TimeEnd = reader.GetDateTime("EndTime"),
                 Days = reader.GetString("Days")
             };
             symbolsList.Add(session);
         }
         reader.Close();
     }
     return symbolsList;
 }
Ejemplo n.º 6
0
 private void OnAddSesion(SessionModel sesions)
 {
     AddSesionHandler handler = AddSesion;
     if (handler != null) handler(sesions);
 }
Ejemplo n.º 7
0
 private void buttonX_add_Click_1(object sender, EventArgs e)
 {
     var sess = new SessionModel
     {
         Id = -1,
         Name = textBoxX_sessionsName.Text==""?"Untitled session":textBoxX_sessionsName.Text,
         IsStartYesterday = checkBox_sy.Checked,
         Days = GetDaysStr(),
         TimeStart = dateTimeInput1.Value,
         TimeEnd = dateTimeInput2.Value,
     };
     //OnAddSesion(sess);
     AddSessionToList(sess);
     ClientDatabaseManager.AddSessionForGroup(AGroupModel.GroupId, sess);
 }
Ejemplo n.º 8
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            var ind = comboBoxEx_existigsSessions.SelectedIndex;
            if (ind == -1)
            {
                ToastNotification.Show(panelEx4, "Please, choose any session.");
                return;
            }

            var sess = new SessionModel
            {
                Id = -1,
                Name = addedSessions[ind].Name,
                IsStartYesterday = addedSessions[ind].IsStartYesterday,
                Days = addedSessions[ind].Days,
                TimeStart = addedSessions[ind].TimeStart,
                TimeEnd = addedSessions[ind].TimeEnd,
            };
            //OnAddSesion(sess);
            AddSessionToList(sess);
            ClientDatabaseManager.AddSessionForGroup(AGroupModel.GroupId, sess);
        }
Ejemplo n.º 9
0
 private void AddSessionToList(SessionModel sess)
 {
     var res = listViewEx_times.Items.Add(listViewEx_times.Items.Count.ToString());
     res.SubItems.Add(sess.Name);
     res.SubItems.Add(sess.TimeStart.ToShortTimeString());
     res.SubItems.Add(sess.Days);
 }