public bool DeleteNotic(string type) { try { NHibernateTransaction.DBContext db = new NHibernateTransaction.DBContext(); var query = db.CurrentSession.CreateQuery("delete from NoticeInfo n where n.Type=:type"); query.SetParameter("type", type); int i = query.ExecuteUpdate(); return true; } catch { return false; } }
/// <summary> /// 機台準備工作項目 /// </summary> /// <param name="machineID"></param> /// <returns></returns> public List<PrepareProjectMaster_ppm_Info> GetPPM(string machineID) { try { string sql = @"select a.* from PrepareProjectMaster_ppm as a left join MachinePrepareItem_mpit on ppm_RecordID=mpit_PIPFID left join MachineMaster_mmt on mmt_cMachineID=mpit_cDCMPID where mmt_cMachineID=? order by ppm_iSeq"; using (NHibernateTransaction.DBContext db = new NHibernateTransaction.DBContext()) { var sqlQuery = db.CurrentSession.CreateSQLQuery(sql).AddEntity(typeof(PrepareProjectMaster_ppm_Info)).SetParameter(0, machineID); List<PrepareProjectMaster_ppm_Info> data = sqlQuery.List<PrepareProjectMaster_ppm_Info>().ToList(); return data; } } catch (Exception ex) { Common.General.DALoger.Error("查詢機台的準備工作項目出錯,機台編號:" + machineID, ex); return null; } }
/// <summary> /// 獲取未做的保養計劃 /// </summary> /// <param name="searchInfo"></param> /// <returns></returns> public List<Model.HBPMS.Master.MaintainPlan_mtp_Info> SearchRecord(Model.HBPMS.Master.MaintainPlan_mtp_Info searchInfo) { try { List<MaintainPlan_mtp_Info> listRes = new List<MaintainPlan_mtp_Info>(); using (NHibernateTransaction.DBContext db = new NHibernateTransaction.DBContext()) { var query = db.CurrentSession.QueryOver<MaintainPlan_mtp_Info>(); query.Where(d => d.mtp_lIsAtive == true); //Modify by jerryxiao on 2014-07-16 添加! if (!string.IsNullOrEmpty(searchInfo.mtp_cMachineModel)) { query.And(d => d.mtp_cMachineModel == searchInfo.mtp_cMachineModel); } listRes = query.List().ToList<MaintainPlan_mtp_Info>(); if (searchInfo.SearchDate.HasValue) { listRes = listRes.Where(d => (d.mtp_dBeginDate.Value.Date <= searchInfo.SearchDate.Value.Date && d.mtp_dExpireTime == null) || (d.mtp_dBeginDate.Value.Date <= searchInfo.SearchDate.Value.Date && d.mtp_dExpireTime.Value.Date != null && d.mtp_dExpireTime.Value.Date >= searchInfo.SearchDate.Value.Date) ).ToList(); } } return listRes; } catch { throw; } }
public List<CorrectRecord_ctr_Info> GetProjectCorrectQtyRecord(Guid scheduleProjectID) { List<CorrectRecord_ctr_Info> resultList = null; try { string sql = @"select st.* from CorrectRecord_ctr st left join PrintProject_ppj pp on pp.[ppj_RecordID] =st.ctr_PPJID and pp.ppj_lActiveRecord='1' left join ScheduleProjList_swl sw on sw.[swl_RecordID] ==pp. ppj_SWLID and sw.swl_lSync='0' where sw.[swl_RecordID]=?"; NHibernateTransaction.DBContext trans = new NHibernateTransaction.DBContext(); var query = trans.CurrentSession.CreateSQLQuery(sql); query.SetParameter(0, scheduleProjectID.ToString()); query.AddEntity(typeof(CorrectRecord_ctr_Info)); resultList = query.List<CorrectRecord_ctr_Info>().ToList(); } catch (Exception ex) { Common.General.DALoger.Error(ex); // throw; } return resultList; }
List<ProductCollect_Info> IProductCollectBL.GetShiftProjectSummary(ProductCollect_Info oInfo) { List<ProductCollect_Info> resultList = new List<ProductCollect_Info>(); try { NHibernateTransaction.DBContext trans = new NHibernateTransaction.DBContext(); ShiftTypeMaster_stm_Info shiftType = (from stm in trans.CurrentSession.QueryOver<ShiftTypeMaster_stm_Info>() where stm.stm_iRecordID == oInfo.ShiftTypeID select stm).SingleOrDefault<ShiftTypeMaster_stm_Info>(); DateTime nextDate = oInfo.SearchDate.AddDays(1); var oResult = from spl in trans.CurrentSession.QueryOver<ShiftProjList_spl_Info>().Where(d => d.spl_dBeginTime >= oInfo.SearchDate && d.spl_dBeginTime < nextDate).List() join ppj in trans.CurrentSession.QueryOver<PrintProject_ppj_Info>().List() on spl.spl_PPJID equals ppj.ppj_RecordID join swl in trans.CurrentSession.QueryOver<ScheduleProjList_swl_Info>().List() on ppj.ppj_SWLID equals swl.swl_RecordID join sifo in trans.CurrentSession.QueryOver<ShiftInfo_sifo_Info>().List() on spl.spl_SIFOID equals sifo.sifo_RecordID orderby spl.spl_dBeginTime select new ProductCollect_Info { SONO = swl.swl_cSONO, ItemNO = swl.swl_cItemNO, ProdName = swl.swl_cProdName, ItemName = swl.swl_cItemName, Edition=swl.swl_cEdition, SheetProdQty=swl.swl_iSheetProdQty, PlanProdQty=swl.swl_iPlanProdQty, ActualProdNum=spl.spl_iQTY, CountDefectiveQty=spl.spl_iDefectiveQty, CountWastNum=spl.spl_iWastQTY, QualifiedNum=spl.spl_iQTY-spl.spl_iWastQTY-spl.spl_iDefectiveQty, BeginTime = spl.spl_dBeginTime, EndTime = spl.spl_dEndTime, ProjRunTime = spl.spl_iRunTime, StopTime = spl.spl_iStopTime, ActualPrepairTime = spl.spl_iPrepairTime, NextGroup=swl.swl_cNextGroup, NextArea=swl.swl_cNextArea, ShiftTypeID=sifo.sifo_iSTMID, ProdDate = sifo.sifo_dProdDate, MachineNO = swl.swl_cMachineNO }; if (shiftType == null) { oResult = oResult.Where(d => d.BeginTime >= oInfo.SearchDate.Date && d.EndTime == null ? true : d.EndTime <= oInfo.SearchDate.Date.AddDays(1)); } else { oResult = oResult.Where(d => d.ShiftTypeID == oInfo.ShiftTypeID); } oResult = oResult.Where(d => d.ProdDate == oInfo.SearchDate); oResult = oResult.Where(d => d.MachineNO == oInfo.MachineNO); if (oResult != null) { int indexNum = 1; foreach (ProductCollect_Info oEarchResult in oResult) { oEarchResult.Index = indexNum; resultList.Add(oEarchResult); indexNum++; } } return resultList; } catch (Exception ex) { mLogger.Error(ex); } return resultList; }