Example #1
0
        public static void MembersDataDownload()
        {
            members.Clear();

            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(SQLData.MembersDownload, connection);

                    connection.Open();

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        members.Add(new Member(Convert.ToInt32(reader[0]), reader[1].ToString(), Convert.ToInt32(reader[2])));
                    }
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }
        }
Example #2
0
        public static void ScheduleInsert(DateTime timeOfLessons, int instructor, string students, int curriculum)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(SQLData.ScheduleInsert, connection);

                    command.Parameters.Add("@TimeOfLesson", SqlDbType.DateTime);
                    command.Parameters["@TimeOfLesson"].Value = timeOfLessons;

                    command.Parameters.Add("@Instructor", SqlDbType.Int);
                    command.Parameters["@Instructor"].Value = instructor;

                    command.Parameters.Add("@Students", SqlDbType.VarChar);
                    command.Parameters["@Students"].Value = students;

                    command.Parameters.Add("@Curriculum", SqlDbType.Int);
                    command.Parameters["@Curriculum"].Value = curriculum;

                    connection.Open();

                    command.ExecuteNonQuery();
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }
        }
Example #3
0
        public static void MemberDataUpload()
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(SQLData.MembersUpload, connection);

                    connection.Open();

                    command.Parameters.Add("@MemberName", SqlDbType.VarChar);
                    command.Parameters.Add("@Master", SqlDbType.Bit);

                    for (int i = 0; i < members.Count; i++)
                    {
                        command.Parameters["@MemberName"].Value = members[i].MemberName;
                        command.Parameters["@Master"].Value     = members[i].Master;

                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }
        }
Example #4
0
        public static void ScheduleUpdate(int scheduleID, DateTime modifiedTimeOfLesson, int modifiedInstructor, int modifiedCurriculum)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(SQLData.ScheduleUpdate, connection);

                    command.Parameters.Add("@ScheduleID", SqlDbType.Int);
                    command.Parameters["@ScheduleID"].Value = scheduleID;

                    command.Parameters.Add("@TimeOfLesson", SqlDbType.DateTime);
                    command.Parameters["@TimeOfLesson"].Value = modifiedTimeOfLesson;

                    command.Parameters.Add("@Instructor", SqlDbType.Int);
                    command.Parameters["@Instructor"].Value = modifiedInstructor;

                    command.Parameters.Add("@Curriculum", SqlDbType.Int);
                    command.Parameters["@Curriculum"].Value = modifiedCurriculum;

                    connection.Open();

                    command.ExecuteNonQuery();
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }
        }
Example #5
0
        public static List <DateTime> LessonsTimeOfSelectedTeacher(int selectedMeberId)
        {
            List <DateTime> timeOfLessons = new List <DateTime>();

            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(SQLData.LessonsOfSelectedTeacher, connection);

                    command.Parameters.AddWithValue("@MemberID", selectedMeberId);

                    connection.Open();

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        timeOfLessons.Add(Convert.ToDateTime(reader[0]));
                    }
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }

            return(timeOfLessons);
        }
Example #6
0
        public static List <Schedule> SchedulesDownload()
        {
            List <Schedule> lessons = new List <Schedule>();

            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(SQLData.ScheduleDownload, connection);

                    connection.Open();

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        lessons.Add(new Schedule(Convert.ToInt32(reader[0]), Convert.ToDateTime(reader[1]), Convert.ToInt32(reader[2]), reader[3].ToString(), Convert.ToInt32(reader[4])));
                    }
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }
            return(lessons);
        }
Example #7
0
        public static int TableCount(int table)
        {
            int result = -1;

            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(table == 1 ? SQLData.DatabaseTablePosesCount : SQLData.DatabaseTableMembersCount, connection);

                    connection.Open();

                    SqlDataReader reader = command.ExecuteReader();

                    reader.Read();

                    result = Convert.ToInt32(reader[0]);
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }

            return(result);
        }
Example #8
0
        public static bool TableIsEmpty(int table)
        {
            object checkresult = null;

            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(table == 1 ? SQLData.DatabaseTablePosesCheck : SQLData.DatabaseTableMembersCheck, connection);

                    connection.Open();

                    checkresult = command.ExecuteScalar();
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }

            return(checkresult == null);
        }
Example #9
0
        public static bool DatabaseCheck()
        {
            object checkResult = null;

            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(SQLData.DatabaseCheck, connection);

                    connection.Open();

                    checkResult = command.ExecuteScalar();
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }

            return(checkResult != null);
        }
Example #10
0
        public static void ScheduleDelete(int selectedSceduleID)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(SQLData.ConncectionString))
                {
                    SqlCommand command = new SqlCommand(SQLData.ScheduleDelete, connection);

                    command.Parameters.Add("@ScheduleID", SqlDbType.Int);
                    command.Parameters["@ScheduleID"].Value = selectedSceduleID;

                    connection.Open();

                    command.ExecuteNonQuery();
                }
            }
            catch (Exception a)
            {
                if (CEPrintout != null)
                {
                    CEPrintout.Invoke(a.Message);
                }
            }
        }