private void LoadGridView() { conn.Connect(); var reult = conn.database.RunCommand <BsonDocument>(new BsonDocument { { "eval", "getCustomer()" } }); var array = reult["retval"].AsBsonArray; foreach (var document in array) { DataGridViewRow row = (DataGridViewRow)gridviewKH.Rows[0].Clone(); // row.Cells[0].Value = b["_id"].AsObjectId; row.Cells[0].Value = document["HoTen"].AsString; row.Cells[1].Value = (document["tuoi"].AsInt64).ToString(); row.Cells[2].Value = document["DiaChi"].AsString; row.Cells[3].Value = (document["dienThoai"].AsInt64).ToString(); row.Cells[4].Value = document["maGiamGia"].AsString; row.Cells[5].Value = document["_id"].AsObjectId; gridviewKH.Rows.Add(row); } }
//排序 public static DataTable ExecuteQuery(out int total, string sql, string sortExpression, int start, int count, params SqlParameter[] cmdParms) { string sort = String.IsNullOrEmpty(sortExpression) ? "":" order by " + sortExpression; string sql1 = "select count(*)" + sql.Substring(sql.IndexOf(" from")); SqlConnection con = ConnectDB.Connect(); SqlCommand cmd = new SqlCommand(sql + sort, con); SqlCommand cmd1 = new SqlCommand(sql1, con); con.Open(); foreach (SqlParameter parm in cmdParms) { cmd.Parameters.Add(parm); cmd1.Parameters.Add(parm); } total = Int32.Parse(cmd1.ExecuteScalar().ToString());//查询第一行获取记录 DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); try { da.Fill(start, count, dt); return(dt); } catch { return(null); } finally { da.Dispose(); cmd.Dispose(); cmd1.Dispose(); con.Close(); con.Dispose(); } }
public CategoryNewsController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public NewsController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public GroupTinhnangController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public ProductsController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public CommentsController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public OrderController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public AuthRepository(ISocialMediaDBSettings settings) { var db = ConnectDB.Connect(settings); _users = db.GetCollection <User>("Users"); }
public CategoryImageController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public testController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public PermissionController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public IntroductionController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public QuangcaoController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public PostRepository(ISocialMediaDBSettings settings) : base(settings) { var db = ConnectDB.Connect(settings); _posts = db.GetCollection <Post>("Posts"); }
public HDSudungController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public BaohanhController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public DanhmucPhukienController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public FaqController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public SettingController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public GenericRepository(ISocialMediaDBSettings settings) { var db = ConnectDB.Connect(settings); _collection = db.GetCollection <TDocument>(GetCollectionName(typeof(TDocument))); }
public AddressController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public MenuController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public VitriController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public LikeRepository(ISocialMediaDBSettings settings) : base(settings) { var db = ConnectDB.Connect(settings); _likes = db.GetCollection <Like>("Likes"); }
public CommentRepository(ISocialMediaDBSettings settings) : base(settings) { var db = ConnectDB.Connect(settings); _comments = db.GetCollection <Comment>("Comments"); }
public ConfigController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public UsersController() { con = ConnectDB.Connect(); ConnectDB.Open(); }
public DanhmucsanphamController() { con = ConnectDB.Connect(); ConnectDB.Open(); }