public void ShowData(String SelectStatment, String ColumnName, ListBox listView) { listView.Items.Clear(); dbConnection dbcon = new dbConnection(); dbcon.OpenConection(); SqlDataReader dr = dbcon.DataReader(SelectStatment); while (dr.Read()) { listView.Items.Add(dr[ColumnName]); } }
public void ListData(String SelectStatment, String ColumnName1, String ColumnName2, ListView listView) { listView.Items.Clear(); dbConnection dbcon = new dbConnection(); dbcon.OpenConection(); SqlDataReader dr = dbcon.DataReader(SelectStatment); while (dr.Read()) { listView.Items.Add(dr[ColumnName1].ToString()); listView.Items.Add(dr[ColumnName2].ToString()); } }
private void cmbCategory_MouseUp(object sender, MouseEventArgs e) { cmbCategory.Items.Clear(); dbConnection dbcon = new dbConnection(); dbcon.OpenConection(); SqlDataReader dr = dbcon.DataReader("select Category from tbMeCategory"); dr.Read(); if (dr.HasRows) { cmbCategory.Items.Add(dr["Category"]).ToString(); while (dr.Read()) { cmbCategory.Items.Add(dr["Category"]).ToString(); } } }
private void cmbRType_MouseUp(object sender, MouseEventArgs e) { cmbRType.Items.Clear(); dbConnection dbcon = new dbConnection(); dbcon.OpenConection(); SqlDataReader dr = dbcon.DataReader("select RType from tbRoomType"); dr.Read(); if (dr.HasRows) { cmbRType.Items.Add(dr["RType"]).ToString(); while (dr.Read()) { cmbRType.Items.Add(dr["RType"]).ToString(); } } }
public void RoomModule_Load(object sender, EventArgs e) { listViewShow lst = new listViewShow(); lst.ShowData("select RoomNo from tbRoom", "RoomNo", lstView); dbConnection dbcon = new dbConnection(); dbcon.OpenConection(); SqlDataReader dr = dbcon.DataReader("select RType from tbRoomType"); dr.Read(); if (dr.HasRows) { cmbRType.Items.Add(dr["RType"]).ToString(); while (dr.Read()) { cmbRType.Items.Add(dr["RType"]).ToString(); } } }
public int getID(string Selectstatment, string ColumName) { dbConnection dbcon = new dbConnection(); dbcon.OpenConection(); SqlDataReader dr = dbcon.DataReader(Selectstatment); dr.Read(); string ID = null; if (dr.HasRows) { ID = dr[ColumName].ToString(); if (ID == null) { int y = 1; return(y); } while (dr.Read()) { ID = dr[ColumName].ToString(); } if (ID == null) { int y = 2; return(y); } if (ID != null) { int y = Int32.Parse(ID) + 1; return(y); } } return(1); }