예제 #1
0
파일: Form1.cs 프로젝트: Mitzury/ITMO
        // INSERT NEW
        private void button1_Click(object sender, EventArgs e)
        {
            string addname    = textBox1.Text;
            string addsurname = textBox2.Text;
            string addfname   = textBox3.Text;
            string SqlCom     = "INSERT INTO [dbo].[current_st] VALUES ('" + addname + "', '" + addsurname + "', '" + addfname + "')";

            ConnToSql.SqlQuery(SqlCom);
        }
예제 #2
0
파일: Form1.cs 프로젝트: Mitzury/ITMO
 // DELETE
 private void button3_Click(object sender, EventArgs e)
 {
     if (listBox1.Items.Count != 0 && listBox1.SelectedIndex != -1)
     {
         var ForDel = listBox1.SelectedItem.ToString();
         int ForDelId;
         int.TryParse(string.Join("", ForDel.Where(c => char.IsDigit(c))), out ForDelId);
         string SqlCom = "DELETE FROM [dbo].[current_st] WHERE [id]=" + ForDelId;
         ConnToSql.SqlQuery(SqlCom);
         ConnToSql.Message("Удаление успешно. Обновите базу.");
     }
     else
     {
         ConnToSql.Message("Перед тем как удалить сотрудника, обновите базу и выберите");
     }
 }
예제 #3
0
파일: Form1.cs 프로젝트: Mitzury/ITMO
        // UPDATE
        private void button5_Click(object sender, EventArgs e)
        {
            string name    = textBox1.Text;
            string surname = textBox2.Text;
            string fname   = textBox3.Text;
            string uid     = label1.Text;
            string SqlCom  = "UPDATE[dbo].[current_st] SET[name] = '" + name + "', [surname] = '" + surname + "', [fname] = '" + fname + "' WHERE[id] = " + uid;

            ConnToSql.SqlQuery(SqlCom);
            button1.Enabled    = true;
            label1.Text        = "";
            textBox1.Text      = "Имя";
            textBox1.ForeColor = Color.Gray;
            textBox2.Text      = "Фамилия";
            textBox2.ForeColor = Color.Gray;
            textBox3.Text      = "Отчество";
            textBox3.ForeColor = Color.Gray;
        }