private void mtAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtadd.Text) || String.IsNullOrEmpty(txtstatus.Text) || txttele.Text.Length == 0)
         {
             MessageBox.Show("Please check all the fields are filled");
         }
         else
         {
             try
             {
                 String        name   = txtname.Text;
                 String        add    = txtadd.Text;
                 String        status = txtstatus.Text;
                 String        pw     = txtpw.Text;
                 DBSystemUsers di     = new DBSystemUsers();
                 int           tele   = Convert.ToInt32(txttele.Text);
                 int           line   = di.setSystemUser(u_id, name, add, status, tele, pw);
                 if (line == 1)
                 {
                     MessageBox.Show("Data entered successfully");
                 }
             }
             catch (Exception es)
             {
                 MessageBox.Show(es.ToString());
             }
         }
     }
     catch (Exception)
     {
     }
 }
        private void Form1_Load(object sender, EventArgs e)
        {
            SqlDataAdapter da;
            DBSystemUsers  sys = new DBSystemUsers();

            da = sys.getUser();
            DataTable dt = new DataTable();

            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }
        private void mtUpdate_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Do you want to update?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (dr.ToString() == "Yes")
            {
                if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtadd.Text) || String.IsNullOrEmpty(txtstatus.Text) || txttele.Text.Length != 10)
                {
                    MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }


                else
                {
                    try
                    {
                        String        name   = txtname.Text;
                        String        add    = txtadd.Text;
                        String        status = txtstatus.Text;
                        String        pw     = txtpw.Text;
                        DBSystemUsers di     = new DBSystemUsers();
                        int           tele   = Convert.ToInt32(txttele.Text);
                        int           no     = di.getSysNo(name);
                        int           line   = di.updateSysUser(name, add, status, tele, no, pw);
                        if (line == 1)
                        {
                            MessageBox.Show("Data entered successfully");
                        }
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }
            }
        }