Ejemplo n.º 1
0
        private void set_Click(object sender, EventArgs e) // Нажата кнопка создать
        {
            bd.Open();
            //проверка что всё гуд создаем записи
            if ((!string.IsNullOrEmpty(komnata.Text) && !string.IsNullOrWhiteSpace(komnata.Text) && Convert.ToInt32(komnata.Value) != 0) &&
                (!string.IsNullOrEmpty(organization.Text) && !string.IsNullOrWhiteSpace(organization.Text)) &&
                (!string.IsNullOrEmpty(organization.Text) && !string.IsNullOrWhiteSpace(specialty.Text)))
            {
                if (error.Visible) // проверка что не указана ошибка
                {
                    error.Visible = false;
                }
                // --------- определения Id
                int id_org     = check_id(" organization ", organization.Text, bd);
                int id_spesial = check_id(" specialty ", specialty.Text, bd);
                Set_Man(id_org, id_spesial);
                Set_Time();
                DateTime date = DateTime.Today;

                // Создание записей какой инвентарь был взят
                for (int i = 0; i < invent.Rows.Count; i++)
                {
                    object invent_row       = invent[2, i].Value;
                    int    invent_row_kolvo = Convert.ToInt32(invent_row);
                    if (invent_row_kolvo != 0)
                    {
                        SqlCommand inset_invent = new SqlCommand("INSERT INTO [rent] (id_klient,id_inventory,kolbo_taken,kolbo_give_away,check_dolg,data) VALUES (@id_klient,@id_inventory,@kolbo_taken,0,@check_dolg,@data)", bd);
                        inset_invent.Parameters.AddWithValue("id_klient", id_new_man);
                        inset_invent.Parameters.AddWithValue("id_inventory", Convert.ToInt32(invent[0, i].Value));
                        inset_invent.Parameters.AddWithValue("kolbo_taken", Convert.ToInt32(invent[2, i].Value));
                        inset_invent.Parameters.AddWithValue("data", date);
                        inset_invent.Parameters.AddWithValue("check_dolg", 1);
                        inset_invent.ExecuteNonQuery();
                    }
                }
                this.Hide();
                get_mans get_mans = new get_mans();
                get_mans.Show();
                bd.Close();
            }
            // Создание не удалось
            else
            {
                error.Text = "Вы не указали";
                if (komnata.Value == 0)
                {
                    error.Text += " комнату";
                }
                if (string.IsNullOrEmpty(organization.Text) || string.IsNullOrWhiteSpace(organization.Text))
                {
                    error.Text += " организацию";
                }
                if (string.IsNullOrEmpty(specialty.Text) || string.IsNullOrWhiteSpace(specialty.Text))
                {
                    error.Text += " специальность";
                }
                error.Visible = true;
                bd.Close();
            }
        }
Ejemplo n.º 2
0
        private void назадToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
            bd.Close();
            get_mans get_mans = new get_mans();

            get_mans.Show();
        }
Ejemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e) // нажата назад
        {
            bd.Close();
            this.Hide();
            get_mans get_mans = new get_mans();

            get_mans.Show();
        }
Ejemplo n.º 4
0
        private void списокКлиентовToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            bd.Close();
            get_mans get_mans = new get_mans();

            get_mans.Show();
        }
Ejemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e) // нажата кнопка отмена создания человека
        {
            //Thread.Sleep(2000);
            this.Hide();
            get_mans get_mans = new get_mans();

            get_mans.Show();
        }
Ejemplo n.º 6
0
 private async void button1_Click(object sender, EventArgs e) // изменить запись клиента
 {
     if (!string.IsNullOrEmpty(organization.Text) && !string.IsNullOrWhiteSpace(organization.Text) &&
         (!string.IsNullOrEmpty(organization.Text)))
     {
         foreach (KeyValuePair <string, string> keyValue in assocArray)
         {
             if (keyValue.Key == "specialty" || keyValue.Key == "organization")
             {
                 int Id_check;
                 if (keyValue.Key == "specialty")
                 {
                     string a = keyValue.Key.ToString();
                     string b = keyValue.Value.ToString();
                     Id_check = set_man.check_id(a, b, bd);
                 }
                 else
                 {
                     Id_check = set_man.check_id(keyValue.Key, keyValue.Value, bd);
                 }
                 var        sqlString = string.Format("UPDATE Man SET id_{0} = @val WHERE Id=@ID", keyValue.Key);
                 SqlCommand update_w  = new SqlCommand(sqlString, bd);
                 update_w.Parameters.AddWithValue("ID", id_man);
                 update_w.Parameters.AddWithValue("val", Id_check);
                 await update_w.ExecuteNonQueryAsync();
             }
             else
             {
                 var        sqlString = string.Format("UPDATE Man SET {0} = @val WHERE Id=@ID", keyValue.Key);
                 SqlCommand update    = new SqlCommand(sqlString, bd);
                 update.Parameters.AddWithValue("ID", id_man);
                 update.Parameters.AddWithValue("val", keyValue.Value);
                 await update.ExecuteNonQueryAsync();
             }
         }
         bd.Close();
         this.Hide();
         get_mans get_mans = new get_mans();
         get_mans.Show();
     }
     else
     {
         MessageBox.Show("Организация и специальность и даты не могут быть пустыми");
     }
 }
Ejemplo n.º 7
0
        private async void problit_Click(object sender, EventArgs e) // прописать клиента
        {
            if (kom.Value != 0)
            {
                DateTime   date1 = DateTime.Today;
                DateTime   date2 = DateTime.Today.AddMonths(1);
                SqlCommand Inset = new SqlCommand("INSERT INTO [time_klient] (id_klient, date_of_arrival ,date_of_withdrawal,komnata) VALUES (@id_klient,@date_of_arrival,@date_of_withdrawal,@komnata)", bd);
                Inset.Parameters.AddWithValue("id_klient", id_man);
                Inset.Parameters.AddWithValue("date_of_arrival", date1);
                Inset.Parameters.AddWithValue("date_of_withdrawal", date2);
                Inset.Parameters.AddWithValue("komnata", kom.Text);
                await Inset.ExecuteNonQueryAsync();

                get_mans get_mans = new get_mans();
                bd.Close();
                get_mans.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Вы не указали комнату");
            }
        }