using Commom.Utility;
|
using Common;
|
using Model;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Text;
|
|
namespace BLL.DAL
|
{
|
public class DALDepotsArea
|
{
|
/// <summary>
|
/// 获取区域集合
|
/// </summary>
|
/// <param name="region"></param>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public IList<DepotsArea> GetDepotsAreaItems(QueryDepotsArea depotsArea, ref PageInfo page)
|
{
|
try
|
{
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("select * from View_DepotsArea_Region where IsDel = 0 ");
|
if (depotsArea.DepotsCode != null && depotsArea.DepotsCode != "")
|
{
|
stringBuilder.Append("and DepotsCode like '%" + depotsArea.DepotsCode + "%' ");
|
}
|
if (depotsArea.DepotsName != null && depotsArea.DepotsName != "")
|
{
|
stringBuilder.Append("and DepotsName like '%" + depotsArea.DepotsName + "%' ");
|
}
|
//if (depotsArea.RegionID != null && depotsArea.RegionID != "")
|
//{
|
// stringBuilder.Append("and RegionID = " + depotsArea.RegionID.AddQuotes());
|
//}
|
|
SqlParam[] para = new SqlParam[]
|
{
|
};
|
|
DataTable dt = DataFactory.SqlDataBase().GetPageList(stringBuilder.ToString(), para, "CreatTime", "DESC", ref page);
|
IList<DepotsArea> list = ModelConvertHelper<DepotsArea>.DataTableToModel(dt);
|
|
return list;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public IList<DepotsArea> GetDepotsAreaItems(string Guid = "",string RegionId = "")
|
{
|
try
|
{
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("select * from View_DepotsArea_Region where IsDel = 0 ");
|
if (Guid != null && Guid != "")
|
{
|
stringBuilder.Append(" and Guid = " + Guid.AddQuotes());
|
}
|
//if (RegionId != null && RegionId != "")
|
//{
|
// stringBuilder.Append(" and RegionID = " + RegionId.AddQuotes());
|
//}
|
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(stringBuilder);
|
return ModelConvertHelper<DepotsArea>.DataTableToModel(dt);
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
public IList<DepotsArea> GetDepotsAreaItems()
|
{
|
try
|
{
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("select * from View_DepotsArea_Region where IsDel = 0 ");
|
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(stringBuilder);
|
return ModelConvertHelper<DepotsArea>.DataTableToModel(dt);
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
/// <summary>
|
/// 保存区域信息
|
/// </summary>
|
/// <param name="region"></param>
|
/// <param name="loginUser"></param>
|
/// <returns>true:成功 false:失败</returns>
|
public bool SetDepotsAreas(DepotsArea depotsArea, string loginUser)
|
{
|
try
|
{
|
bool bl = false;
|
int rowCount = 0;
|
Hashtable ht = new Hashtable();
|
if (depotsArea.Guid == "")
|
{
|
ht["DepotsCode"] = depotsArea.DepotsCode.AddQuotes();
|
ht["DepotsName"] = depotsArea.DepotsName.AddQuotes();
|
//ht["RegionID"] = depotsArea.RegionID.AddQuotes();
|
ht["DepotsRow"]= depotsArea.DepotsRow;
|
ht["DepotsColumn"] = depotsArea.DepotsColumn;
|
ht["DepotsLayer"] = depotsArea.DepotsLayer;
|
//ht["InStorageLocation"] = depotsArea.InStorageLocation.AddQuotes();
|
//ht["OutStorageLocation"] = depotsArea.OutStorageLocation.AddQuotes();
|
ht["Demo"] = depotsArea.Demo.AddQuotes();
|
|
ht["CreatTime"] = "convert(varchar(20),getdate(),120)";
|
ht["CreatUser"] = loginUser.AddQuotes();
|
ht["UpdateTime"] = "convert(varchar(20),getdate(),120)";
|
ht["UpdateUser"] = loginUser.AddQuotes();
|
|
rowCount = DataFactory.SqlDataBase().InsertByHashtableNullParam("DepotsArea", ht);
|
}
|
else
|
{
|
ht["DepotsName"] = depotsArea.DepotsName.AddQuotes();
|
ht["Demo"] = depotsArea.Demo.AddQuotes();
|
ht["UpdateTime"] = "convert(varchar(20),getdate(),120)";
|
ht["UpdateUser"] = loginUser.AddQuotes();
|
|
rowCount = DataFactory.SqlDataBase().UpdateByHashtable("DepotsArea",
|
"Guid", depotsArea.Guid.AddQuotes(), ht);
|
}
|
|
if (rowCount > 0)
|
{
|
bl = true;
|
}
|
|
return bl;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
/// <summary>
|
/// 删除区域(逻辑删除)
|
/// </summary>
|
/// <param name="regionCodes"></param>
|
/// <param name="loginUser"></param>
|
/// <returns>true:成功 false:失败</returns>
|
public bool DelDepotsAreas(string[] DepotsAreaGuids, string loginUser)
|
{
|
try
|
{
|
bool bl = false;
|
int rowCount = 0;
|
Hashtable ht = new Hashtable();
|
foreach (string DepotsAreaGuid in DepotsAreaGuids)
|
{
|
ht["IsDel"] = 1;
|
rowCount += DataFactory.SqlDataBase().UpdateByHashtable("DepotsArea",
|
"Guid", DepotsAreaGuid.AddQuotes(), ht);
|
}
|
|
if (rowCount > 0)
|
{
|
bl = true;
|
}
|
|
return bl;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
/// <summary>
|
/// 检查是否已存在
|
/// </summary>
|
/// <param name="region"></param>
|
/// <returns></returns>
|
public bool IsExist(DepotsArea depotsArea)
|
{
|
try
|
{
|
bool bl = false;
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("select count(*) from depotsArea where (DepotsCode = " + depotsArea.DepotsCode.AddQuotes());
|
stringBuilder.Append(" or DepotsName = " + depotsArea.DepotsName.AddQuotes() + ") and isDel = 0 ");
|
stringBuilder.Append("and Guid != " + depotsArea.Guid.AddQuotes() + ";");
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(stringBuilder);
|
if (dt.Rows[0][0].ToString() != "0")
|
{
|
bl = true;
|
}
|
|
return bl;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
}
|
}
|