//visszateriti a berlesek listajat public List<Loan> GetLoanList(string makerFilter, string categoryFilter) { string query = "SELECT * FROM Berlesek"; string error = string.Empty; SqlDataReader rdr = dal.ExecuteReader(query, ref error); List<Loan> loanList = new List<Loan>(); if (error == "OK") { while (rdr.Read()) { Loan v = new Loan(); v.LoanID = Convert.ToInt32(rdr[0]); v.VehicleID = Convert.ToInt32(rdr[1]); v.LoanerID = Convert.ToInt32(rdr[2]); v.LoanStart = rdr[3].ToString(); v.LoanEnd = rdr[4].ToString(); v.Cost = Convert.ToInt32(rdr[5]); loanList.Add(v); } } dal.CloseDataReader(rdr); return loanList; }
//hozzaadja az adott autot a kivalasztott datumok kozott a berlesi listahoz //ha az mar foglalt valamely napokon a kivalasztott datumok kozott, akkor figyelmezteti a felhasznalot private void btnLoanListAdd_Click(object sender, EventArgs e) { Loan l = new Loan(); l.LoanStart = dtpLoanStart.Value.ToString("yyyy-MM-dd"); l.LoanEnd = dtpLoanEnd.Value.ToString("yyyy-MM-dd"); l.VehicleID = Convert.ToInt32(dgvVehicles.SelectedRows[0].Cells[0].Value); if (loans.IsFree(l.VehicleID, l.LoanStart, l.LoanEnd) == 0) { loanList.Add(l); dgvLoanList.Rows.Add(dgvVehicles.SelectedRows[0].Cells[1].Value.ToString() + " " + dgvVehicles.SelectedRows[0].Cells[2].Value.ToString(), dtpLoanStart.Value.ToString("yyyy-MM-dd"), dtpLoanEnd.Value.ToString("yyyy-MM-dd")); } else { MessageBox.Show("A jármű foglalt."); } }