/// <summary> /// Hàm lấy dữ liệu . Trả về 1 data table /// </summary> /// <returns></returns> public DataTable GetData() { DataTable dt = new DataTable(); cmd.CommandText = "select * from HoaDon"; cmd.CommandType = CommandType.Text; cmd.Connection = con.strConn; try { con.OpenConnect(); SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); con.CloseConnection(); } catch (Exception ex) { string mes = ex.Message; cmd.Dispose(); con.CloseConnection(); } return(dt); }
public bool SeachKhachHang(KhachHangObj khobj) { cmd.CommandText = "select from KhachHang where TenKH LIKE " + khobj.TenKH + " "; cmd.CommandType = CommandType.Text; cmd.Connection = con.strConn; try { con.OpenConnect(); cmd.ExecuteNonQuery(); con.CloseConnection(); return(true); } catch (Exception ex) { string mes = ex.Message; cmd.Dispose(); con.CloseConnection(); } return(true); }
private DataTable timKiem() { DataTable dt = new DataTable(); cmd.CommandText = " select * from KhachHang where TenKH LIKE '" + txtSeach.Text.ToString() + "' "; cmd.CommandType = CommandType.Text; cmd.Connection = con.strConn; try { con.OpenConnect(); cmd.ExecuteNonQuery(); SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); con.CloseConnection(); con.CloseConnection(); } catch (Exception ex) { string mes = ex.Message; cmd.Dispose(); con.CloseConnection(); } return(dt); }