コード例 #1
0
        private void Button4_Click(object sender, EventArgs e)
        {
            student_details gg = new student_details();

            gg.Show();
            //this.Hide();
        }
コード例 #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            int val = 0;

            Int32.TryParse(textBox9.Text, out val);

            if (val >= 10 || val <= 0)
            {
                DialogResult result = MessageBox.Show("Please enter a valid Faculty ID", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (result == DialogResult.OK)
                {
                    student_details gg = new student_details();
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                SqlConnection conn = new SqlConnection(@"Server=DESKTOP-TP8ATKN;Database=myschool;Trusted_Connection=Yes");
                using (SqlCommand cmd = new SqlCommand("select * from faculty where idfaculty='" + textBox9.Text.Trim() + "'"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = conn;
                    conn.Open();
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                    {
                        sdr.Read();
                        textBox1.Text = sdr["FirstName"].ToString();
                        textBox5.Text = sdr["LastName"].ToString();
                        textBox2.Text = sdr["Salary"].ToString();
                        textBox6.Text = sdr["Qualification"].ToString();
                        textBox8.Text = sdr["EmergencyContact"].ToString();
                        textBox4.Text = sdr["ContactNumber"].ToString();
                        textBox3.Text = sdr["Gender"].ToString();
                        textBox7.Text = sdr["Address"].ToString();
                    }
                    conn.Close();
                }
            }
        }