baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GuangFu.StringTracing", "GuangFu.StringTracing\GuangFu.StringTracing.csproj", "{96026F2A-5866-4570-B6E5-DDB8E5A1F919}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{96026F2A-5866-4570-B6E5-DDB8E5A1F919}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{96026F2A-5866-4570-B6E5-DDB8E5A1F919}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{96026F2A-5866-4570-B6E5-DDB8E5A1F919}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{96026F2A-5866-4570-B6E5-DDB8E5A1F919}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace GuangFu.StringTracing.Common
|
||||
{
|
||||
|
||||
public class MySqlUtils : IDisposable
|
||||
{
|
||||
#region 构造函数
|
||||
public MySqlUtils()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 连接字符串
|
||||
private string _connectionString;
|
||||
public string ConnectionString
|
||||
{
|
||||
get { return _connectionString; }
|
||||
set { _connectionString = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据库连接
|
||||
/// <summary>
|
||||
/// 数据库连接
|
||||
/// </summary>
|
||||
public MySqlConnection Connection
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取连接
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlConnection GetConnection()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Connection == null)
|
||||
{
|
||||
Connection = new MySqlConnection();
|
||||
Connection.ConnectionString = _connectionString;
|
||||
}
|
||||
if (Connection.State == ConnectionState.Broken)
|
||||
{
|
||||
Connection.Close();
|
||||
}
|
||||
if (Connection.State == ConnectionState.Closed)
|
||||
{
|
||||
Connection.ConnectionString = _connectionString;
|
||||
Connection.Open();
|
||||
}
|
||||
return Connection;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("获取连接失败.\r\n" + ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 销毁对象
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (Connection != null)
|
||||
{
|
||||
if (Connection.State != ConnectionState.Closed)
|
||||
{
|
||||
Connection.Close();
|
||||
}
|
||||
Connection.Dispose();
|
||||
Connection = null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 执行查询
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="strSQL"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable ExecQuery(string strSQL)
|
||||
{
|
||||
DataSet dsTemp = new DataSet();
|
||||
try
|
||||
{
|
||||
using (MySqlDataAdapter daExcute = new MySqlDataAdapter(strSQL, GetConnection()))
|
||||
{
|
||||
daExcute.Fill(dsTemp);
|
||||
|
||||
if (DBNull.Value.Equals(dsTemp) || dsTemp.Tables.Count < 1 || DBNull.Value.Equals(dsTemp.Tables[0]))
|
||||
{
|
||||
throw new Exception("查询结果为空.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return dsTemp.Tables[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 执行增删改(不带参数)
|
||||
/// <summary>
|
||||
/// 执行增删改操作
|
||||
/// </summary>
|
||||
/// <param name="strSQL">SQL语句</param>
|
||||
/// <returns>受影响的行数</returns>
|
||||
public int ExecNonQuery(string strSQL)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand(strSQL, GetConnection()))
|
||||
{
|
||||
return cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("执行SQL失败: " + strSQL + "\r\n" + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 执行增删改(带参数)
|
||||
/// <summary>
|
||||
/// 执行带参数的增删改操作
|
||||
/// </summary>
|
||||
/// <param name="strSQL">SQL语句</param>
|
||||
/// <param name="parameters">参数数组</param>
|
||||
/// <returns>受影响的行数</returns>
|
||||
public int ExecNonQuery(string strSQL, params MySqlParameter[] parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand(strSQL, GetConnection()))
|
||||
{
|
||||
if (parameters != null && parameters.Length > 0)
|
||||
{
|
||||
cmd.Parameters.AddRange(parameters);
|
||||
}
|
||||
return cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("执行SQL失败: " + strSQL + "\r\n" + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user