Beispiel #1
0
 private void btnTao_Click(object sender, EventArgs e)
 {
     if (txtDaiDien.TextLength < 10 || txtDaiDien.TextLength > 50)
     {
         MessageBox.Show("Tên đại diện phải lớn hơn 10 kí tự và nhỏ hơn 50 kí tự", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         //create daidien
         string      madd  = dd.nextMa("MDD");
         DTO_DAIDIEN dtodd = new DTO_DAIDIEN(madd, null, txtDaiDien.Text);
         if (dd.addDAIDIEN(dtodd))
         {
             //create dangky
             string     magiai = (string)cboGiaiDau.SelectedValue;
             string     matk   = BUS_Main.getMaDN();
             DTO_DANGKY dtodk  = new DTO_DANGKY(magiai, madd, dtaNgayDangKy.Value, matk);
             if (dk.addDANGKY(dtodk))
             {
                 MessageBox.Show("Bạn đã hoàn tất đăng ký, vui lòng tạo một đội bóng để có thể tham gia Giải Đấu", "Chúc mừng", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("Tạo thất bại, vui lòng kiểm tra lại thông tin đăng kí", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             MessageBox.Show("Tạo thất bại, vui lòng kiểm tra lại thông tin người đại diện", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Beispiel #2
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     if (txtTenDoi.TextLength < 6 || txtTenDoi.TextLength > 50)
     {
         MessageBox.Show("Tên đội phải lớn hơn 6 và nhỏ hơn 50 kí tự", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtTenDoi.Focus();
     }
     else if (txtTenHLV.TextLength < 6 || txtTenHLV.TextLength > 50)
     {
         MessageBox.Show("Tên HLV phải lớn hơn 6 và nhỏ hơn 50 kí tự", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtTenHLV.Focus();
     }
     else if (txtDoiTruong.TextLength < 6 || txtDoiTruong.TextLength > 50)
     {
         MessageBox.Show("Tên đội trưởng phải lớn hơn 6 và nhỏ hơn 50 kí tự", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtDoiTruong.Focus();
     }
     else
     {
         //create team
         string mad = d.nextMa();
         cboThanhVien.ValueMember = "SoThanhVien";
         int     tv   = (int)cboThanhVien.SelectedValue;
         string  mau  = txtMau.Text;
         DTO_DOI dtod = new DTO_DOI(mad, txtTenDoi.Text, txtTenHLV.Text, txtDoiTruong.Text, tv, mau);
         if (d.addDOI(dtod))
         {
             MessageBox.Show("Tạo đội hoàn tất, bạn có thể thêm cầu thủ vào đội của mình", "Chúc mừng", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //add daidien ma doi
             string madd = (string)cboDaiDien.SelectedValue;
             cboDaiDien.ValueMember = "TenNguoiDD";
             string      nguoi = (string)cboDaiDien.SelectedValue;
             DTO_DAIDIEN dtodd = new DTO_DAIDIEN(madd, mad, nguoi);
             dd.upDAIDIEN(dtodd);
             //refresh
             refresh();
         }
         else
         {
             MessageBox.Show("Tạo đội thất bại, kiểm tra lại thông tin", "Thật tiếc", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
 //xoa
 public bool delDAIDIEN(DTO_DAIDIEN d)
 {
     try
     {
         connect.Open();
         string     sql = string.Format("DELETE FROM DAIDIEN WHERE MaDD='{0}'", d.MaDD);
         SqlCommand cmd = new SqlCommand(sql, connect);
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         connect.Close();
     }
     return(false);
 }
 //them
 public bool addDAIDIEN(DTO_DAIDIEN d)
 {
     try
     {
         connect.Open();
         string     sql = string.Format("INSERT INTO DAIDIEN(MaDD,MaDoi,TenNguoiDD) VALUES ('{0}',NULL,N'{1}')", d.MaDD, d.TenNguoiDD);
         SqlCommand cmd = new SqlCommand(sql, connect);
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         //close connect
         connect.Close();
     }
     return(false);
 }
Beispiel #5
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            cboXoa.ValueMember = "MaDoi";
            //up dd
            DTO_DAIDIEN dtodd = new DTO_DAIDIEN();
            string      mad   = "";
            DataTable   t     = d.getDaiDien((string)cboXoa.SelectedValue);

            if (t.Rows.Count > 0)
            {
                dtodd.MaDD       = t.Rows[0].Field <string>(0);
                mad              = t.Rows[0].Field <string>(1);
                dtodd.MaDoi      = null;
                dtodd.TenNguoiDD = t.Rows[0].Field <string>(2);
                dd.upDAIDIEN(dtodd);
            }
            if (!d.delDOI((string)cboXoa.SelectedValue))
            {
                MessageBox.Show("Xóa thất bại, bạn chỉ được phép xóa những đội vừa mới tạo! Hoặc đội trong giải đã hết hạn", "Thật tiếc", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dtodd.MaDoi = mad;
                dd.upDAIDIEN(dtodd);
            }
            refresh();
        }
 //sua
 public bool upDAIDIEN(DTO_DAIDIEN d)
 {
     try
     {
         connect.Open();
         string     sql = "UPDATE DAIDIEN SET MaDoi=@MAD, TenNguoiDD=@TEN WHERE MaDD=@MADD";
         SqlCommand cmd = new SqlCommand(sql, connect);
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.Add(new SqlParameter("@MADD", d.MaDD));
         cmd.Parameters.Add(new SqlParameter("@MAD", (object)d.MaDoi ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TEN", d.TenNguoiDD));
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         connect.Close();
     }
     return(false);
 }
 public bool delDAIDIEN(DTO_DAIDIEN g)
 {
     return(dalDAIDIEN.delDAIDIEN(g));
 }
 public bool upDAIDIEN(DTO_DAIDIEN g)
 {
     return(dalDAIDIEN.upDAIDIEN(g));
 }
 public bool addDAIDIEN(DTO_DAIDIEN g)
 {
     return(dalDAIDIEN.addDAIDIEN(g));
 }