using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Windows.Forms; namespace Cyberpipe { class LogManager { //保存日志 public static void saveLog(String username, String operation) { try { //获得当前时间 string now = DateTime.Now.ToString("yyyy-MM-dd"); //操作名称转换 string convertedOper = operation; //根据oper名称转换为operid string convertSql = "select OPERID from casic_funclist where OPERNAME = '" + convertedOper + "'"; DataTable table = OledbHelper.QueryTable(convertSql); string operId = ""; operId = table.Rows.Count > 0 ? table.Rows[0][0].ToString() : "0"; //保存日志 //string sql = " insert into casic_loginfo values('" + now + "','" + // username + "','" + operId + "','')"; string sql = "insert into casic_loginfo(LOGDATE,LOGUSERNAME,LOGOPER) values (to_date('" + now+"','yyyy-MM-dd'),'" + username + "','" + operId + "')"; int count = OledbHelper.sqlExecuteNonQuery(sql); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }