Esempio n. 1
0
 private static void PrepareCommand(SqlCommand command, ZapsanyKurz zapsanyKurz)
 {
     command.Parameters.AddWithValue("@IdRegistrace", zapsanyKurz.IdRegistrace);
     command.Parameters.AddWithValue("@DatumZapisu", zapsanyKurz.DatumZapisu);
     command.Parameters.AddWithValue("@DatumUkonceni", zapsanyKurz.DatumUkonceni == null ? DBNull.Value :
                                     (object)zapsanyKurz.DatumUkonceni);
     command.Parameters.AddWithValue("@Splneno", zapsanyKurz.Splneno == null ? DBNull.Value :
                                     (object)zapsanyKurz.Splneno);
     command.Parameters.AddWithValue("@IdStudent", zapsanyKurz.IdStudent);
     command.Parameters.AddWithValue("@IdKurz", zapsanyKurz.IdKurz);
 }
Esempio n. 2
0
        public static int Update(ZapsanyKurz zapsanyKurz)
        {
            using (var db = new Database())
            {
                db.Connect();

                SqlCommand command = db.CreateCommand(SQL_UPDATE);
                PrepareCommand(command, zapsanyKurz);
                int ret = db.ExecuteNonQuery(command);

                return(ret);
            }
        }
Esempio n. 3
0
        private static Collection <ZapsanyKurz> Read(SqlDataReader reader, bool complete)
        {
            Collection <ZapsanyKurz> zapsaneKurzy = new Collection <ZapsanyKurz>();

            while (reader.Read())
            {
                ZapsanyKurz zapsanyKurz = new ZapsanyKurz();
                int         i           = -1;
                zapsanyKurz.IdRegistrace = reader.GetInt32(++i);
                zapsanyKurz.DatumZapisu  = reader.GetDateTime(++i);

                if (!reader.IsDBNull(++i))
                {
                    zapsanyKurz.DatumUkonceni = reader.GetDateTime(i);
                }

                if (!reader.IsDBNull(++i))
                {
                    zapsanyKurz.Splneno = reader.GetBoolean(i);
                }

                zapsanyKurz.IdStudent = reader.GetInt32(++i);
                zapsanyKurz.IdKurz    = reader.GetInt32(++i);
                if (complete)
                {
                    zapsanyKurz.Student                 = new Student();
                    zapsanyKurz.Kurz                    = new Kurz();
                    zapsanyKurz.Student.IdStudent       = zapsanyKurz.IdStudent;
                    zapsanyKurz.Kurz.IdKurz             = zapsanyKurz.IdKurz;
                    zapsanyKurz.Student.Jmeno           = reader.GetString(++i);
                    zapsanyKurz.Student.Prijmeni        = reader.GetString(++i);
                    zapsanyKurz.Student.Login           = reader.GetString(++i);
                    zapsanyKurz.Student.DatumRegistrace = reader.GetDateTime(++i);
                    zapsanyKurz.Kurz.Nazev              = reader.GetString(++i);
                    zapsanyKurz.Kurz.Popis              = reader.GetString(++i);
                    zapsanyKurz.Kurz.Vytvoren           = reader.GetDateTime(++i);
                    zapsanyKurz.Kurz.IdVyucujici        = reader.GetInt32(++i);
                    zapsanyKurz.Kurz.Kapacita           = reader.GetByte(++i);
                }

                zapsaneKurzy.Add(zapsanyKurz);
            }

            return(zapsaneKurzy);
        }
Esempio n. 4
0
        public static Collection <Pisemka> SelectPastTests(ZapsanyKurz course)
        {
            using (Database db = new Database())
            {
                db.Connect();

                using (SqlCommand command = db.CreateCommand(SQL_PAST_TESTS))
                {
                    command.Parameters.AddWithValue("@IdKurz", course.IdRegistrace);

                    SqlDataReader reader = db.Select(command);

                    Collection <Pisemka> pisemky = Read2(reader, true);

                    return(pisemky);
                }
            }
        }
Esempio n. 5
0
        private void InitMaterials(ZapsanyKurz course)
        {
            LEARNING_MATERIALS_LISTVIEW.Items.Clear();

            Collection <VyukovyMaterial> materials = VyukovyMaterialTable.SelectByCourse(course.IdKurz);

            if (materials != null)
            {
                foreach (var material in materials)
                {
                    ListViewItem i = new ListViewItem(material.IdVyukovyMaterial.ToString());
                    i.SubItems.Add(material.Nazev);
                    i.SubItems.Add(material.Text);
                    i.SubItems.Add(material.Autor.Prijmeni + ", " + material.Autor.Jmeno);

                    LEARNING_MATERIALS_LISTVIEW.Items.Add(i);
                }
            }
        }
Esempio n. 6
0
        private void SIGN_COURSE_BUTTON_Click(object sender, EventArgs e)
        {
            string courseName = AVAIL_COURSES_CB.Text;

            int studentsCount = 0, capacity = 0;

            if (courseName != null && courseName != "")
            {
                ZapsanyKurz zk = new ZapsanyKurz();

                Kurz k = KurzTable.SelectByCourseName(courseName);
                if (k == null)
                {
                    k = KurzTable.SelectLastCourseByName(courseName);
                }

                zk.IdKurz     = k.IdKurz;
                studentsCount = KurzTable.GetStudentsCount(k.IdKurz);
                capacity      = k.Kapacita;

                zk.IdStudent = idStudent;
                ZapsanyKurzTable.Insert(zk);
                if (studentsCount < capacity)
                {
                    InitView();
                }
                else
                {
                    MessageBox.Show("J*z neni misto. Budete zapsan do fronty na tento kurz. " +
                                    "Jakmile se otevre kurz, budete zapsan do kurzu.");
                }
            }
            else
            {
                MessageBox.Show("Vyberte kurz z combo boxu!");
            }
        }