Exemple #1
0
        public int InsertSystemLogTable(EntitySystemLog entity)
        {
            string SqlStr = "";

            SqlStr  = "insert into tc_system_log";
            SqlStr += " values('" + entity.DateLogOn + "','" + entity.DateLogOff + "','" + entity.UserName.Trim() + "')";

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = SqlStr;

            ExcuteSql(sqlCommand);

            return(Constants.SystemConfig.SERVER_SUCCESS);
        }
Exemple #2
0
        //***********************************************************************
        /// <summary>
        /// 关闭按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        ///    完成信息:赵毅男      2010/09/20 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            //取得日志实体
            EntitySystemLog systemLogEntity = new EntitySystemLog();

            systemLogEntity.DateLogOn  = LoginUser.LogOnTime;
            systemLogEntity.DateLogOff = DateTime.Now;
            systemLogEntity.UserName   = LoginUser.UserName;

            try
            {
                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //调用数据操作类
                GetData getData = new GetData(dataAccess.Connection);
                int     result  = getData.InsertSystemLogTable(systemLogEntity);

                //如果失败
                if (result == -1)
                {
                    MessageBox.Show("添加系统日志失败,请查看数据库连接是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dataAccess.Close();
            }

            //退出系统
            Application.Exit();
        }