Esempio n. 1
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (txtHoTen.TextLength < 6 || txtHoTen.TextLength > 50)
     {
         MessageBox.Show("Họ tên không được bé hơn 6 và vượt 50 kí tự", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (dtaNgaySinh.Value.Year > 2007)
     {
         MessageBox.Show("Cầu thủ phải trên 12 tuổi", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         string     mact  = ct.nextMa();
         string     mad   = (string)cboDoi.SelectedValue;
         int        soao  = (int)cboSoAo.SelectedValue;
         string     vitri = (string)cboViTri.SelectedValue;
         DTO_CAUTHU dtoct = new DTO_CAUTHU(mact, mad, txtHoTen.Text, dtaNgaySinh.Value, soao, vitri);
         if (ct.addCAUTHU(dtoct))
         {
             MessageBox.Show("Đã thêm thành công cầu thủ", "Chúc mừng", MessageBoxButtons.OK, MessageBoxIcon.Information);
             // refresh combobox
             refresh();
         }
         else
         {
             MessageBox.Show("Thêm thất bại vui lòng thử lại!", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Esempio n. 2
0
 //sua
 public bool upCAUTHU(DTO_CAUTHU d)
 {
     try
     {
         connect.Open();
         string     ngaysinh = String.Format("{0:yyyy/MM/dd}", d.NgaySinh);
         string     sql      = string.Format("UPDATE CAUTHU SET MaDoi='{0}', HoTenCT=N'{1}', NgaySinh='{2}', SoAo={3}, ViTri=N'{4}' WHERE MaCT='{5}'", d.MaDoi, d.HoTenCT, ngaysinh, d.SoAo, d.ViTri, d.MaCT);
         SqlCommand cmd      = new SqlCommand(sql, connect);
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         connect.Close();
     }
     return(false);
 }
Esempio n. 3
0
 //them
 public bool addCAUTHU(DTO_CAUTHU d)
 {
     try
     {
         connect.Open();
         string     ngaysinh = String.Format("{0:yyyy/MM/dd}", d.NgaySinh);
         string     sql      = string.Format("INSERT INTO CAUTHU(MaCT,MaDoi,HoTenCT,NgaySinh,SoAo,ViTri) VALUES ('{0}','{1}',N'{2}','{3}',{4},N'{5}')", d.MaCT, d.MaDoi, d.HoTenCT, ngaysinh, d.SoAo, d.ViTri);
         SqlCommand cmd      = new SqlCommand(sql, connect);
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         //close connect
         connect.Close();
     }
     return(false);
 }
Esempio n. 4
0
 public bool addCAUTHU(DTO_CAUTHU g)
 {
     return(dalCAUTHU.addCAUTHU(g));
 }
Esempio n. 5
0
 public bool upCAUTHU(DTO_CAUTHU g)
 {
     return(dalCAUTHU.upCAUTHU(g));
 }