public List<CSeatType> get_seattypes(string key, object key_val) { var seat_types = new List<CSeatType>(); SqlConnection sqlCn = open_connection(); if (sqlCn == null || sqlCn.State != ConnectionState.Open) return seat_types; try { string cmd_str = "Select * from [SeatType]"; if (key != null) cmd_str += " where " + key + "='" + key_val.ToString() + "'"; SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn); using (SqlDataReader dr = cmdSelect.ExecuteReader()) { while (dr.Read()) { var seat_type = new CSeatType(); seat_type.id = (int)dr["id"]; seat_type.name = dr["name"].ToString(); seat_type.population = (int)dr["population"]; seat_type.menuId = ToInt(dr["menuId"]); seat_type.department = dr["department"].ToString(); seat_type.depositeRequired = ToBool(dr["depositeRequired"]); seat_type.depositeAmountMin = ToInt(dr["depositeAmountMin"]); seat_types.Add(seat_type); } } } catch (System.Exception e) { BathClass.printErrorMsg(e.Message); IOUtil.insert_file(e.Message + "\n"); } finally { close_connection(sqlCn); } return seat_types; }
private void OpenDepositForm_Load(object sender, EventArgs e) { //db = new BathDBDataContext(LogIn.connectionString); //m_seatType = db.SeatType.FirstOrDefault(x => x.id == m_seat.typeId); dao = new DAO(LogIn.connectionString); m_seatType = dao.get_seattype("id", m_seat.typeId); depositMin.Text = m_seatType.depositeAmountMin.ToString(); }