public MachinePrepareItem_mpit_Info() { mpit_MPITID = Guid.Empty; mpit_PIPFID = Guid.Empty; mpit_cDCMPID = string.Empty; mpit_lIsDeleted = true; mpit_dUpdateTime = DateTime.MinValue; ppmSeq = 0; PrepareProjectItem = new PrepareProjectMaster_ppm_Info(); MachineItem = new Model.HBPMS.Master.MachineMaster_mmt_Info(); }
/// <summary> /// 刪除記錄 /// </summary> /// <param name="KeyObject"></param> /// <returns></returns> /// <remarks>Create By Leothlink TonyWu On 01/02/2013</remarks> public bool DeleteRecord(Model.IModel.IModelObject KeyObject) { bool isSuccess = false; PrepareProjectMaster_ppm_Info info = new PrepareProjectMaster_ppm_Info(); info = KeyObject as PrepareProjectMaster_ppm_Info; using (MainDBDataContext db = new MainDBDataContext()) { PrepareProjectMaster_ppm delTab = db.PrepareProjectMaster_ppm.SingleOrDefault(t => t.ppm_RecordID == info.ppm_RecordID); if (delTab != null) { db.PrepareProjectMaster_ppm.DeleteOnSubmit(delTab); db.SubmitChanges(); isSuccess = true; } } return isSuccess; }
/// <summary> /// 顯示記錄 /// </summary> /// <param name="KeyObject"></param> /// <returns></returns> /// <remarks>Create By Leothlink TonyWu On 01/02/2013</remarks> public PrepareProjectMaster_ppm_Info DisplayRecord(Model.IModel.IModelObject KeyObject) { PrepareProjectMaster_ppm_Info info = new PrepareProjectMaster_ppm_Info(); try { using (MainDBDataContext db = new MainDBDataContext()) { PrepareProjectMaster_ppm disTab = db.PrepareProjectMaster_ppm.SingleOrDefault(t => t.ppm_RecordID == ((KeyObject) as PrepareProjectMaster_ppm_Info).ppm_RecordID); if (disTab != null) { info = Common.General.CopyObjectValue<PrepareProjectMaster_ppm, PrepareProjectMaster_ppm_Info>(disTab); } } } catch (Exception Ex) { throw Ex; } return info; }
public List<PrepareProjectMaster_ppm_Info> GetAllProjects() { //throw new NotImplementedException(); List<PrepareProjectMaster_ppm_Info> list = new List<PrepareProjectMaster_ppm_Info>(); PrepareProjectMaster_ppm_Info info = new PrepareProjectMaster_ppm_Info(); //info = searchCondition as PrepareProjectMaster_ppm_Info; StringBuilder sqlString = new StringBuilder(); sqlString.AppendLine("SELECT TOP " + Common.DefineConstantValue.ListRecordMaxCount.ToString()); sqlString.AppendLine("*,isnull(cmt1.cmt_cRemark,'') as ppm_cMachineTypeName,isnull(cmt2.cmt_cRemark,'') as ppm_cItemTypeName"); sqlString.AppendLine("FROM dbo.PrepareProjectMaster_ppm"); sqlString.AppendLine("LEFT JOIN CodeMaster_cmt as cmt1"); sqlString.AppendLine("on ppm_cMachineType=cmt1.cmt_cValue and cmt1.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt1.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_MACHINEMODEL + "'"); sqlString.AppendLine("LEFT JOIN CodeMaster_cmt as cmt2"); sqlString.AppendLine("on ppm_cItemType=cmt2.cmt_cValue and cmt2.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt2.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_PREPARETYPE + "'"); sqlString.AppendLine("WHERE 1=1"); sqlString.AppendLine(" order by ppm_iSeq"); IEnumerable<PrepareProjectMaster_ppm_Info> infos = null; try { using (MainDBDataContext db = new MainDBDataContext()) { infos = db.ExecuteQuery<PrepareProjectMaster_ppm_Info>(sqlString.ToString(), new object[] { }); if (infos != null) { list = infos.ToList<PrepareProjectMaster_ppm_Info>(); } } } catch (Exception Ex) { throw Ex; } return list; }
/// <summary> /// 按條件搜索數據 /// </summary> /// <param name="info"></param> /// <returns></returns> /// <remarks>Create By Leothlink TonyWu On 01/02/2013</remarks> public List<PrepareProjectMaster_ppm_Info> FindRecord(PrepareProjectMaster_ppm_Info info) { return SearchRecords(info); }
/// <summary> /// 更新記錄 /// </summary> /// <param name="infoObject"></param> /// <returns></returns> /// <remarks>Create By Leothlink TonyWu On 01/02/2013</remarks> public bool UpdateRecord(PrepareProjectMaster_ppm_Info infoObject) { bool isSuccess = false; try { using (MainDBDataContext hbpmsDB = new MainDBDataContext()) { PrepareProjectMaster_ppm query = hbpmsDB.PrepareProjectMaster_ppm.SingleOrDefault(t => t.ppm_RecordID == infoObject.ppm_RecordID); if (query != null) { query.ppm_cMachineType = infoObject.ppm_cMachineType; query.ppm_cItemType = infoObject.ppm_cItemType; query.ppm_cItemName = infoObject.ppm_cItemName; query.ppm_iSeq = infoObject.ppm_iSeq; query.ppm_lIsParallelable = infoObject.ppm_lIsParallelable; query.ppm_iPredictedTime = infoObject.ppm_iPredictedTime; query.ppm_lIsActive = infoObject.ppm_lIsActive; query.ppm_cLast = infoObject.ppm_cLast; query.ppm_dLastDate = DateTime.Now; hbpmsDB.SubmitChanges(); } } isSuccess = true; } catch (Exception ex) { Common.General.DALoger.Error("PrepareProjectMasterDA.UpdateRecord", ex); throw ex; } return isSuccess; }
/// <summary> /// 搜索多條記錄 /// </summary> /// <param name="searchCondition"></param> /// <returns></returns> /// <remarks>Create By Leothlink TonyWu On 01/02/2013</remarks> public List<PrepareProjectMaster_ppm_Info> SearchRecords(Model.IModel.IModelObject searchCondition) { List<PrepareProjectMaster_ppm_Info> list = new List<PrepareProjectMaster_ppm_Info>(); PrepareProjectMaster_ppm_Info info = new PrepareProjectMaster_ppm_Info(); info = searchCondition as PrepareProjectMaster_ppm_Info; StringBuilder sqlString = new StringBuilder(); sqlString.AppendLine("SELECT TOP " + Common.DefineConstantValue.ListRecordMaxCount.ToString()); sqlString.AppendLine("*,cmt1.cmt_cRemark as ppm_cMachineTypeName,cmt2.cmt_cRemark as ppm_cItemTypeName"); sqlString.AppendLine("FROM dbo.PrepareProjectMaster_ppm"); sqlString.AppendLine("LEFT JOIN CodeMaster_cmt as cmt1"); sqlString.AppendLine("on ppm_cMachineType=cmt1.cmt_cValue and cmt1.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt1.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_MACHINEMODEL + "'"); sqlString.AppendLine("LEFT JOIN CodeMaster_cmt as cmt2"); sqlString.AppendLine("on ppm_cItemType=cmt2.cmt_cValue and cmt2.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt2.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_PREPARETYPE + "'"); sqlString.AppendLine("WHERE 1=1"); if (info.ppm_cItemCode != "") { sqlString.AppendLine("AND ppm_cItemCode='" + info.ppm_cItemCode + "'"); } if (info.ppm_cMachineType != "") { sqlString.AppendLine("AND ppm_cMachineType='" + info.ppm_cMachineType + "'"); } if (info.ppm_cItemType != "") { sqlString.AppendLine("AND ppm_cItemType='" + info.ppm_cItemType + "'"); } if (info.ppm_cItemName != "") { sqlString.AppendLine("AND ppm_cItemName Like N'" + info.ppm_cItemName.ToString().Replace("*", "%").Replace("?", "_") + "'"); if (info.ppm_cItemName.ToString().Contains("*") || info.ppm_cItemName.ToString().Contains("?")) { sqlString.AppendLine("AND ppm_cItemName Like N'" + info.ppm_cItemName.ToString().Replace("*", "%").Replace("?", "_") + "'"); } else { sqlString.AppendLine("AND ppm_cItemName LIKE N'%" + info.ppm_cItemName + "%'"); } } if (info.ppm_iPredictedTime != 0) { sqlString.AppendLine("AND ppm_iPredictedTime=" + info.ppm_iPredictedTime.ToString()); } sqlString.AppendLine(" order by ppm_iSeq"); IEnumerable<PrepareProjectMaster_ppm_Info> infos = null; try { using (MainDBDataContext db = new MainDBDataContext()) { infos = db.ExecuteQuery<PrepareProjectMaster_ppm_Info>(sqlString.ToString(), new object[] { }); if (infos != null) { list = infos.ToList<PrepareProjectMaster_ppm_Info>(); } } } catch (Exception Ex) { throw Ex; } return list; }
/// <summary> /// 檢查是否存在指定條件的記錄 /// </summary> /// <param name="KeyObject"></param> /// <returns></returns> /// <remarks>Create By Leothlink TonyWu On 01/02/2013</remarks> public bool IsExistRecord(object KeyObject) { PrepareProjectMaster_ppm_Info info = new PrepareProjectMaster_ppm_Info(); info = KeyObject as PrepareProjectMaster_ppm_Info; using (MainDBDataContext db = new MainDBDataContext()) { PrepareProjectMaster_ppm query = db.PrepareProjectMaster_ppm.SingleOrDefault(t => t.ppm_cItemCode == info.ppm_cItemCode); if (query != null) { return true; } } return false; }
/// <summary> /// 插入記錄 /// </summary> /// <param name="infoObject"></param> /// <returns></returns> /// <remarks>Create By Leothlink TonyWu On 01/02/2013</remarks> public bool InsertRecord(PrepareProjectMaster_ppm_Info infoObject) { bool isSuccess = false; PrepareProjectMaster_ppm_Info info = new PrepareProjectMaster_ppm_Info(); using (MainDBDataContext db = new MainDBDataContext()) { PrepareProjectMaster_ppm ppm = Common.General.CopyObjectValue<PrepareProjectMaster_ppm_Info, PrepareProjectMaster_ppm>(infoObject); PrepareProjectMaster_ppm_Info lastPPM = GetRecord_Last(); if (lastPPM != null) { ppm.ppm_iSeq = lastPPM.ppm_iSeq + 1; } else { ppm.ppm_iSeq = 1; } db.PrepareProjectMaster_ppm.InsertOnSubmit(ppm); db.SubmitChanges(); isSuccess = true; } return isSuccess; }
public PrepareProjectMaster_ppm_Info GetPPItems(Guid PIPFID) { PrepareProjectMaster_ppm_Info info = new PrepareProjectMaster_ppm_Info(); StringBuilder sqlString = new StringBuilder(); sqlString.AppendLine("SELECT TOP 1 "); sqlString.AppendLine("*,isnull(cmt1.cmt_cRemark,'') as ppm_cMachineTypeName,isnull(cmt2.cmt_cRemark,'') as ppm_cItemTypeName"); sqlString.AppendLine("FROM dbo.PrepareProjectMaster_ppm"); sqlString.AppendLine("LEFT JOIN CodeMaster_cmt as cmt1"); sqlString.AppendLine("on ppm_cMachineType=cmt1.cmt_cValue and cmt1.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt1.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_MACHINEMODEL + "'"); sqlString.AppendLine("LEFT JOIN CodeMaster_cmt as cmt2"); sqlString.AppendLine("on ppm_cItemType=cmt2.cmt_cValue and cmt2.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt2.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_PREPARETYPE + "'"); sqlString.AppendLine("WHERE ppm_RecordID='" + PIPFID + "'"); sqlString.AppendLine(" order by ppm_iSeq"); IEnumerable<PrepareProjectMaster_ppm_Info> infos = null; try { using (MainDBDataContext db = new MainDBDataContext()) { infos = db.ExecuteQuery<PrepareProjectMaster_ppm_Info>(sqlString.ToString(), new object[] { }); if (infos != null) { info = infos.ToList<PrepareProjectMaster_ppm_Info>().FirstOrDefault(); ; } } } catch (Exception Ex) { throw Ex; } return info; }
public Model.General.ReturnValueInfo Save(Model.IModel.IModelObject itemEntity, Common.DefineConstantValue.EditStateEnum EditMode) { Model.General.ReturnValueInfo returnValue = new Model.General.ReturnValueInfo(); PrepareProjectMaster_ppm_Info info = new PrepareProjectMaster_ppm_Info(); returnValue.messageText = ""; info = itemEntity as PrepareProjectMaster_ppm_Info; try { switch (EditMode) { case Common.DefineConstantValue.EditStateEnum.OE_Insert: bool isExist = false; isExist = _prepareProjectMasterDA.IsExistRecord(info); if (!isExist) { returnValue.boolValue = _prepareProjectMasterDA.InsertRecord(info); _prepareProjectMasterDA.RepairRepeatSeq(); } else { returnValue.boolValue = false; returnValue.messageText = "準備項目編碼重复!"; } break; case Common.DefineConstantValue.EditStateEnum.OE_Update: returnValue.boolValue = _prepareProjectMasterDA.UpdateRecord(info); _prepareProjectMasterDA.RepairRepeatSeq(); if (returnValue.boolValue) { returnValue.messageText = "更新数据时出错!"; } break; case Common.DefineConstantValue.EditStateEnum.OE_Delete: returnValue.boolValue = _prepareProjectMasterDA.DeleteRecord(info); if (returnValue.boolValue) { returnValue.messageText = "删除数据时出错!"; } break; default: break; } } catch (Exception Ex) { throw Ex; } return returnValue; }
public List<PrepareProjectMaster_ppm_Info> FindRecord(PrepareProjectMaster_ppm_Info info) { List<PrepareProjectMaster_ppm_Info> returnList = new List<PrepareProjectMaster_ppm_Info>(); try { returnList = _prepareProjectMasterDA.FindRecord(info); } catch (Exception Ex) { throw Ex; } return returnList; }
/// <summary> /// 初始化數據 /// </summary> private void BindingView() { try { this.Cursor = Cursors.WaitCursor; Model.HBPMS.Management.RunningManagement.PrepareProjectMaster_ppm_Info prepareItem = new Model.HBPMS.Management.RunningManagement.PrepareProjectMaster_ppm_Info(); prepareItem.ppm_cMachineType = cbxPrinterType.SelectedValue.ToString(); var prepareProjects = _prepareProjectMasterBL.FindRecord(prepareItem); prepareProjects.ForEach(d => d.ppm_iPredictedTime = decimal.Parse(d.ppm_iPredictedTime.ToString("N1"))); this.lvInfo.BeginUpdate(); lvInfo.SetDataSource<Model.HBPMS.Management.RunningManagement.PrepareProjectMaster_ppm_Info>(prepareProjects); this.lvInfo.EndUpdate(); //ConvertMachineCodeToRemark(); } catch (Exception ex) { this.ShowWarningMessage("綁定數據失敗,失敗原因:" + ex.Message); } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// 初始化當前模式 /// </summary> private void InitModelInfo() { if (BaseParam != null) { _currentItem = BaseParam as Model.HBPMS.Management.RunningManagement.PrepareProjectMaster_ppm_Info; } else { _currentItem = new Model.HBPMS.Management.RunningManagement.PrepareProjectMaster_ppm_Info(); } DisplayInfo(_currentItem); }