Exemplo n.º 1
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);
         }
     }
 }
Exemplo n.º 2
0
 //sua
 public bool upDOI(DTO_DOI g)
 {
     try
     {
         connect.Open();
         string     sql = string.Format("UPDATE DOI SET TenDoi=N'{0}', TenHLV=N'{1}', DoiTruong=N'{2}', SoThanhVien={3}, MauAo=N'{4}' WHERE MaDoi='{5}'", g.TenDoi, g.TenHLV, g.DoiTruong, g.SoThanhVien, g.MauAo, g.MaDoi);
         SqlCommand cmd = new SqlCommand(sql, connect);
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         connect.Close();
     }
     return(false);
 }
Exemplo n.º 3
0
 //them
 public bool addDOI(DTO_DOI g)
 {
     try
     {
         connect.Open();
         string     sql = string.Format("INSERT INTO DOI(MaDoi,TenDoi,TenHLV,DoiTruong,SoThanhVien,MauAo) VALUES ('{0}',N'{1}',N'{2}',N'{3}',{4},N'{5}')", g.MaDoi, g.TenDoi, g.TenHLV, g.DoiTruong, g.SoThanhVien, g.MauAo);
         SqlCommand cmd = new SqlCommand(sql, connect);
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         //close connect
         connect.Close();
     }
     return(false);
 }
Exemplo n.º 4
0
 public bool upDOI(DTO_DOI g)
 {
     return(dalDOI.upDOI(g));
 }
Exemplo n.º 5
0
 public bool addDOI(DTO_DOI g)
 {
     return(dalDOI.addDOI(g));
 }