using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Text;
|
using Commom.Utility;
|
using Common;
|
using Model;
|
|
namespace BLL
|
{
|
public class DALUnit : IDALUnit
|
{
|
public bool Add(Unit model, string loginUser)
|
{
|
bool result = false;
|
try
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["UnitNum"] = "'" + model.UnitNum + "'";
|
ht["UnitName"] = "'" + model.UnitName + "'";
|
|
ht["CreatUser"] = "'" + loginUser + "'";
|
ht["Demo"] = "'" + model.Demo + "'";
|
|
int _ret = DataFactory.SqlDataBase().InsertByHashtableNullParam("Unit", ht);
|
|
if (_ret == 1) result = true;
|
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
//审核
|
public bool AnditUnit(string[] UnitNum, string AuditModel,string User)
|
{
|
bool result = false;
|
try
|
{
|
int dt = DataFactory.SqlDataBase().IsExist("Log_Unit", "UnitNum", UnitNum);
|
if (dt >= UnitNum.Length)
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["AuditFlag"] = string.IsNullOrEmpty(AuditModel) ? "'AD01'" : "'" + AuditModel + "'";
|
ht["AuditUser"] ="'"+ User+"'";
|
ht["AuditTime"] = "getdate()";
|
int _ret = DataFactory.SqlDataBase().UpdateByHashtableA("Unit", "UnitNum", UnitNum, ht);
|
|
if (_ret >= UnitNum.Length) result = true;
|
}
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public bool BatchDelete(string[] UnitNum)
|
{
|
bool result = false;
|
try
|
{
|
int i = 0;
|
int _ret = 0;
|
while (i < UnitNum.Length)
|
{
|
StringBuilder sql = new StringBuilder();
|
sql.Append("update Unit set IsDel=1 where Guid='" + UnitNum[i] + "'");
|
_ret += DataFactory.SqlDataBase().ExecuteBySql(sql);
|
if (_ret >= UnitNum.Length)
|
{
|
result = true;
|
}
|
|
i++;
|
}
|
|
return result;
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public bool Delete(string UnitNum)
|
{
|
throw new NotImplementedException();
|
}
|
|
public DataTable GetDataTable(string[] strWhere)
|
{
|
throw new NotImplementedException();
|
}
|
|
public DataTable GetDataTable(int PageSize, int PageIndex, string strWhere)
|
{
|
throw new NotImplementedException();
|
}
|
|
public IList<Unit> GetUnitList()
|
{
|
try
|
{
|
|
IList<Unit> ls = new List<Unit>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("select UnitName,UnitNum,guid from Unit where IsDel = 0 order by creatTime");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<Unit>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public IList<Unit> GetList(AjaxUnitList Json, ref PageInfo pageInfo)
|
{
|
try
|
{
|
|
IList<Unit> list = new List<Unit>();
|
StringBuilder strSql = new StringBuilder();
|
List<SqlParam> para = new List<SqlParam>();
|
strSql.Append("Select * from view_Log_Unit ");
|
|
|
if (Json.UnitNum != null && Json.UnitNum != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("UnitNum like '%' + @UnitNum + '%' ");
|
para.Add(new SqlParam("@UnitNum", Json.UnitNum));
|
}
|
|
if (Json.UnitName != null && Json.UnitName != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("UnitName like '%' + @UnitName + '%' ");
|
para.Add(new SqlParam("@UnitName", Json.UnitName));
|
}
|
|
if (para.Count < 1) strSql.Append("where IsDel = 0"); else strSql.Append(" and IsDel = 0");
|
|
SqlParam[] param = null;
|
if (para != null)
|
param = para.ToArray();
|
|
|
DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "CreatTime", "DESC", ref pageInfo);
|
|
list = ModelConvertHelper<Unit>.DataTableToModel(dt);
|
|
return list;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public Unit GetModel(string UnitNum)
|
{
|
try
|
{
|
Unit us = null;
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select * from view_Log_Unit where ");
|
strSql.Append("Guid = @UnitNum ");
|
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@UnitNum", UnitNum),
|
};
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
|
|
us = ModelConvertHelper<Unit>.ReaderToModel(dt);
|
|
return us;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public bool IsExist(string sqlWhere)
|
{
|
return DataFactory.SqlDataBase().IsExist("Unit", sqlWhere);
|
}
|
|
public bool Update(Unit model, string loginUser)
|
{
|
bool result = false;
|
try
|
{
|
Hashtable ht = new Hashtable();
|
ht["UnitName"] = model.UnitName.AddQuotes();
|
ht["Demo"] = model.Demo.AddQuotes();
|
ht["UpdateTime"] = "convert(varchar(20),getdate(),120)";
|
ht["UpdateUser"] = loginUser.AddQuotes();
|
|
string UnitNum = model.UnitNum.AddQuotes();
|
|
int _ret = DataFactory.SqlDataBase().UpdateByHashtable("Unit", "UnitNum", UnitNum, ht);
|
|
if (_ret == 1) result = true;
|
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
}
|
}
|