private void FrmCheckin_Load(object sender, EventArgs e) { //查询未入住房间 try { FreeRoomNum freeroom = new FreeRoomNum(); freeroom.lxbh = "0"; freeroom.fjlx = "请选择"; this.cb_rzfj.DisplayMember = "fjlx"; this.cb_rzfj.ValueMember = "lxbh"; List <FreeRoomNum> lst_room = Bll_Room.GetFreeRoom(); for (int i = 0; i < lst_room.Count; i++) { lst_room[i].fjlx = lst_room[i].fjlx + "(" + lst_room[i].sl + ")"; } lst_room.Insert(0, freeroom); this.cb_rzfj.DataSource = lst_room; } catch (MySqlException ex) { MessageBox.Show("数据库异常:" + ex.Message); } catch (Exception ex) { MessageBox.Show("其它异常:" + ex.Message); } }
public FrmReserve() { InitializeComponent(); //查询未入住房间 try { FreeRoomNum freeroom = new FreeRoomNum(); freeroom.lxbh = "0"; freeroom.fjlx = "请选择"; this.cb_rzfj.DisplayMember = "fjlx"; this.cb_rzfj.ValueMember = "lxbh"; List <FreeRoomNum> lst_room = Bll_Room.GetFreeRoom(); for (int i = 0; i < lst_room.Count; i++) { lst_room[i].fjlx = lst_room[i].fjlx + "(" + lst_room[i].sl + ")"; } lst_room.Insert(0, freeroom); this.cb_rzfj.DataSource = lst_room; } catch (MySqlException ex) { MessageBox.Show("数据库异常:" + ex.Message); } catch (Exception ex) { MessageBox.Show("其它异常:" + ex.Message); } }
/// <summary> /// 查询未入住房间 /// </summary> /// <returns></returns> public static List <FreeRoomNum> GetFreeRoom() { MySqlDataReader reader = SqlHelper.ExecuteReader("GetFreeRoom", CommandType.Text, null); List <FreeRoomNum> freeroom = new List <FreeRoomNum>(); while (reader.Read()) { FreeRoomNum r = new FreeRoomNum(); r.lxbh = reader["lxbh"].ToString(); r.fjlx = reader["fjlx"].ToString(); r.sl = reader["sl"].ToString(); freeroom.Add(r); } reader.Close(); return(freeroom); }
/// <summary> /// 查询未入住房间 /// </summary> /// <returns></returns> public static List <FreeRoomNum> GetFreeRoom() { string sql = "select t.fjlx lxbh,GetCodeMean('1001', t.fjlx) fjlx,COUNT(*)sl from room t where t.fjzt='2' GROUP BY lxbh"; MySqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.Text, null); List <FreeRoomNum> freeroom = new List <FreeRoomNum>(); while (reader.Read()) { FreeRoomNum r = new FreeRoomNum(); r.lxbh = reader["lxbh"].ToString(); r.fjlx = reader["fjlx"].ToString(); r.sl = reader["sl"].ToString(); freeroom.Add(r); } reader.Close(); return(freeroom); }