private async void send_button_Click_1(object sender, EventArgs e)
        {
            string type_doc   = comboBox1.SelectedItem.ToString();
            int    to_whom_id = to_whom_ids[Convert.ToInt32(comboBox2.SelectedIndex.ToString())];
            int    id_get     = Convert.ToInt32(id.get_idUser());

            preparing_the_script(type_doc, id.get_buffer(), dateTimePicker1.Value.Date.ToString("yyyy-MM-dd"), to_whom_id, id_get);

            string str1 = await Task.Run(() => { return(this.getOutput("C://Users//dessa//AppData//Local//Programs//Python//Python38-32//python.exe", "D://document_flow_in_office_management/MyBD/scripts/read_doc2.py")); });

            MessageBox.Show(str1);



            File.Delete(@"D://document_flow_in_office_management//MyBD//scripts//read_doc2.py");
        }
        private void get_send_docs()
        {
            dataGridView1.Rows.Clear();
            try
            {
                sends.Clear();

                using (SqlConnection cn = getConnection()) {
                    DataTable      table   = new DataTable();
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    SqlCommand     command = new SqlCommand("SELECT [document].[type_doc], (select concat([info].[user_name],' ',[info].[surname])  from [otdel_kadr].[dbo].[info],[otdel_kadr].[dbo].[document]  where [info].[users_id]=[document].[id_to_whom]), [document].[date],[document].[id],[document].[id_to_whom], [document].[users_id] FROM [otdel_kadr].[dbo].[document] where [document].[users_id]=@id", cn);

                    command.Parameters.Add("@id", MySqlDbType.Int32).Value = Convert.ToInt32(idlik.get_idUser());
                    adapter.SelectCommand = command;
                    adapter.Fill(table);
                    var myData = table.Select();
                    for (int i = 0; i < myData.Length; i++)
                    {
                        dataGridView1.Rows.Add(i + 1, myData[i].ItemArray[0].ToString().Trim(), myData[i].ItemArray[1].ToString().Trim(), myData[i].ItemArray[2].ToString().Trim());
                        sends.Add(Convert.ToInt32(myData[i].ItemArray[3].ToString()));
                    }
                }
                //dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                //dataGridView1.RowTemplate.Height = 25;
                //dataGridView1.AllowUserToAddRows = false;
                //dataGridView1.DataSource = table;
            }
            catch (Exception)
            {
                MessageBox.Show("Ошибка при загрузке данных!");
            }
        }
        private void update_d()
        {
            try
            {
                using (SqlConnection cn = getConnection())
                {
                    DataTable      table   = new DataTable();
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    SqlCommand     command = new SqlCommand("SELECT [user_name],  [info].[surname],   [info].[birthday],   [info].[phone],   [info].[email] FROM info where [info].[users_id]=@id", cn);

                    command.Parameters.Add("@id", MySqlDbType.Int32).Value = Convert.ToInt32(id.get_idUser());
                    adapter.SelectCommand = command;
                    adapter.Fill(table);

                    var myData = table.Select();

                    label10.Text = myData[0].ItemArray[0].ToString().Trim();
                    label9.Text  = myData[0].ItemArray[1].ToString().Trim();
                    label8.Text  = myData[0].ItemArray[2].ToString().Trim();
                    label7.Text  = myData[0].ItemArray[3].ToString().Trim();
                    label6.Text  = myData[0].ItemArray[4].ToString().Trim();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ошибка при загрузке данных!");
            }
        }
        private void get_docs()
        {
            dataGridView2.Rows.Clear();
            improves.Clear();
            try
            {
                using (SqlConnection cn = getConnection())
                {
                    System.Data.DataTable table   = new DataTable();
                    SqlDataAdapter        adapter = new SqlDataAdapter();
                    SqlCommand            command = new SqlCommand("SELECT DISTINCT [document].[type_doc], (select concat([info].[user_name], ' ',[info].[surname])  from [info] where [info].[users_id]=[document].[id_to_whom]), [document].[date], [document].[id]  FROM document where [document].[id_to_whom]=@id", cn);

                    command.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(idlik.get_idUser());
                    adapter.SelectCommand = command;
                    adapter.Fill(table);

                    var myData = table.Select();

                    for (int i = 0; i < myData.Length; i++)
                    {
                        dataGridView2.Rows.Add(i + 1, myData[i].ItemArray[0].ToString().Trim(), myData[i].ItemArray[1].ToString().Trim(), myData[i].ItemArray[2].ToString().Trim());
                        improves.Add(Convert.ToInt32(myData[i].ItemArray[3].ToString()));
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ошибка при загрузке данных!");
            }
        }
示例#5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection cn = getConnection())
                {
                    SqlCommand command = new SqlCommand(" UPDATE info SET [user_name] = @user_name, [surname] =  @surname, [birthday] = @birthday, [phone] = @phone, [email] = @email  WHERE [users_id]= @id", cn);
                    command.Parameters.Add("@user_name", SqlDbType.VarChar).Value = name_user.Text;
                    command.Parameters.Add("@surname", SqlDbType.VarChar).Value   = surname_user.Text;
                    command.Parameters.Add("@birthday", SqlDbType.Date).Value     = dateTimePicker1.Value;
                    command.Parameters.Add("@phone", SqlDbType.VarChar).Value     = phone.Text;;
                    command.Parameters.Add("@email", SqlDbType.VarChar).Value     = email.Text;
                    command.Parameters.Add("@id", SqlDbType.Int).Value            = Convert.ToInt32(id.get_idUser());

                    cn.Open();

                    if (command.ExecuteNonQuery() == 1)
                    {
                        MessageBox.Show("Все данные успешно обновлены!!!");
                        this.Hide();
                        Iinfo.Show();
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }