public bool suaLichChuyenBay(LichChuyenBay lCB) { SqlConnection sqlConnection = createConnection(); try { sqlConnection.Open(); string SQL = "UPDATE LICH_CHUYEN_BAY SET MaSBDi = '" + lCB.MaSBDi + "', MaSBDen = '" + lCB.MaSBDen + "', GiaTien = '" + lCB.GiaTien + "', NgayGio = '" + lCB.NgayGio + "', ThoiGianBay = '" + lCB.ThoiGianBay + "', SoLuongGheHang1 = '" + lCB.SoLuongGheHang1 + "', SoLuongGheHang2 = '" + lCB.SoLuongGheHang2 + "' WHERE MaCB = '" + lCB.MaCB + "'"; SqlCommand cmd = new SqlCommand(SQL, sqlConnection); // Query và kiểm tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { throw e; } finally { // Dong ket noi sqlConnection.Close(); } return(false); }
public bool xoaLichChuyenBay(LichChuyenBay lCB) { SqlConnection sqlConnection = createConnection(); try { sqlConnection.Open(); string SQL = "DELETE LICH_CHUYEN_BAY WHERE MaCB = '" + lCB.MaCB + "'"; SqlCommand cmd = new SqlCommand(SQL, sqlConnection); // Query và kiểm tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { throw e; } finally { // Dong ket noi sqlConnection.Close(); } return(false); }
public bool themLichChuyenBay(LichChuyenBay lCB) { SqlConnection sqlConnection = createConnection(); try { sqlConnection.Open(); //SqlCommand cmd = new SqlCommand("INSERT INTO SAN_BAY(MaSB,TenSB) VALUES ('" + txtMaSB.Text + "',N'" + txtTenSB.Text + "')", con); string SQL = "INSERT INTO LICH_CHUYEN_BAY(MaCB, MaSBDi, MaSBDen, GiaTien, NgayGio, ThoiGianBay, SoLuongGheHang1, SoLuongGheHang2) VALUES ('" + lCB.MaCB + "', '" + lCB.MaSBDi + "', '" + lCB.MaSBDen + "','" + lCB.GiaTien + "','" + lCB.NgayGio + "', '" + lCB.ThoiGianBay + "', '" + lCB.SoLuongGheHang1 + "', '" + lCB.SoLuongGheHang2 + "')"; SqlCommand cmd = new SqlCommand(SQL, sqlConnection); // Query và kiểm tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { throw e; } finally { // Dong ket noi sqlConnection.Close(); } return(false); }
public DataTable GetDataTimKiemCB(LichChuyenBay lCB) { SqlConnection sqlConnection = createConnection(); string sql = "SELECT MaCB, S1.TenSB, S.TenSB, GiaTien, NgayGio, ThoiGianBay, SoLuongGheHang1, SoLuongGheHang2 FROM LICH_CHUYEN_BAY L, SAN_BAY S, SAN_BAY S1 WHERE (L.MaSBDen = S.MaSB AND L.MaSBDi = S1.MaSB) AND (MaCB = '" + lCB.MaCB + "') OR (MaSBDi = '" + lCB.MaSBDi + "' AND MaSBDen = '" + lCB.MaSBDen + "') OR (MaSBDi = '" + lCB.MaSBDi + "') OR (MaSBDen = '" + lCB.MaSBDen + "')"; SqlCommand cmd = new SqlCommand(sql, sqlConnection); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, sqlConnection); DataSet ds = new DataSet(); sqlDataAdapter.Fill(ds); //SqlCommand cmd = new SqlCommand("SELECT * FROM DOIBONG", sqlConnection); //SqlDataAdapter da = new SqlDataAdapter(cmd); //DataSet ds = new DataSet(); //da.Fill(ds); //DGVHienThi.DataSource = ds.Tables[0]; //DGVHienThi.Refresh(); return(ds.Tables[0]); }