|
@@ -16,7 +16,7 @@ namespace Services
|
|
|
/// <summary>
|
|
|
/// 基础服务
|
|
|
/// </summary>
|
|
|
- public class BaseServices: BaseInterface
|
|
|
+ public class BaseServices : BaseInterface
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 装箱单个数据对象
|
|
@@ -65,7 +65,7 @@ namespace Services
|
|
|
protected List<string> Loadstringist(DataTable dt)
|
|
|
{
|
|
|
List<string> result = new List<string>();
|
|
|
-
|
|
|
+
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
{
|
|
|
result.Add(dr[0].ToString());
|
|
@@ -75,11 +75,11 @@ namespace Services
|
|
|
|
|
|
public Boolean Add<T>(T obj)
|
|
|
{
|
|
|
- if (obj==null)
|
|
|
+ if (obj == null)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
- string tablename= EnumHelper.GetZXTableName<T>();
|
|
|
+ string tablename = EnumHelper.GetZXTableName<T>();
|
|
|
var tbnameary = tablename.Split('.');
|
|
|
List<string> fildlist = new List<string>();
|
|
|
List<string> paramsql = new List<string>();
|
|
@@ -95,13 +95,20 @@ namespace Services
|
|
|
{
|
|
|
fildlist.Add(pi.Name);
|
|
|
paramsql.Add("@" + pi.Name);
|
|
|
- paramlist.Add(new SqlParameter("@"+pi.Name, value1));
|
|
|
- }
|
|
|
+ paramlist.Add(new SqlParameter("@" + pi.Name, value1));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
string insertsql = string.Format(AddItemSql, tbnameary[1], string.Join(",", fildlist), string.Join(",", paramsql));
|
|
|
var conn = SqlHelper.GetConnection(tbnameary[0]);
|
|
|
- var result = SqlHelper.ExecuteNonQuery(conn,CommandType.Text, insertsql, paramlist.ToArray());
|
|
|
+ var result = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, insertsql, paramlist.ToArray());
|
|
|
+ return result > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool CBAdd(string sql, SqlParameter[] para)
|
|
|
+ {
|
|
|
+ var conn = SqlHelper.GetConnection("CBDataBase");
|
|
|
+ var result = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, para);
|
|
|
return result > 0;
|
|
|
}
|
|
|
|
|
@@ -128,8 +135,8 @@ namespace Services
|
|
|
return result > 0;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public T QueryItembyKey<T>(object key )
|
|
|
+
|
|
|
+ public T QueryItembyKey<T>(object key)
|
|
|
{
|
|
|
string tablename = EnumHelper.GetZXTableName<T>();
|
|
|
var tbnameary = tablename.Split('.');
|
|
@@ -170,7 +177,7 @@ namespace Services
|
|
|
string tablename = EnumHelper.GetZXTableName<T>();
|
|
|
var tbnameary = tablename.Split('.');
|
|
|
List<string> paramsql = new List<string>();
|
|
|
- var key = new object() ;
|
|
|
+ var key = new object();
|
|
|
string keyname = string.Empty;
|
|
|
List<SqlParameter> paramlist = new List<SqlParameter>();
|
|
|
foreach (PropertyInfo pi in data.GetType().GetProperties())
|
|
@@ -192,12 +199,12 @@ namespace Services
|
|
|
|
|
|
if (((IsInsert)attribute).FildName)
|
|
|
{
|
|
|
- paramsql.Add(string.Format(" {0} = @{0}",pi.Name));
|
|
|
+ paramsql.Add(string.Format(" {0} = @{0}", pi.Name));
|
|
|
paramlist.Add(new SqlParameter("@" + pi.Name, value1));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- string insertsql = string.Format(UpdateItemsql, tbnameary[1], string.Join(" ,", paramsql),keyname,key.GetType()==typeof(int)?key:"'"+key+"'");
|
|
|
+ string insertsql = string.Format(UpdateItemsql, tbnameary[1], string.Join(" ,", paramsql), keyname, key.GetType() == typeof(int) ? key : "'" + key + "'");
|
|
|
var conn = SqlHelper.GetConnection(tbnameary[0]);
|
|
|
var result = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, insertsql, paramlist.ToArray());
|
|
|
return result > 0;
|
|
@@ -205,8 +212,8 @@ namespace Services
|
|
|
|
|
|
public List<T> GetList<T>(int page, int rows, string order, List<EExpression> expression, bool isDesc = true)
|
|
|
{
|
|
|
- int startindex = (page-1) * rows;
|
|
|
- int endindex = startindex + rows+1;
|
|
|
+ int startindex = (page - 1) * rows;
|
|
|
+ int endindex = startindex + rows + 1;
|
|
|
string tablename = EnumHelper.GetZXTableName<T>();
|
|
|
var tbnameary = tablename.Split('.');
|
|
|
List<string> fildlist = new List<string>();
|
|
@@ -227,10 +234,10 @@ namespace Services
|
|
|
}
|
|
|
for (int i = 0; i < expression.Count; i++)
|
|
|
{
|
|
|
- expressionlist.Add(@" AND "+expression[i].GetSql());
|
|
|
+ expressionlist.Add(@" AND " + expression[i].GetSql());
|
|
|
}
|
|
|
//"AND OpenCode1>3 AND IsChecked=1"
|
|
|
- string pageListSql = string.Format(QueryListPageSql, string.Join(",", fildlist),order==null?keyname: order, isDesc?"desc":"asc",tbnameary[1],string.Join("", expressionlist),startindex,endindex);
|
|
|
+ string pageListSql = string.Format(QueryListPageSql, string.Join(",", fildlist), order == null ? keyname : order, isDesc ? "desc" : "asc", tbnameary[1], string.Join("", expressionlist), startindex, endindex);
|
|
|
var conn = SqlHelper.GetConnection(tbnameary[0]);
|
|
|
var ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, pageListSql);
|
|
|
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
@@ -243,7 +250,7 @@ namespace Services
|
|
|
return new List<T>();
|
|
|
}
|
|
|
}
|
|
|
- public List<T> GetList<T>(string order,List<EExpression> expression, bool isDesc = true)
|
|
|
+ public List<T> GetList<T>(string order, List<EExpression> expression, bool isDesc = true)
|
|
|
{
|
|
|
string tablename = EnumHelper.GetZXTableName<T>();
|
|
|
var tbnameary = tablename.Split('.');
|
|
@@ -278,7 +285,7 @@ namespace Services
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
public int GetCount<T>()
|
|
|
{
|
|
|
string tablename = EnumHelper.GetZXTableName<T>();
|
|
@@ -330,7 +337,7 @@ namespace Services
|
|
|
|
|
|
private static string PageListCount = @"SELECT Count({0}) FROM {1} WHERE 1=1 {2}";
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|