示例#1
0
        private void addclg_Click(object sender, EventArgs e)
        {
            this.Hide();
            Addcollege mf = new Addcollege();

            mf.Show();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con;

            con = new SqlConnection(connetionString);
            SqlCommand cmd = new SqlCommand("insert into College(clg_name) values('" + addclgtxt.Text + "')", con);

            cmd.CommandType = CommandType.Text;

            try

            {
                if (addclgtxt.Text == "")
                {
                    MessageBox.Show("Please insert College Name!!!");
                }
                else
                {
                    con.Open();

                    cmd.ExecuteNonQuery();

                    MessageBox.Show("College Name Inserted successfully");

                    this.Hide();
                    Addcollege mf = new Addcollege();
                    mf.Show();
                    con.Close();

                    refress();
                }
            }

            catch (Exception ex)

            {
                MessageBox.Show(ex.Message);
            }
        }
        private void updateclg_Click(object sender, EventArgs e)
        {
            SqlConnection con;

            con = new SqlConnection(connetionString);
            SqlCommand cmd = new SqlCommand("update College set clg_name ='" + selectedclg.Text + "' where clg_name = '" + slct + "' ;", con);

            cmd.CommandType = CommandType.Text;

            try

            {
                if (selectedclg.Text == "")
                {
                    MessageBox.Show("Please Insert College Name!!!");
                }
                else
                {
                    con.Open();

                    cmd.ExecuteNonQuery();

                    MessageBox.Show("College Name Updated successfully");
                    this.Hide();
                    Addcollege mf = new Addcollege();
                    mf.Show();

                    con.Close();
                    selectedclg.Text = " ";
                }
            }

            catch (Exception ex)

            {
                MessageBox.Show(ex.Message);
            }
        }