/// <summary> /// 调用存储过程(分页存储过程)初始化dataGirdView /// </summary> /// <param name="tableName">要绑定的表名</param> /// <param name="procSplitPageName">分页查询的存储过程名称:p_splitPage</param> /// <param name="procQueryTableRecordCountName">查询数据个数的存储过程名称:p_queryTableRecordCount</param> public void Sx_initDataGirdView() { if (Sx_tableName.Length == 0) { MessageBox.Show("initDataGirdView方法未指定表名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@pageSize", sx_pageSize), new SqlParameter("@currentPage", sx_currentPageIndex), new SqlParameter("@tableName", Sx_tableName) }; sx_dataGirdView.DataSource = CommonDB.invokeProc_DataTable(Sx_procSplitPageName, sp); #region dataGridView相关属性设置【抛出,不在此设置】 //// 设置 dataGridView1 的第1列整列单元格为只读 //dataGirdView.Columns[0].ReadOnly = true; //// 设定包括Header和所有单元格的列宽自动调整 //dataGirdView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; //// 设定包括Header和所有单元格的行高自动调整 //dataGirdView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; #endregion //查询表记录数 Sx_queryDataCount(); calcPageInfo(); } }
/// <summary> /// 调用存储过程查询表记录数 /// </summary> /// <param name="tableName">表名</param> /// <param name="p_queryTableRecordCountName">存储过程名称:p_queryTableRecordCount</param> private void Sx_queryDataCount() { if ((Sx_tableName != null && Sx_tableName.Trim().Length != 0) && (Sx_procQueryTableRecordCountName != null && Sx_procQueryTableRecordCountName.Trim().Length != 0)) { //查询表记录数 SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@tableName", Sx_tableName) }; object flag = CommonDB.invokeProc_ExecuteScalar(Sx_procQueryTableRecordCountName, sp); sx_totalCount = Convert.ToInt32(flag); } else { MessageBox.Show("queryDataCount参数有误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }