private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("OK to delete this information it flights?", "Tips", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (dgridView.CurrentRow.Index > -1) { int nID = (int)dgridView[0, dgridView.CurrentRow.Index].Value; TicketInfo ticket = new TicketInfo(); ticket.Id = nID; if (access.DeleteTicket(ticket)) { MessageBox.Show("Removal Information Success!!!", "Tips", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); LoadData(); } else { MessageBox.Show("Delete information failed!!!", "Tips", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } } else { MessageBox.Show("Please select the information to be deleted!!!", "Tips", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } } }
private void btnAdd_Click(object sender, EventArgs e) { TicketInfo ticket = new TicketInfo(); ticket.FlightNo = this.txtFeightNo.Text.Trim(); ticket.SeatCount = Convert.ToInt32(this.txtSeatCount.Text.Trim()); ticket.LeaveCity = this.txtLeaveCity.Text.Trim(); ticket.Destination = this.txtArriveCity.Text.Trim(); ticket.LeaveTime = Convert.ToDateTime(this.dtpLeaveTime.Text.Trim()); ticket.ArriveTime = Convert.ToDateTime(this.dtpLeaveTime.Text.Trim()); ticket.SecondClass = Convert.ToSingle(this.txtSecondPrice.Text.Trim()); ticket.FirstClass = Convert.ToSingle(this.txtFirstPrice.Text.Trim()); if (access.InsertTicket(ticket)) { MessageBox.Show("Add Success!!!", "Tips", MessageBoxButtons.OK, MessageBoxIcon.Information); main.LoadData(); this.Close(); } else { MessageBox.Show("Add Failed!!!", "Tips", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public DataTable InquireTicket(TicketInfo ticket) { string Sql = "SELECT Id, FlightNO, SeatCount,LeaveCity," + " Destination, LeaveTime,arriveTime, SecondClass" + ", FirstClass FROM TicketInfo Where LeaveCity like '%" + ticket.LeaveCity + "%' and " + "Destination like'%" + ticket.Destination + "%'"; return(GetDataSource(Sql, "Query")); }
private void btnQuery_Click(object sender, EventArgs e) { TicketInfo ticket = new TicketInfo(); ticket.LeaveCity = txtLeaveCity.Text.Trim(); ticket.Destination = txtArriveCity.Text.Trim(); dgridView.DataSource = access.InquireTicket(ticket); }
public bool UpdateTicket(TicketInfo ticket) { string Sql = string.Format("Update TicketInfo Set FlightNO='{0}', LeaveCity='{1}',Destination='{2}',LeaveTime='{3}',arriveTime='{4}',SecondClass={5},FirstClass={6},SeatCount={7} Where Id={8}", ticket.FlightNo, ticket.LeaveCity, ticket.Destination, ticket.LeaveTime, ticket.ArriveTime, ticket.SecondClass, ticket.FirstClass, ticket.SeatCount, ticket.Id); return(ExcuteSql(Sql)); }
public bool InsertTicket(TicketInfo ticket) { string Sql = string.Format("Insert into TicketInfo values('{0}','{1}','{2}','{3}','{4}','{5}',{6},{7})", ticket.FlightNo, ticket.LeaveCity, ticket.Destination, ticket.LeaveTime, ticket.ArriveTime, ticket.SecondClass, ticket.FirstClass, ticket.SeatCount); return(ExcuteSql(Sql)); }
public bool DeleteTicket(TicketInfo ticket) { string Sql = "Delete From TicketInfo Where Id=" + ticket.Id; return(ExcuteSql(Sql)); }