private void button3_Click(object sender, EventArgs e) { string name = tbName.Text, birth = dtpBirth.Value.ToString("yyyy-MM-dd"), tab = textBox3.Text, inn = tbInn.Text, snils = tbSnils.Text, dep = cbDep.SelectedValue.ToString(), post = cbPost.SelectedValue.ToString(), pasp = tbPasp.Text, query = string.Format(@"insert into Employee (name,birth,inn,snils,pasp,post_id,dep_id,tabNumber) values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}');", name, birth, inn, snils, pasp, post, dep, tab); if (!ret) { DBConnect.ExecuteNonQuery(query); } else { query += "SELECT CAST(scope_identity() AS int)"; worker = Convert.ToInt16(DBConnect.ExecuteScalar(query)); } Close(); }