using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMAPP.BLL; using QMAPP.Entity; using QMAPP.FJC.DAL.Andon; using QMAPP.MD.Entity; using QMFrameWork.Log; using QMFrameWork.Data; using QMAPP.MD.DAL; namespace QMAPP.MD.BLL { /// /// 作 用:班组成员 /// 作 者:周晓东 /// 编写日期:2017年11月21日 /// public class ScheduleBLL : BaseBLL { #region 获取信息 /// /// 获取信息 /// /// 条件 /// 信息 public DataResult Get(ScheduleEntity model) { DataResult result = new DataResult(); try { result.Result = new ScheduleDAL().Get(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } public DataResult GetEntity(ScheduleEntity model) { DataResult result = new DataResult(); try { result.Result = new ScheduleDAL().GetEntity(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 获取列表 /// /// 获取列表 /// /// 条件 /// 数据页 /// 数据页 public DataResult GetList(ScheduleEntity condition, DataPage page) { DataResult result = new DataResult(); try { //获取班组信息列表 DataPage dataPage = new ScheduleDAL().GetList(condition, page); #region List InfoList = dataPage.Result as List; var shiftList = new FJC.DAL.Basic.ProduceShiftDAL().GetList(new QMAPP.FJC.Entity.Basic.ProduceShift { PRODUCELINE="All" }); var teamList = new TeamBLL().GetAllTeam(new Team()); var factoryList = new FactoryBLL().GetFactoryList(new Factory()); foreach (ScheduleEntity m in InfoList) { //班次 var shift = shiftList.FirstOrDefault(x => x.PRODUCESHIFTTCODE == m.SHIFT_CODE.Trim());// && x.FACTORY_CODE == m.FACTORY_CODE); if (shift != null) m.SHIFT_NAME = shift.PRODUCESHIFTNAME; //班组 var team = teamList.FirstOrDefault(x => x.TEAM_CODE == m.TEAM_CODE.Trim() && x.FACTORY_CODE == m.FACTORY_CODE); if (team != null) m.TEAM_NAME = team.TEAM_NAME; //工厂 var factory = factoryList.Result.FirstOrDefault(x => x.FACTORY_CODE == m.FACTORY_CODE.Trim()); if (factory != null) m.FACTORY_NAME = factory.FACTORY_NAME; } #endregion result.Result = dataPage; } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion // /// 获取全部用户 /// /// 获取条件 /// 用户信息列表 public List GetAllSchedule(ScheduleEntity condition) { return new ScheduleDAL().GetAllSchedule(condition); } #region 插入信息 /// /// 插入信息(单表) /// /// 信息 /// 插入行数 public DataResult Insert(ScheduleEntity model) { DataResult result = new DataResult(); //基本信息 model.PID = Guid.NewGuid().ToString(); model.CREATEUSER = this.LoginUser.UserID; model.CREATEDATE = DateTime.Now; model.UPDATEUSER = model.CREATEUSER; model.UPDATEDATE = model.CREATEDATE; try { //if (ExistsTeam(model) == true) //{ // result.IsSuccess = false; // result.Msg = Resource.TeamCodeIsHave; // return result; //} result.Result = new ScheduleDAL().Insert(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 更新信息 /// /// 更新信息 /// /// /// 更新行数 public DataResult Update(ScheduleEntity model) { DataResult result = new DataResult(); //基本信息 model.UPDATEUSER = this.LoginUser.UserID; //model.UPDATEDATE = DateTime.Now; try { //if (ExistsTeam(model) == true) //{ // result.IsSuccess = false; // result.Msg = Resource.TeamCodeIsHave; // return result; //} result.Result = new ScheduleDAL().Update(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 删除 /// /// 删除信息 /// /// /// 删除个数 public DataResult Delete(string strs) { DataResult result = new DataResult(); string[] list = strs.Split(":".ToCharArray()); try { //foreach (string str in list) //{ // if (IsUsing(new ScheduleEntity { PID = str }) == true) // { // result.IsSuccess = false; // result.Msg = Resource.WorkTeamIsUsing; // return result; // } //} foreach (string str in list) { result.Result += this.DeleteWorkTeam(new ScheduleEntity { PID = str }); } } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } /// /// 删除信息 /// /// 信息 /// 删除个数 public int DeleteWorkTeam(ScheduleEntity model) { int count = 0; try { count = new ScheduleDAL().Delete(model); return count; } catch (Exception ex) { throw ex; } } #endregion } }