/// <summary>
        /// ket noi du lieu sql
        /// </summary>
        /// <returns></returns>
        //public static SqlConnection StartConnectToDataBase()
        //{
        //    return ConnectToDataBase.StartConnection();
        //}

        public bool Insert_CauThu(CauThu entity)
        {
            SqlParameter[] pa = new SqlParameter[8];
                        
            string ma = "CT";
            int mact = 0;
            if (string.Compare(entity.Mact, "") != 0)
            {
                mact = int.Parse(entity.Mact.Replace("CT", ""));
            }
            mact++;
            if (mact < 10)
            {
                entity.Mact = ma + "0" + mact;
            }
            else
            {
                entity.Mact = ma + mact;
            }
            pa[0] = new SqlParameter("@mact", entity.Mact);
            pa[1] = new SqlParameter("@madb", entity.Madb);
            pa[2] = new SqlParameter("@hoten_ct", entity.Hotenct);
            pa[3] = new SqlParameter("@gioitinh", entity.Gioitinh);
            pa[4] = new SqlParameter("@ngaysinh", entity.Ngaysinh);
            pa[5] = new SqlParameter("@soao", entity.Soao);
            pa[6] = new SqlParameter("@mavt", entity.Mavt);
            pa[7] = new SqlParameter("@quoctich", entity.Quoctich);
            return SQLProvider.Execute_NonQuery("Insert_CauThu", pa);
        }
        public CauThu GetValueForm()
        {
            CauThu ct = new CauThu();
            if (mode == 1 || mode == 2)
            {
                int ma = dataGridView1.Rows.Count;
                if (ma > 0)
                {
                    ct.Mact = dataGridView1.Rows[ma - 1].Cells[0].Value.ToString();
                }
                else
                {
                    ct.Mact = "";
                }
            }
            else
            {
                ct.Mact = tbmact.Text;
            }
            
            ct.Hotenct = tbhotenct.Text;
            ct.Ngaysinh = datetimeNgaySinh.Value.Date;
            ct.Gioitinh = cbbGioiTinh.Text;
            ct.Mavt = cbbvtri.Text;
            ct.Quoctich = cbbQuocTich.Text;
            ct.Soao = nbsoao.Value.ToString();
            //bi
            CT_MaDB_dataGridView2.DataSource = ql.TimMaDBTheoTen(cbbmadb.Text);
            if (CT_MaDB_dataGridView2[0, 0].Value != null)
                ct.Madb = CT_MaDB_dataGridView2[0, 0].Value.ToString();
            return ct;

        }
 public bool Update_CauThu(CauThu entity)
 {
     SqlParameter[] pa = new SqlParameter[8];
     pa[0] = new SqlParameter("@mact_1", entity.Mact);
     pa[1] = new SqlParameter("@madb_3", entity.Madb);
     pa[2] = new SqlParameter("@hoten_ct_4", entity.Hotenct);
     pa[3] = new SqlParameter("@gioitinh_5", entity.Gioitinh);
     pa[4] = new SqlParameter("@ngaysinh_6", entity.Ngaysinh);
     pa[5] = new SqlParameter("@soao_7", entity.Soao);
     pa[6] = new SqlParameter("@mavt_8", entity.Mavt);
     pa[7] = new SqlParameter("@QuocTich_9", entity.Quoctich);
     //pa[8] = new SqlParameter("@thephat", entity.Thephat);
     //pa[9] = new SqlParameter("@ghiban", entity.Ghiban);
     return SQLProvider.Execute_NonQuery("update_CauThu", pa);
 }
 public bool Delete_CauThu(CauThu entity)
 {
     SqlParameter[] pa = new SqlParameter[1];
     pa[0] = new SqlParameter("@maCt", entity.Mact);
     return SQLProvider.Execute_NonQuery("Delete_CauThu", pa);
 }
 public bool Update_CauThu(CauThu ct)
 {
     return adapter.Update_CauThu(ct);
 }
 public bool Delete_CauThu(CauThu ct)
 {
     return adapter.Delete_CauThu(ct);
 }
 public bool Insert_CauThu(CauThu ct)
 {
     return adapter.Insert_CauThu(ct);
 }
        private void btXoa_Click(object sender, EventArgs e)
        {
            mode = 2;
            int flg = 0;
            foreach (DataGridViewRow item in dataGridView1.SelectedRows)
            {
                CauThu ct = new CauThu();
                ct.Mact = item.Cells[0].Value.ToString();
                if (ql.Delete_CauThu(ct))
                {
                    flg = 1;
                }
                dataGridView1.Rows.RemoveAt(item.Index);
            }

            if (flg == 1)
            {
                MessageBox.Show("Xoá cầu thủ thành công");
                this.ChiTietDanhSachCauThu_Load(sender, e);
            }
            else
            {
                MessageBox.Show("Qúa trình thực hiện thất bại");
            } 
        }