Beispiel #1
0
        private void BtnCourseNew_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection connecting = new SqlConnection(Program.connection))
                {
                    connecting.Open();
                    SqlCommand cmd = connecting.CreateCommand();

                    //Добавление документа
                    cmd.CommandText = "INSERT INTO [Documents] (TypeDoc, [Group], IdStudent, StatusDoc, Utrata, Obmen, Unichtog, SeriesDoc, NumberDoc, RegNumber, DateIssued) VALUES ('" + Convert.ToString(CbTypeDoc.Text) + "', '" + Convert.ToString(CbGroup.Text) + "','" + Convert.ToInt32(TbStudent.Text) + "','" + CbStatusDoc.Text + "', '" + CbUtrata.Text + "','" + CbObmen.Text + "', '" + CbUnichtog.Text + "', '" + TbSeriesDoc.Text + "', '" + Convert.ToInt32(TbNumberDoc.Text) + "', '" + Convert.ToInt32(TbRegNumber.Text) + "', '" + Convert.ToDateTime(dateTimedateissued.Value).ToShortDateString() + "')";
                    cmd.ExecuteScalar();

                    MessageBox.Show("Документ добавлен");

                    Documents ifrm = new Documents();
                    ifrm.Show();
                    this.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Возникла ошибка: " + ex);
            }
        }
Beispiel #2
0
        private void BtnEditDoc_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection connecting = new SqlConnection(Program.connection))
                {
                    connecting.Open();


                    SqlCommand cmd = connecting.CreateCommand();

                    //Изменение данных о слушателе
                    SqlCommand WriteCommand;
                    WriteCommand = new SqlCommand("UPDATE [Documents] SET TypeDoc = @typedoc, [Group] = @group, IdStudent=@idstudent, StatusDoc=@statusdoc, Utrata = @utrata, Obmen = @obmen, Unichtog = @unichtog, SeriesDoc= @seriesdoc, NumberDoc = @numberdoc, RegNumber = @regnumber  WHERE ID = @ID", connecting);

                    WriteCommand.Parameters.AddWithValue("typedoc", CbTypeDoc.Text);
                    WriteCommand.Parameters.AddWithValue("group", CbGroup.Text);
                    WriteCommand.Parameters.AddWithValue("idstudent", TbStudent.Text);
                    WriteCommand.Parameters.AddWithValue("statusdoc", CbStatusDoc.Text);
                    WriteCommand.Parameters.AddWithValue("utrata", CbUtrata.Text);
                    WriteCommand.Parameters.AddWithValue("obmen", CbObmen.Text);
                    WriteCommand.Parameters.AddWithValue("unichtog", CbUnichtog.Text);
                    WriteCommand.Parameters.AddWithValue("seriesdoc", TbSeriesDoc.Text);
                    WriteCommand.Parameters.AddWithValue("numberdoc", Convert.ToInt32(TbNumberDoc.Text));
                    WriteCommand.Parameters.AddWithValue("regnumber", Convert.ToInt32(TbRegNumber.Text));
                    WriteCommand.Parameters.AddWithValue("ID", Convert.ToInt32(id));
                    WriteCommand.ExecuteNonQuery();

                    MessageBox.Show("Данные о документе изменены");
                    connecting.Close();
                }
                Documents ifrm = new Documents();
                ifrm.Show();
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex.Message));
            }
        }
Beispiel #3
0
 private void button2_Click_1(object sender, EventArgs e)
 {
     Forms.Documents frm = new Forms.Documents();
     frm.Show();
     this.Hide();
 }