예제 #1
0
파일: Cources.cs 프로젝트: panterka47/CDO
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            string p = "";

            NewCourse frm = new NewCourse(p);

            frm.BtnAdd.Enabled  = true;
            frm.BtnEdit.Enabled = false;

            frm.Show();
            this.Hide();
        }
예제 #2
0
파일: Cources.cs 프로젝트: panterka47/CDO
        private void BtnEdit_Click(object sender, EventArgs e)
        {
            NewCourse frm = new NewCourse(p);

            //Передача данных о студенте на форму редактирования

            using (SqlConnection connecting = new SqlConnection(Program.connection))
            {
                connecting.Open();


                // Данные из таблицы Курсы

                SqlCommand course = connecting.CreateCommand();
                course.CommandText = "SELECT Course FROM [NewCourse] WHERE ID= " + p;
                course.ExecuteScalar();

                SqlCommand program = connecting.CreateCommand();
                program.CommandText = "SELECT Program FROM [NewCourse] WHERE ID= " + p;
                program.ExecuteScalar();

                SqlCommand type = connecting.CreateCommand();
                type.CommandText = "SELECT Type FROM [NewCourse] WHERE ID= " + p;
                type.ExecuteScalar();

                SqlCommand datestart = connecting.CreateCommand();
                datestart.CommandText = "SELECT DateStart FROM [NewCourse] WHERE ID= " + p;
                datestart.ExecuteScalar();

                SqlCommand dateend = connecting.CreateCommand();
                dateend.CommandText = "SELECT DateEnd FROM [NewCourse] WHERE ID= " + p;
                dateend.ExecuteScalar();

                SqlCommand kolchas = connecting.CreateCommand();
                kolchas.CommandText = "SELECT KolChas FROM [NewCourse] WHERE ID= " + p;
                kolchas.ExecuteScalar();

                SqlCommand smeta = connecting.CreateCommand();
                smeta.CommandText = "SELECT Smeta FROM [NewCourse] WHERE ID= " + p;
                smeta.ExecuteScalar();

                SqlCommand typeobuch = connecting.CreateCommand();
                typeobuch.CommandText = "SELECT TypeObuch FROM [NewCourse] WHERE ID= " + p;
                typeobuch.ExecuteScalar();

                SqlCommand typepractik = connecting.CreateCommand();
                typepractik.CommandText = "SELECT TypePractik FROM [NewCourse] WHERE ID= " + p;
                typepractik.ExecuteScalar();


                //Заполнение полей на форме редактирования данных о курсе
                frm.CbCourse.Text      = Convert.ToString(course.ExecuteScalar());
                frm.CbProgram.Text     = Convert.ToString(program.ExecuteScalar());
                frm.CbTypeProg.Text    = Convert.ToString(type.ExecuteScalar());
                frm.dateStart.Value    = Convert.ToDateTime(datestart.ExecuteScalar());
                frm.dateEnd.Value      = Convert.ToDateTime(dateend.ExecuteScalar());
                frm.TbChas.Text        = Convert.ToString(kolchas.ExecuteScalar());
                frm.TbSmeta.Text       = Convert.ToString(smeta.ExecuteScalar());
                frm.CbTypeObuch.Text   = Convert.ToString(typeobuch.ExecuteScalar());
                frm.CbTypePractik.Text = Convert.ToString(typepractik.ExecuteScalar());

                frm.BtnAdd.Enabled  = false;
                frm.BtnEdit.Enabled = true;


                frm.Show();
                this.Hide();
                connecting.Close();
            }
        }