示例#1
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (txtTenSanBay.Text.Trim() != "" && txtTenThanhPho.Text.Trim() != "")
     {
         if (busSanBay.CheckSanBay(txtTenSanBay.Text, txtTenThanhPho.Text))
         {
             MessageBox.Show("Sân bay đã tồn tại, vui lòng nhập lại thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         try
         {
             dtoSanBay = new DTO_SanBay(txtMaSanBay.Text, txtTenSanBay.Text, txtTenThanhPho.Text);
             if (busSanBay.Add(dtoSanBay))
             {
                 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);
     }
 }
示例#2
0
 public bool Update(DTO_SanBay dto)
 {
     try
     {
         _con.Open();
         string     sqlQuery = string.Format("UPDATE SANBAY SET TENSANBAY=N'{0}', TENTHANHPHO=N'{1}' WHERE MASANBAY='{2}'", dto.TenSanBay, dto.TenThanhPho, dto.MaSanBay);
         SqlCommand cmd      = new SqlCommand(sqlQuery, _con);
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception a)
     {
     }
     finally
     {
         _con.Close();
     }
     return(false);
 }
示例#3
0
 public bool Add(DTO_SanBay dto)
 {
     try
     {
         _con.Open();
         string     maSanBay = TaoMaSanBay();
         string     sqlQuery = string.Format("INSERT INTO SANBAY(MASANBAY, TENSANBAY, TENTHANHPHO) VALUES('{0}', N'{1}', N'{2}')", maSanBay, dto.TenSanBay, dto.TenThanhPho);
         SqlCommand cmd      = new SqlCommand(sqlQuery, _con);
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception a)
     {
     }
     finally
     {
         _con.Close();
     }
     return(false);
 }
示例#4
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     if (txtMaSanBay.Text.Trim() != "")
     {
         if (txtTenSanBay.Text.Trim() != "" && txtTenThanhPho.Text.Trim() != "")
         {
             try
             {
                 dtoSanBay = new DTO_SanBay(txtMaSanBay.Text, txtTenSanBay.Text, txtTenThanhPho.Text);
                 if (busSanBay.Update(dtoSanBay))
                 {
                     MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("Sửa không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             catch (Exception a)
             {
                 MessageBox.Show("Sửa 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);
         }
     }
     else
     {
         MessageBox.Show("Vui lòng chọn một hàng trong danh sách!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#5
0
 public bool Update(DTO_SanBay dto)
 {
     return(dal.Update(dto));
 }
示例#6
0
 public bool Add(DTO_SanBay dto)
 {
     return(dal.Add(dto));
 }