private San GetValueSan()
 {
     San s = new San();
     if (mode == 1 || mode == 2)
     {
         int ma = dataGridView1_san.Rows.Count;
         if (ma > 0)
         {
             s.Masan = dataGridView1_san.Rows[ma - 1].Cells[0].Value.ToString();
         }
         else
         {
             s.Masan = "";
         }
     }
     else
     {
         s.Masan = tbmasan.Text;
     }
     
     s.Tensan = tbtensan.Text;
     s.Diachi = tbdiachi.Text;
     s.Succhua = int.Parse(tbsucchua.Text);
     return s;
 }
        public bool Insert_San(San s)
        {
            SqlParameter[] pa = new SqlParameter[4];
            string ma = "SVD";
            int mas = 0;
            if (string.Compare(s.Masan, "") != 0)
            {
                mas = int.Parse(s.Masan.Replace("SVD", ""));
            }
            mas++;
            if (mas < 10)
            {
                s.Masan = ma + "0" + mas;
            }
            else
            {
                s.Masan = ma + mas;
            }

            pa[0] = new SqlParameter("@masan_1", s.Masan);
            pa[1] = new SqlParameter("@Diachi_2", s.Diachi);
            pa[2] = new SqlParameter("@tenSan_3", s.Tensan);
            pa[3] = new SqlParameter("@succhua_4", s.Succhua);
            return SQLProvider.Execute_NonQuery("insert_SAN_1", pa);            
        }
 public bool Update_San(San s)
 {
     SqlParameter[] pa = new SqlParameter[4];
     pa[0] = new SqlParameter("@masan_2", s.Masan);
     pa[1] = new SqlParameter("@Diachi_3", s.Diachi);
     pa[2] = new SqlParameter("@tenSan_4", s.Tensan);
     pa[3] = new SqlParameter("@succhua_5", s.Succhua);
     return SQLProvider.Execute_NonQuery("update_SAN_1", pa);
 }
        private void XoaSan_Click(object sender, EventArgs e)
        {
            mode = 2;
            int flg = 0;
            foreach (DataGridViewRow item in dataGridView1_san.SelectedRows)
            {
                San s = new San();
                s.Masan = item.Cells[0].Value.ToString();
                if (ql.Delete_San(s))
                {
                    flg = 1;
                }
                dataGridView1_san.Rows.RemoveAt(item.Index);
            }

            if (flg == 1)
            {
                MessageBox.Show("Xoá sân thành công");
                this.LoadSan();
            }
            else
            {
                MessageBox.Show("Qúa trình thực hiện thất bại");
            } 
        }
 public bool Delete_San(San s)
 {
     SanAdapter a = new SanAdapter();
     return a.Delete_San(s);
 }
 public bool Update_San(San s)
 {
     SanAdapter a = SanAdapter.CreatSanAdapter();
     return a.Update_San(s);
 }
 public bool Insert_San(San s)
 {
     SanAdapter a = SanAdapter.CreatSanAdapter();
     return a.Insert_San(s);
 }
 public bool Delete_San(San s)
 {
     SqlParameter[] pa = new SqlParameter[1];
     pa[0] = new SqlParameter("@masan_1", s.Masan);
     return SQLProvider.Execute_NonQuery("delete_San_1", pa);
 }