private void btnThem_Click(object sender, EventArgs e)
 {
     if (txtTenMayBay.Text.Trim() != "" && txtSoLuongGhe.Text.Trim() != "")
     {
         try
         {
             dtoMayBay = new DTO_MayBay(txtMaMayBay.Text, txtTenMayBay.Text, Convert.ToInt32(txtSoLuongGhe.Text));
             if (busMayBay.Add(dtoMayBay))
             {
                 MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("Thêm không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception a)
         {
             MessageBox.Show("Thêm không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         finally
         {
             TaoLai();
         }
     }
     else
     {
         MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #2
0
 public bool Update(DTO_MayBay dto)
 {
     try
     {
         _con.Open();
         string     sqlQuery = string.Format("UPDATE MAYBAY SET TENMAYBAY='{0}', SOLUONGGHE='{1}' WHERE MAMAYBAY='{2}'", dto.TenMayBay, dto.SoLuongGhe, dto.MaMayBay);
         SqlCommand cmd      = new SqlCommand(sqlQuery, _con);
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception a)
     {
     }
     finally
     {
         _con.Close();
     }
     return(false);
 }
Beispiel #3
0
 public bool Add(DTO_MayBay dto)
 {
     try
     {
         _con.Open();
         string     maMayBay = TaoMaMayBay();
         string     sqlQuery = string.Format("INSERT INTO MAYBAY(TENMAYBAY, SOLUONGGHE, MAMAYBAY) VALUES('{0}', '{1}', '{2}')", dto.TenMayBay, dto.SoLuongGhe, maMayBay);
         SqlCommand cmd      = new SqlCommand(sqlQuery, _con);
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception a)
     {
     }
     finally
     {
         _con.Close();
     }
     return(false);
 }
Beispiel #4
0
 public bool Update(DTO_MayBay dto)
 {
     return(dal.Update(dto));
 }
Beispiel #5
0
 public bool Add(DTO_MayBay dto)
 {
     return(dal.Add(dto));
 }