using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Text;
|
using Common;
|
using Model;
|
|
namespace BLL
|
{
|
public class DALGoodsPos : IDALGoodsPos
|
{
|
public bool Add(GoodsPos model, string loginUser)
|
{
|
bool result = false;
|
try
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["Addre"] = "'" + model.Area + model.pai.PadLeft(2,'0') + model.lie.PadLeft(2, '0') + model.ceng.PadLeft(2, '0') + "'";
|
ht["pai"] = "'" + model.pai.PadLeft(2, '0') + "'";
|
ht["lie"] = "'" + model.lie.PadLeft(2, '0') + "'";
|
ht["ceng"] = "'" + model.ceng.PadLeft(2, '0') + "'";
|
ht["Property"] = "'" + model.property + "'";
|
ht["ALock"] = "'" + model.ALock + "'";
|
ht["StorageAraeNo"] = "'" + model.Area + "'";
|
ht["Demo"] = "'" + model.Demo + "'";
|
|
ht["guid"] = "NEWID()";
|
|
int _ret = DataFactory.SqlDataBase().InsertByHashtableNullParam("GoodsPos", ht);
|
|
if (_ret == 1) result = true;
|
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public bool UpdateLock(string[] Addre, string ALock)
|
{
|
bool result = false;
|
try
|
{
|
int dt = DataFactory.SqlDataBase().IsExist("GoodsPos", "Addre", Addre);
|
if (dt >= Addre.Length)
|
{
|
Hashtable ht = new Hashtable();
|
string str = "";
|
if (ALock == "Lock") str = "NL";
|
if (ALock == "UnLock") str = "N";
|
ht["ALock"] = string.IsNullOrEmpty(ALock) ? "'N'" : "'" + str + "'";
|
|
int _ret = DataFactory.SqlDataBase().UpdateByHashtable("GoodsPos", "Addre", Addre ,ht);
|
if (_ret >= Addre.Length) result = true;
|
}
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public bool UpdateProperty(string[] Addre, string Property)
|
{
|
bool result = false;
|
try
|
{
|
int dt = DataFactory.SqlDataBase().IsExist("GoodsPos", "Addre", Addre);
|
if (dt >= Addre.Length)
|
{
|
Hashtable ht = new Hashtable();
|
string str = "";
|
//if (ALock == "Lock") str = "NL";
|
//if (ALock == "UnLock") str = "N";
|
ht["Property"] = string.IsNullOrEmpty(Property) ? "'N'" : "'" + Property + "'";
|
|
int _ret = DataFactory.SqlDataBase().UpdateByHashtable("GoodsPos", "Addre", Addre, ht);
|
if (_ret >= Addre.Length) result = true;
|
}
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public bool BatchDelete(string[] MatNo)
|
{
|
bool result = false;
|
try
|
{
|
int dt = DataFactory.SqlDataBase().IsExist("Material", "MatNo", MatNo);
|
if (dt >= MatNo.Length)
|
{
|
int _ret = DataFactory.SqlDataBase().BatchDeleteData("Material", "MatNo", MatNo);
|
if (_ret > MatNo.Length) result = true;
|
}
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public bool Delete(string MatNo)
|
{
|
throw new NotImplementedException();
|
}
|
|
public DataTable GetDataTable(string[] strWhere)
|
{
|
DataTable dt = null;
|
try
|
{
|
int index = 0;
|
string str = "@MatNo" + index;
|
SqlParam[] param = new SqlParam[strWhere.Length];
|
StringBuilder sql = new StringBuilder();
|
sql.Append("Select MatNo as 物料编码,MatName as 物料名称,packFormat as 包装规格,PackQuant as 包装量,UnitFrist as 计量单位(主),UnitSec as 计量单位(辅),Matweighttype as 物料轻重,storecondition as 储存环境,usefreq as 频率,sizeNum as 包装尺寸 FROM MatNo where MatNo in (");
|
|
for (int i = 0; i < param.Length - 1; i++)
|
{
|
string obj2 = strWhere[i];
|
str = "@MatNo" + index;
|
sql.Append(str).Append(",");
|
param[index] = new SqlParam(str, obj2);
|
index++;
|
}
|
str = "@MatNo" + index;
|
sql.Append(str);
|
param[index] = new SqlParam(str, strWhere[index]);
|
sql.Append(")");
|
|
dt = DataFactory.SqlDataBase().GetDataTableBySQL(sql, param, "");
|
|
return dt;
|
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public DataTable GetDataTable(int PageSize, int PageIndex, string strWhere)
|
{
|
throw new NotImplementedException();
|
}
|
//GetNullList
|
|
|
/// <summary>
|
/// 查询库位
|
/// </summary>
|
/// <param name="Json"></param>
|
/// <param name="pageInfo"></param>
|
/// <returns>库位集合</returns>
|
public IList<GoodsPos> GetList(AjaxGoodsPosList Json, ref PageInfo pageInfo)
|
{
|
try
|
{
|
|
IList<GoodsPos> list = new List<GoodsPos>();
|
StringBuilder strSql = new StringBuilder();
|
List<SqlParam> para = new List<SqlParam>();
|
strSql.Append("Select * from view_GoodsPos ");
|
|
|
if (Json.Addre != null && Json.Addre != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("addre like '%"+Json.Addre+"%' ");
|
para.Add(new SqlParam("@addre", Json.Addre));
|
}
|
|
if (Json.pai != null && Json.pai != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("pai = @pai ");
|
para.Add(new SqlParam("@pai", Json.pai.PadLeft(2,'0')));
|
}
|
|
if (Json.lie != null && Json.lie != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("lie = @lie ");
|
para.Add(new SqlParam("@lie", Json.lie.PadLeft(2, '0')));
|
}
|
|
if (Json.ceng != null && Json.ceng != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("ceng = @ceng ");
|
para.Add(new SqlParam("@ceng", Json.ceng.PadLeft(2, '0')));
|
}
|
|
if (Json.Area != null && Json.Area != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("StorageAraeNo = '" + Json.Area + "' ");
|
para.Add(new SqlParam("@Area", Json.Area));
|
}
|
|
if (Json.statu != null && Json.statu != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("statuNo = '"+ Json.statu + "' ");
|
para.Add(new SqlParam("@statu", Json.statu));
|
}
|
|
if (Json.property != null && Json.property != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("propertyNo = '"+ Json.property + "' ");
|
para.Add(new SqlParam("@property", Json.property));
|
}
|
|
if (Json.ALock != null && Json.ALock != "")
|
{
|
if (para.Count < 1) strSql.Append("where "); else strSql.Append(" and ");
|
strSql.Append("ALockNo = '"+ Json.ALock + "' ");
|
para.Add(new SqlParam("@ALock", Json.ALock));
|
}
|
|
|
SqlParam[] param = null;
|
if (para != null)
|
param = para.ToArray();
|
|
|
DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), param, "Id", "ASC", ref pageInfo);
|
|
list = ModelConvertHelper<GoodsPos>.DataTableToModel(dt);
|
|
return list;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
/// <summary>
|
/// 获取库位信息
|
/// </summary>
|
/// <param name="addre"></param>
|
/// <returns></returns>
|
public GoodsPos GetModel(string addre)
|
{
|
try
|
{
|
GoodsPos us = null;
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("select * from GoodsPos where ");
|
strSql.Append("addre = '"+ addre + "'");
|
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@addre", "'" + addre + "'"),
|
};
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql, para);
|
us = ModelConvertHelper<GoodsPos>.ReaderToModel(dt);
|
|
return us;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public bool IsExist(string name, string value)
|
{
|
bool result = false;
|
try
|
{
|
string[] para = new string[] { value };
|
int dt = DataFactory.SqlDataBase().IsExist("Material", name, para);
|
if (dt > 0) result = true;
|
return result;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
public bool IsExist(Hashtable ht)
|
{
|
bool result = false;
|
try
|
{
|
int dt = DataFactory.SqlDataBase().IsExist("Material", ht);
|
if (dt > 0) result = true;
|
return result;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
/// <summary>
|
/// 更新库位状态
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool Update(GoodsPos model)
|
{
|
bool result = false;
|
try
|
{
|
StringBuilder sbstr = new StringBuilder();
|
sbstr.Append("update GoodsPos set statu= '"+ model.statu+ "',");
|
sbstr.Append("Property= '" + model.property+ "',ALock='"+ model.ALock+ "',");
|
sbstr.Append( "Demo='" + model.Demo+ "' ");
|
sbstr.Append("where Addre = '" + model.Area + "';");
|
|
// 数据库交互
|
int _ret = DataFactory.SqlDataBase().ExecuteBySql(sbstr);
|
if (_ret == 1)
|
{
|
result = true;
|
}
|
|
return result;
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
|
public bool AnditMat(string[] MatNo, string AuditModel)
|
{
|
bool result = false;
|
try
|
{
|
int dt = DataFactory.SqlDataBase().IsExist("Material", "MatNo", MatNo);
|
if (dt >= MatNo.Length)
|
{
|
Hashtable ht = new Hashtable();
|
|
ht["AuditFlag"] = string.IsNullOrEmpty(AuditModel) ? "'N'" :"'" + AuditModel + "'";
|
|
int _ret = DataFactory.SqlDataBase().UpdateByHashtable("Material", "MatNo", MatNo, ht);
|
|
if (_ret >= MatNo.Length) result = true;
|
}
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public IList<GoodsPos> GetPaiList(string StorageNO)
|
{
|
try
|
{
|
IList<GoodsPos> ls = new List<GoodsPos>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select distinct pai,cast( pai as decimal) as ord from goodsPos");
|
if (StorageNO != string.Empty)
|
{
|
strSql.Append(" where StorageAraeNo = '" + StorageNO + "'");
|
}
|
strSql.Append(" order by cast( pai as decimal);");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<GoodsPos>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public IList<GoodsPos> GetLieList(string StorageNO)
|
{
|
try
|
{
|
IList<GoodsPos> ls = new List<GoodsPos>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select distinct lie,cast( lie as decimal) as ord from goodsPos");
|
if (StorageNO != string.Empty)
|
{
|
strSql.Append(" where StorageAraeNo = '" + StorageNO + "'");
|
}
|
strSql.Append(" order by cast( lie as decimal);");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<GoodsPos>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public IList<GoodsPos> GetCengList(string StorageNO)
|
{
|
try
|
{
|
IList<GoodsPos> ls = new List<GoodsPos>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select distinct ceng,cast( ceng as decimal) as ord from goodsPos");
|
if (StorageNO != string.Empty)
|
{
|
strSql.Append(" where StorageAraeNo = '" + StorageNO + "'");
|
}
|
strSql.Append(" order by cast( ceng as decimal);");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<GoodsPos>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public IList<GoodsProperty> GetPropertyList()
|
{
|
try
|
{
|
IList<GoodsProperty> ls = new List<GoodsProperty>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select PropertyNo,PropertyName from log_Property ");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<GoodsProperty>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public IList<GoodsStatu> GetStatuList()
|
{
|
try
|
{
|
IList<GoodsStatu> ls = new List<GoodsStatu>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select StatuNo,StatuName from log_Statu ");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<GoodsStatu>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public IList<GoodsALock> GetALockList()
|
{
|
try
|
{
|
IList<GoodsALock> ls = new List<GoodsALock>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select AlockNo,AlockName from log_ALock ");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<GoodsALock>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
public IList<GoodsArea> GetAreaList()
|
{
|
try
|
{
|
IList<GoodsArea> ls = new List<GoodsArea>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select StorageNo as AreaNo,StorageName as AreaName from StorageArea ");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<GoodsArea>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
public IList<GoodsPos> GetAddreList(string AreaNo)
|
{
|
try
|
{
|
IList<GoodsPos> ls = new List<GoodsPos>();
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select distinct Addre from goodsPos");
|
if (AreaNo != string.Empty)
|
{
|
strSql.Append(" where StorageAraeNo = '" + AreaNo + "'");
|
}
|
else
|
{
|
strSql.Append(" where 1=0");
|
}
|
strSql.Append(" order by addre;");
|
|
IDataReader dt = DataFactory.SqlDataBase().GetDataReaderBySQL(strSql);
|
ls = ModelConvertHelper<GoodsPos>.DataReaderToModel(dt);
|
|
return ls;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
}
|
}
|