Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                this.Hide();
                con.Open();
                SqlCommand cmd = new SqlCommand("spInsertdoc", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@doctor_name", SqlDbType.VarChar).Value           = textBox1.Text.Trim();
                cmd.Parameters.AddWithValue("@doctor_specialization", SqlDbType.VarChar).Value = textBox2.Text.Trim();
                cmd.Parameters.AddWithValue("@doctor_salary", SqlDbType.BigInt).Value          = textBox3.Text.Trim();
                cmd.Parameters.AddWithValue("@doctor_age", SqlDbType.Int).Value                = textBox4.Text.Trim();
                cmd.Parameters.AddWithValue("@doctor_contact", SqlDbType.NVarChar).Value       = maskedTextBox1.Text.Trim();
                cmd.Parameters.AddWithValue("@doctor_qualification", SqlDbType.NVarChar).Value = textBox6.Text.Trim();
                cmd.Parameters.AddWithValue("@department_id", SqlDbType.Int).Value             = textBox7.Text.Trim();
                cmd.Parameters.AddWithValue("@doctor_gender", SqlDbType.VarChar).Value         = comboBox1.Text.Trim();

                cmd.ExecuteNonQuery();
                con.Close();
                Doctors doctors = new Doctors();
                doctors.Show();
                MessageBox.Show("Doctor has been inserted");

                Doctors2 doc2 = new Doctors2();
            }

            catch
            {
                MessageBox.Show("you entered some wrong values");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            Doctors2 doc2 = new Doctors2();

            doc2.Show();
        }