public bool xoaBanVeCB(BanVe bV) { SqlConnection sqlConnection = createConnection(); try { sqlConnection.Open(); string SQL = "DELETE VE_CHUYEN_BAY WHERE MaVeCB = '" + bV.MaVeCB + "'"; 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 themBanVeCB(BanVe bV) { 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 VE_CHUYEN_BAY(MaVeCB, MaCB, MaHK, MaHV, GiaTien) VALUES ('" + bV.MaVeCB + "','" + bV.MaCB + "', '" + bV.MaHK + "', '" + bV.MaHV + "', '" + bV.GiaTien + "')"; 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 GetDataTimKiemVeCB(BanVe bV) { SqlConnection sqlConnection = createConnection(); string sql = "SELECT MaVeCB, MaCB, MaHK, MaHV, GiaTien FROM VE_CHUYEN_BAY WHERE (MaVeCB = '" + bV.MaVeCB + "') OR (MaHK = '" + bV.MaHK + "')"; 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]); }