/// <summary> /// 传出一行数据信息 /// </summary> private void dgvGridData(int RowIndex) { GridDataEventArgs args = new GridDataEventArgs(); GridDataEventArgs.ArgsPass griddataargs; if (null != GridDataEvent) { if (RowIndex != -1) { griddataargs.id = dataGridView1.Rows[RowIndex].Cells[0].Value.ToString(); griddataargs.eventid = dataGridView1.Rows[RowIndex].Cells[1].Value.ToString(); griddataargs.priority = dataGridView1.Rows[RowIndex].Cells[2].Value.ToString(); griddataargs.category = dataGridView1.Rows[RowIndex].Cells[3].Value.ToString(); griddataargs.title = dataGridView1.Rows[RowIndex].Cells[4].Value.ToString(); griddataargs.message = dataGridView1.Rows[RowIndex].Cells[5].Value.ToString(); griddataargs.machine = dataGridView1.Rows[RowIndex].Cells[6].Value.ToString(); griddataargs.timestamp = dataGridView1.Rows[RowIndex].Cells[7].Value.ToString(); griddataargs.severity = dataGridView1.Rows[RowIndex].Cells[8].Value.ToString(); //griddataargs.appdomain = dataGridView1.Rows[RowIndex].Cells[9].Value.ToString(); //griddataargs.proccessid = dataGridView1.Rows[RowIndex].Cells[10].Value.ToString(); //griddataargs.proccessname = dataGridView1.Rows[RowIndex].Cells[11].Value.ToString(); //griddataargs.threadid = dataGridView1.Rows[RowIndex].Cells[12].Value.ToString(); //griddataargs.threadname = dataGridView1.Rows[RowIndex].Cells[13].Value.ToString(); //griddataargs.extendpropertry = dataGridView1.Rows[RowIndex].Cells[14].Value.ToString(); args.argspassto = griddataargs; GridDataEvent(this, args); } } }
/// <summary> /// 数据连接 /// </summary> /// <param name="value"></param> /// <param name="_searchstr"></param> private void connstring(int value, string _searchstr) { myconn = new OleDbConnection(); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string str = config.ConnectionStrings.ConnectionStrings["UserInformationDataBase"].ConnectionString; myconn.ConnectionString = str; myconn.Open(); //myadapter = new OleDbDataAdapter("P_viewPage", myconn); //myadapter.SelectCommand.CommandType = CommandType.StoredProcedure; //myadapter.SelectCommand.Parameters.Add("@Tablename", OleDbType.VarChar, 200); //myadapter.SelectCommand.Parameters[0].Value = "Rx_Log"; //myadapter.SelectCommand.Parameters.Add("@FieldList", OleDbType.VarChar, 2000); //myadapter.SelectCommand.Parameters[1].Value = // "id,EventId,Priority,Category,Title,Message,Machine,Timestamp,Severity,ApplicationDomain,ProcessId,ProcessName,Win32ThreadId,ThreadName,ExtendedProperties"; //myadapter.SelectCommand.Parameters.Add("@PrimaryKey", OleDbType.VarChar, 100); //myadapter.SelectCommand.Parameters[2].Value = "id"; //myadapter.SelectCommand.Parameters.Add("@Where", OleDbType.VarChar, 200); //myadapter.SelectCommand.Parameters[3].Value = _searchstr; //myadapter.SelectCommand.Parameters.Add("@Order", OleDbType.VarChar, 1000); //myadapter.SelectCommand.Parameters[4].Value = "id asc"; //myadapter.SelectCommand.Parameters.Add("@SortType", OleDbType.Integer); //myadapter.SelectCommand.Parameters[5].Value = 1; //myadapter.SelectCommand.Parameters.Add("@RecorderCount ", OleDbType.Integer); //myadapter.SelectCommand.Parameters[6].Value = 0; //myadapter.SelectCommand.Parameters.Add("@PageSize", OleDbType.Integer); //myadapter.SelectCommand.Parameters[7].Value = 30; //myadapter.SelectCommand.Parameters.Add("@PageIndex", OleDbType.Integer); ////SP-209 AnYan RenZihao 2008-07-30 页数为零的时候会出错,在页数为0时把它改为1 //myadapter.SelectCommand.Parameters[8].Value = (value==0)?1:value; //myadapter.SelectCommand.Parameters.Add("@TotalCount", OleDbType.Integer); //myadapter.SelectCommand.Parameters[9].Direction = ParameterDirection.Output; //myadapter.SelectCommand.Parameters.Add("@TotalPageCount", OleDbType.Integer); //myadapter.SelectCommand.Parameters[10].Direction = ParameterDirection.Output; Int32 counts; string strSql; strSql = ClassLibrary.Static.StaticMath.getPageListCounts("rx_log", "id", _searchstr =="" ? "": " and "+_searchstr, 0); myadapter = new OleDbDataAdapter(new OleDbCommand(strSql,myconn)); counts = (int)myadapter.SelectCommand.ExecuteScalar(); //strSql = ClassLibrary.Static.StaticMath.getPageListInSql("rx_log", // "id,EventId,Priority,Category,Title,Message,Machine,[Timestamp],Severity" // , 12, value == 0 ? 1 : value, out pageCount, counts, "id", // 0, _searchstr == "" ? "" : " and " + _searchstr, "id", 0); pageCount = ClassLibrary.Sql.FastPaging.GetPageCount(counts, 30); strSql = ClassLibrary.Sql.FastPaging.Paging(30, value-1, counts, "rx_log" , "id,EventId,Priority,Category,Title,Message,Machine,[Timestamp],Severity" , "id", true, _searchstr); myadapter = new OleDbDataAdapter(strSql, myconn); //myadapter.SelectCommand.Parameters[0].Direction = ParameterDirection.Output; //myadapter.SelectCommand = new OleDbCommand(strSql); myadapter.SelectCommand.ExecuteNonQuery(); ds1 = new VideospDBDataSet.Rx_logDataTable(); ds1.Clear(); myadapter.Fill(ds1); myadapter.Update(ds1); for (int i = 0; i < ds1.Rows.Count; i++) //循环修改列传值 { if (ds1.Rows[i]["eventid"].ToString() == "2000") { ds1.Rows[i]["eventid"] = "用户操作"; } else if (ds1.Rows[i]["eventid"].ToString() == "0") { ds1.Rows[i]["eventid"] = "报警联动"; } else if (ds1.Rows[i]["eventid"].ToString() == "100") { ds1.Rows[i]["eventid"] = "系统操作"; } else if (ds1.Rows[i]["eventid"].ToString() == "6352") { ds1.Rows[i]["eventid"] = "超越权限"; } ds1.AcceptChanges(); //这句最关键,完成修改,做用是允许对DATASET的修改 } dataGridView1.DataSource = ds1; if (m_clickDelLog && m_currentrow != 0) dataGridView1.Rows[m_currentrow - 1].Selected = true; else m_clickDelLog = false; Setcoloumnwidth(); if (dataGridView1.SelectedRows.Count == 0) { GridDataEventArgs args = new GridDataEventArgs(); GridDataEventArgs.ArgsPass griddataargs; griddataargs.id = ""; griddataargs.eventid = ""; griddataargs.priority = ""; griddataargs.timestamp = ""; griddataargs.machine = ""; griddataargs.message = ""; griddataargs.severity = ""; griddataargs.title = ""; griddataargs.category = ""; args.argspassto = griddataargs; GridDataEvent(this, args); } bdnInfo.Enabled = true; dataGridView1.Columns[2].Visible = false; dataGridView1.Columns[3].Visible = false; dataGridView1.Columns[5].Visible = false; myconn.Close(); if(dataGridView1.Rows.Count != 0) { if(m_currentrow > dataGridView1.Rows.Count-1) { m_currentrow = dataGridView1.Rows.Count - 1; } dataGridView1.Rows[m_currentrow].Selected = true; dataGridView1.CurrentCell = dataGridView1[0,m_currentrow]; dgvGridData(m_currentrow); } }