/// <summary> /// 记录应用系统错误消息 /// </summary> /// <param name="mError">错误实体</param> /// <returns>xt_result</returns> public xt_result SaveError(IList <xt_error> lError) { //错误消息 string sql = ""; int i = lError.Count; for (int j = 0; j < i; j++) { if (lError[j].Message.Length > 500) { lError[j].Message = lError[j].Message.Substring(0, 498); } sql = sql + "insert into xt_error (application,message) values ('" + lError[j].Application + "','" + lError[j].Message + "') ;"; } //开始事务 xt_result result = new xt_result(); SqlTransaction Trans; SqlConnection conn = SQLHelper.CreateConnection(base.User_Admin); conn.Open(); Trans = conn.BeginTransaction("trans1"); try { result.ReturnInt = SQLHelper.ExecuteNonQuery(base.User_Admin, CommandType.Text, sql, null); if (result.ReturnInt > 0) { Trans.Commit(); } } catch (Exception e) { result.Message = e.Message; result.Message = result.Message.Replace("\r\n", "\\n"); result.Message = result.Message.Replace("'", ""); Trans.Rollback(); } finally { conn.Close(); } return(result); }
/// <summary> /// 更新xt_tongji中的人数 /// </summary> /// <param name="renshu"></param> /// <returns></returns> public xt_result UpData(int renshu) { string sql = "update xt_tongji set renshu=@renshu;"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@renshu", SqlDbType.VarChar), }; param[0].Value = renshu; //开始事务 xt_result result = new xt_result(); result.Message = "更新数据 成功"; SqlTransaction Trans; SqlConnection conn = SQLHelper.CreateConnection(base.User_Admin); conn.Open(); Trans = conn.BeginTransaction("trans1"); try { result.ReturnInt = SQLHelper.ExecuteNonQuery(Trans, CommandType.Text, sql, param); if (result.ReturnInt > 0) { Trans.Commit(); } else { result.Message = "更新数据 失败"; } } catch (Exception e) { result.Message = e.Message; result.Message = result.Message.Replace("\r\n", ""); result.Message = result.Message.Replace("'", ""); Trans.Rollback(); } finally { conn.Close(); } return(result); }
/// <summary> /// 插入功能 /// </summary> /// <param name="mXt_gongneng"></param> /// <returns></returns> public xt_result InsertGongneng(gongneng mGongneng) { string sql = "insert into gongneng values (@daihao,@yingyong,@bianhao,@xuhao,@mingcheng,@canshu0,@canshu1,@canshu2,@canshu3,@canshu4,@canshu5,@canshu6,@canshu7,@canshu8,@canshu9 )"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@daihao", SqlDbType.NVarChar, 20), new SqlParameter("@yingyong", SqlDbType.NVarChar, 20), new SqlParameter("@bianhao", SqlDbType.NVarChar, 6), new SqlParameter("@xuhao", SqlDbType.NVarChar, 6), new SqlParameter("@mingcheng", SqlDbType.NVarChar, 10), new SqlParameter("@canshu0", SqlDbType.NVarChar, 1), new SqlParameter("@canshu1", SqlDbType.NVarChar, 1), new SqlParameter("@canshu2", SqlDbType.NVarChar, 1), new SqlParameter("@canshu3", SqlDbType.NVarChar, 1), new SqlParameter("@canshu4", SqlDbType.NVarChar, 1), new SqlParameter("@canshu5", SqlDbType.NVarChar, 1), new SqlParameter("@canshu6", SqlDbType.NVarChar, 1), new SqlParameter("@canshu7", SqlDbType.NVarChar, 1), new SqlParameter("@canshu8", SqlDbType.NVarChar, 1), new SqlParameter("@canshu9", SqlDbType.NVarChar, 1) }; param[0].Value = mGongneng.Daihao; param[1].Value = mGongneng.Yingyong; param[2].Value = mGongneng.Bianhao; param[3].Value = mGongneng.Xuhao; param[4].Value = mGongneng.Mingcheng; param[5].Value = mGongneng.Canshu0; param[6].Value = mGongneng.Canshu1; param[7].Value = mGongneng.Canshu2; param[8].Value = mGongneng.Canshu3; param[9].Value = mGongneng.Canshu4; param[10].Value = mGongneng.Canshu5; param[11].Value = mGongneng.Canshu6; param[12].Value = mGongneng.Canshu7; param[13].Value = mGongneng.Canshu8; param[14].Value = mGongneng.Canshu9; //开始事务 xt_result result = new xt_result(); SqlTransaction Trans; SqlConnection conn = SQLHelper.CreateConnection(base.User_Admin); conn.Open(); Trans = conn.BeginTransaction("trans1"); try { result.ReturnInt = SQLHelper.ExecuteNonQuery(Trans, CommandType.Text, sql, param); if (result.ReturnInt > 0) { Trans.Commit(); } } catch (Exception e) { result.Message = e.Message; result.Message = result.Message.Replace("\r\n", "\\n"); result.Message = result.Message.Replace("'", ""); Trans.Rollback(); } finally { conn.Close(); } return(result); }