using System; using System.Collections.Generic; using System.Linq; using System.Text; using CY.IDAL; using System.Data.SqlClient; using System.Data; using CY.Infrastructure.Query; namespace CY.SQLDAL { public class OA_CargoSpaceDAL : IOA_CargoSpaceDAL { private Database _dataBase = null; public OA_CargoSpaceDAL() { _dataBase = new Database(); } /// /// 新增 /// /// /// public bool InserModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_CargoSpace trueModel = model as Model.OA_CargoSpace; if (trueModel == null) { return false; } IList sqlParms = new List() { new SqlParameter("@MemberId",trueModel.MemberId), new SqlParameter("@WarehouseId",trueModel.WarehouseId), new SqlParameter("@Length",trueModel.Length), new SqlParameter("@Width",trueModel.Width), new SqlParameter("@Height",trueModel.Height), new SqlParameter("@StatusId",trueModel.StatusId), new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime), new SqlParameter("@Operator",trueModel.Operator), new SqlParameter("@Remark",trueModel.Remark), new SqlParameter("@Name",trueModel.Name) ,new SqlParameter("@OrderNum",trueModel.OrderNum) }; try { _dataBase.Query("sp_OA_CargoSpace_Insert", CommandType.StoredProcedure, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } /// /// 修改 /// /// /// public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_CargoSpace trueModel = model as Model.OA_CargoSpace; if (trueModel == null) { return false; } IList sqlParms = new List() { new SqlParameter("@Keyid",trueModel.Keyid), new SqlParameter("@MemberId",trueModel.MemberId), new SqlParameter("@WarehouseId",trueModel.WarehouseId), new SqlParameter("@Length",trueModel.Length), new SqlParameter("@Width",trueModel.Width), new SqlParameter("@Height",trueModel.Height), new SqlParameter("@StatusId",trueModel.StatusId), new SqlParameter("@LastUpdateTime",trueModel.LastUpdateTime), new SqlParameter("@Operator",trueModel.Operator), new SqlParameter("@Remark",trueModel.Remark), new SqlParameter("@Name",trueModel.Name) ,new SqlParameter("@OrderNum",trueModel.OrderNum) }; try { _dataBase.Query("sp_OA_CargoSpace_Update", CommandType.StoredProcedure, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } /// /// 删除 /// /// /// public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model) { Model.OA_CargoSpace trueModel = model as Model.OA_CargoSpace; if (trueModel == null) { return false; } IList sqlParms = new List() { new SqlParameter("@Keyid",trueModel.Keyid) }; try { _dataBase.Query("sp_OA_CargoSpace_DeleteRow", CommandType.StoredProcedure, sqlParms.ToArray()); } catch (Exception ex) { throw ex; } return true; } /// /// 分页查询 /// /// /// /// public IEnumerable SelectModelPage(Infrastructure.Query.Query query, Infrastructure.Query.Pagination pagination) { throw new NotImplementedException(); } public IEnumerable getAllModel(Pagination pa, Guid FirmId, string CargoSpaceName, string WarehouseId) { string Condition = " where a.MemberId='" + FirmId + "'"; if (!string.IsNullOrEmpty(CargoSpaceName)) { Condition += "and a.Name like '%" + CargoSpaceName + "%'"; } if (!string.IsNullOrEmpty(WarehouseId)) { Condition += "and a.WarehouseId='" + WarehouseId + "'"; } string selectTarget = " a.*,b.WarehouseName AS WarehouseName ,c.Name AS CargoSpaceStatusName "; string fromSource = " dbo.OA_CargoSpace AS a LEFT JOIN dbo.OA_WarehouseInfo AS b ON a.WarehouseId=b.Keyid LEFT JOIN dbo.Sys_Dictionary AS c ON a.StatusId=c.Keyid " + Condition; return _dataBase.SelectModelPage(pa, selectTarget, fromSource, " a.OrderNum "); } /// /// 取得特定仓库下面的货位 /// /// /// /// public DataTable getAllCargoSpace(Guid FirmId, string WarehouseId) { string selectTarget = " * "; string fromSource = "OA_CargoSpace where Memberid='" + FirmId + "' and warehouseid='" + WarehouseId + "'"; return _dataBase.SelectModel(selectTarget, fromSource); } /// /// 取得所有货位-非分页 /// /// public DataTable getAllModelList(Guid FirmId) { string selectTarget = " * "; string fromSource = "OA_CargoSpace where Memberid='" + FirmId + "'"; return _dataBase.SelectModel(selectTarget, fromSource); } /// /// 单个查询 /// /// /// public IEnumerable SelectAllModel(Infrastructure.Query.Query query) { throw new NotImplementedException(); } public Model.OA_CargoSpace getSingleModel(string Keyid) { string Condition = "where a.Keyid ='" + Keyid + "'"; string selectTarget = " a.*,b.WarehouseName AS WarehouseName ,c.Name AS CargoSpaceStatusName "; string fromSource = " dbo.OA_CargoSpace AS a LEFT JOIN dbo.OA_WarehouseInfo AS b ON a.WarehouseId=b.Keyid LEFT JOIN dbo.Sys_Dictionary AS c ON a.StatusId=c.Keyid " + Condition; if (_dataBase.SelectModel(selectTarget, fromSource).Count > 0) { return _dataBase.SelectModel(selectTarget, fromSource)[0]; } else { return null; } } } }