public MachineStopReasonProfile_msrp_Info() { msrp_iMSRPID=int.MinValue; msrp_iSRPFID=int.MinValue; msrp_cMachineID=string.Empty; msrp_lIsDeleted=false; msrp_dUpdateTime = DateTime.MinValue; StopReasonItem = new StopReasonMaster_srm_Info(); MachineItem = new Model.HBPMS.Master.MachineMaster_mmt_Info(); mtrSeq = 0; }
ReturnValueInfo DeleteRecord(StopReasonMaster_srm_Info reasonInfo) { ReturnValueInfo rvInfo = new ReturnValueInfo(); try { if (reasonInfo == null) { rvInfo.messageText = "条件为空。"; rvInfo.isError = true; return rvInfo; } using (MainDBDataContext db = new MainDBDataContext()) { StopReasonMaster_srm srmInfo = db.StopReasonMaster_srm.FirstOrDefault(x => x.srm_iRecordID == reasonInfo.srm_iRecordID); if (srmInfo == null) { rvInfo.isError = true; rvInfo.messageText = "没有历史记录。"; return rvInfo; } db.StopReasonMaster_srm.DeleteOnSubmit(srmInfo); db.SubmitChanges(); rvInfo.boolValue = true; } } catch (Exception ex) { rvInfo.messageText = ex.Message; rvInfo.isError = true; } return rvInfo; }
List<StopReasonMaster_srm_Info> SearchRecord(StopReasonMaster_srm_Info searchInfo) { List<StopReasonMaster_srm_Info> listReturn = new List<StopReasonMaster_srm_Info>(); try { StopReasonMaster_srm_Info srmSearchInfo = searchInfo as StopReasonMaster_srm_Info; StringBuilder sbSQL = new StringBuilder(); sbSQL.AppendLine("SELECT TOP " + Common.DefineConstantValue.ListRecordMaxCount.ToString()); sbSQL.AppendLine("cmt2.cmt_cRemark as srm_cMachineTypeName,cmt1.cmt_cRemark as srm_cReasonTypeName,cmt3.cmt_cRemark as cPlanTypeDec ,*"); sbSQL.AppendLine("FROM dbo.StopReasonMaster_srm"); sbSQL.AppendLine("left join CodeMaster_cmt as cmt2"); sbSQL.AppendLine("on cmt2.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt2.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_MACHINEMODEL + "' and cmt2.cmt_cValue=srm_cMachineType"); sbSQL.AppendLine("left join CodeMaster_cmt as cmt1"); sbSQL.AppendLine("on cmt1.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt1.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_STOPREASONTYPE + "' and cmt1.cmt_cValue=srm_cReasonType"); sbSQL.AppendLine("left join CodeMaster_cmt as cmt3"); sbSQL.AppendLine("on cmt3.cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt3.cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_PLANTYPE + "' and cmt3.cmt_cValue=srm_cPlanType"); sbSQL.AppendLine(); sbSQL.AppendLine(); sbSQL.AppendLine("WHERE 1=1"); string strSQL = sbSQL.ToString(); if (srmSearchInfo != null) { #region WhereSQL StringBuilder sbWhere = new StringBuilder(); if (!string.IsNullOrEmpty(srmSearchInfo.srm_cReasonCode)) { sbWhere.AppendLine("AND [srm_cReasonCode] ='" + srmSearchInfo.srm_cReasonCode + "'"); } if (!string.IsNullOrEmpty(srmSearchInfo.srm_cMachineType)) { sbWhere.AppendLine("AND [srm_cMachineType] ='" + srmSearchInfo.srm_cMachineType + "' "); } if (!string.IsNullOrEmpty(srmSearchInfo.srm_cReasonType)) { sbWhere.AppendLine("AND [srm_cReasonType] ='" + srmSearchInfo.srm_cReasonType + "' "); } if (!string.IsNullOrEmpty(srmSearchInfo.srm_cReasonName)) { sbWhere.AppendLine("AND [srm_cReasonName] ='" + srmSearchInfo.srm_cReasonName + "' "); } if (srmSearchInfo.srm_iSeq > 0) { sbWhere.AppendLine("AND [srm_iSeq] =" + srmSearchInfo.srm_iSeq + " "); } if (srmSearchInfo.srm_iPredictedTime > 0) { sbWhere.AppendLine("AND [srm_iPredictedTime] =" + srmSearchInfo.srm_iPredictedTime + " "); } sbWhere.AppendLine("AND [srm_lIsAtive] =" + (srmSearchInfo.srm_lIsAtive ? "1" : "0") + " "); if (!string.IsNullOrEmpty(sbWhere.ToString())) { strSQL += sbWhere.ToString(); } strSQL += "order by srm_iSeq"; #endregion } IEnumerable<StopReasonMaster_srm_Info> infos = null; using (MainDBDataContext db = new MainDBDataContext()) { infos = db.ExecuteQuery<StopReasonMaster_srm_Info>(strSQL, new object[] { }); if (infos != null) { listReturn = infos.ToList(); } } } catch (Exception ex) { throw ex; } return listReturn; }
public List<StopReasonMaster_srm_Info> SearchRecords(StopReasonMaster_srm_Info searchCondition) { return SearchRecord(searchCondition); }
public Model.General.ReturnValueInfo UpdateRecord(StopReasonMaster_srm_Info reasonInfo) { ReturnValueInfo rvInfo = new ReturnValueInfo(); try { if (reasonInfo == null) { rvInfo.messageText = "条件为空。"; rvInfo.isError = true; return rvInfo; } using (MainDBDataContext db = new MainDBDataContext()) { StopReasonMaster_srm srmInfo = db.StopReasonMaster_srm.FirstOrDefault(x => x.srm_iRecordID == reasonInfo.srm_iRecordID); if (srmInfo != null) { srmInfo.srm_cLast = reasonInfo.srm_cLast; srmInfo.srm_cMachineType = reasonInfo.srm_cMachineType; srmInfo.srm_cReasonCode = reasonInfo.srm_cReasonCode; srmInfo.srm_cReasonName = reasonInfo.srm_cReasonName; srmInfo.srm_cReasonType = reasonInfo.srm_cReasonType; srmInfo.srm_dLastDate = reasonInfo.srm_dLastDate; srmInfo.srm_iPredictedTime = reasonInfo.srm_iPredictedTime; srmInfo.srm_iSeq = reasonInfo.srm_iSeq; srmInfo.srm_lIsAtive = reasonInfo.srm_lIsAtive; srmInfo.srm_lIsNoneTask = reasonInfo.srm_lIsNoneTask; srmInfo.srm_lIsParallelable = reasonInfo.srm_lIsParallelable; srmInfo.srm_cPlanType = reasonInfo.srm_cPlanType; db.SubmitChanges(); rvInfo.boolValue = true; } else { rvInfo.messageText = "无合适条件的记录。"; rvInfo.isError = true; return rvInfo; } } } catch (Exception ex) { rvInfo.messageText = ex.Message; rvInfo.isError = true; } return rvInfo; }
/// <summary> /// 停機原因主檔 /// </summary> /// <returns></returns> public List<StopReasonMaster_srm_Info> GetStopReasonMaster(string machineID) { try { List<StopReasonMaster_srm_Info> list = new List<StopReasonMaster_srm_Info>(); StringBuilder strSql = new StringBuilder(); strSql.AppendLine("select "); strSql.AppendLine("srm_iRecordID,srm_cReasonCode,srm_cMachineType,srm_cReasonType,srm_cPlanType,srm_cReasonName,srm_iSeq,srm_lIsParallelable,srm_iPredictedTime,srm_lIsAtive,srm_lIsNoneTask,srm_cAdd,srm_dAddDate,srm_cLast,srm_dLastDate "); strSql.AppendLine("from MachineStopReasonProfile_msrp "); strSql.AppendLine("left join StopReasonMaster_srm on msrp_iSRPFID=srm_iRecordID "); strSql.AppendLine("where msrp_cMachineID='" + machineID+"' "); strSql.AppendLine("and msrp_lIsDeleted=0"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { StopReasonMaster_srm_Info model = new StopReasonMaster_srm_Info(); if (sdr["srm_iRecordID"] != null && sdr["srm_iRecordID"].ToString() != "") { model.srm_iRecordID = int.Parse(sdr["srm_iRecordID"].ToString()); } if (sdr["srm_cReasonCode"] != null && sdr["srm_cReasonCode"].ToString() != "") { model.srm_cReasonCode = sdr["srm_cReasonCode"].ToString(); } if (sdr["srm_cMachineType"] != null && sdr["srm_cMachineType"].ToString() != "") { model.srm_cMachineType = sdr["srm_cMachineType"].ToString(); } if (sdr["srm_cReasonType"] != null && sdr["srm_cReasonType"].ToString() != "") { model.srm_cReasonType = sdr["srm_cReasonType"].ToString(); } if (sdr["srm_cPlanType"] != null && sdr["srm_cPlanType"].ToString() != "") { model.srm_cPlanType = sdr["srm_cPlanType"].ToString(); } if (sdr["srm_cReasonName"] != null && sdr["srm_cReasonName"].ToString() != "") { model.srm_cReasonName = sdr["srm_cReasonName"].ToString(); } if (sdr["srm_iSeq"] != null && sdr["srm_iSeq"].ToString() != "") { model.srm_iSeq = int.Parse(sdr["srm_iSeq"].ToString()); } if (sdr["srm_lIsParallelable"] != null && sdr["srm_lIsParallelable"].ToString() != "") { if ((sdr["srm_lIsParallelable"].ToString() == "1") || (sdr["srm_lIsParallelable"].ToString().ToLower() == "true")) { model.srm_lIsParallelable = true; } else { model.srm_lIsParallelable = false; } } if (sdr["srm_iPredictedTime"] != null && sdr["srm_iPredictedTime"].ToString() != "") { model.srm_iPredictedTime = int.Parse(sdr["srm_iPredictedTime"].ToString()); } if (sdr["srm_lIsAtive"] != null && sdr["srm_lIsAtive"].ToString() != "") { if ((sdr["srm_lIsAtive"].ToString() == "1") || (sdr["srm_lIsAtive"].ToString().ToLower() == "true")) { model.srm_lIsAtive = true; } else { model.srm_lIsAtive = false; } } if (sdr["srm_lIsNoneTask"] != null && sdr["srm_lIsNoneTask"].ToString() != "") { if ((sdr["srm_lIsNoneTask"].ToString() == "1") || (sdr["srm_lIsNoneTask"].ToString().ToLower() == "true")) { model.srm_lIsNoneTask = true; } else { model.srm_lIsNoneTask = false; } } if (sdr["srm_cAdd"] != null && sdr["srm_cAdd"].ToString() != "") { model.srm_cAdd = sdr["srm_cAdd"].ToString(); } if (sdr["srm_dAddDate"] != null && sdr["srm_dAddDate"].ToString() != "") { model.srm_dAddDate = DateTime.Parse(sdr["srm_dAddDate"].ToString()); } if (sdr["srm_cLast"] != null && sdr["srm_cLast"].ToString() != "") { model.srm_cLast = sdr["srm_cLast"].ToString(); } if (sdr["srm_dLastDate"] != null && sdr["srm_dLastDate"].ToString() != "") { model.srm_dLastDate = DateTime.Parse(sdr["srm_dLastDate"].ToString()); } list.Add(model); } } return list; } catch (Exception ex) { throw ex; } }
public Model.General.ReturnValueInfo InsertRecord(StopReasonMaster_srm_Info reasonInfo) { ReturnValueInfo rvInfo = new ReturnValueInfo(); try { if (reasonInfo == null) { rvInfo.messageText = "条件为空。"; rvInfo.isError = true; return rvInfo; } using (MainDBDataContext db = new MainDBDataContext()) { StopReasonMaster_srm srmInfo = Common.General.CopyObjectValue<StopReasonMaster_srm_Info, StopReasonMaster_srm>(reasonInfo); StopReasonMaster_srm_Info srmLast = GetRecord_Last(srmInfo.srm_cMachineType); int iSeq = 0; if (srmLast != null) { iSeq = srmLast.srm_iSeq + 1; } srmInfo.srm_iSeq = iSeq; if (srmInfo == null) { rvInfo.isError = true; rvInfo.messageText = "实体转换失败。"; } db.StopReasonMaster_srm.InsertOnSubmit(srmInfo); db.SubmitChanges(); rvInfo.boolValue = true; } } catch (Exception ex) { rvInfo.messageText = ex.Message; rvInfo.isError = true; } return rvInfo; }
private void BindStopReasons() { try { //IList<IDomainObject> list = manager.StopReasonProfileGetAll(); ; IStopReasonBL StopReasonMaster = MasterBLLFactory.GetBLL<IStopReasonBL>(MasterBLLFactory.StopReasonMaster); StopReasonMaster_srm_Info cond = new StopReasonMaster_srm_Info(); List<StopReasonMaster_srm_Info> listStopReason = StopReasonMaster.SearchRecord(cond); FillStopReasonData(listStopReason, lvStopReasonsMain, true); } catch (Exception ex) { ShowErrorMessage(ex); } }
private void lvMachinesMain_SelectedIndexChanged(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; //int machineType = -1; if (lvMachinesMain.SelectedItems.Count > 0) { if (CheckIsSave()) { ShowDialogSaveData(); } MachineMaster_mmt_Info dcm = lvMachinesMain.SelectedItems[0].Tag as MachineMaster_mmt_Info; mSelectedMachineID = dcm.mmt_cMachineID; //machineType = dcm.MachineType; IStopReasonBL StopReasonMaster = new StopReasonBL(); StopReasonMaster_srm_Info cond = new StopReasonMaster_srm_Info(); cond.srm_cMachineType = dcm.mmt_cMachineType; List<StopReasonMaster_srm_Info> stopReasons = StopReasonMaster.SearchRecord(cond); //List<IDomainObject> stopReasons; //stopReasons = GetStopReasonAll(machineType); //IList<IDomainObject> machineStopReasonProfile = manager.GetMachineStopReasonProfileByMachineID(DCMPID); IList<MachineStopReasonProfile_msrp_Info> machineStopReasonProfile = _MachineStopReasonBL.GetStopReasonByMachine(mSelectedMachineID); //m_MachineStopReasonProfile = ToList<MachineStopReasonProfile>(machineStopReasonProfile); if (machineStopReasonProfile != null) { m_MachineStopReasonProfile = machineStopReasonProfile.ToList(); } else { m_MachineStopReasonProfile = new List<MachineStopReasonProfile_msrp_Info>(); } List<StopReasonMaster_srm_Info> selectedStopReasons = new List<StopReasonMaster_srm_Info>(); List<StopReasonMaster_srm_Info> unSelectedStopReasons = new List<StopReasonMaster_srm_Info>(); foreach (MachineStopReasonProfile_msrp_Info item in m_MachineStopReasonProfile) { StopReasonMaster_srm_Info obj = stopReasons.Find(s => s.srm_iRecordID == item.msrp_iSRPFID); if (obj != null) { selectedStopReasons.Add(obj); } } //selectedStopReasons.Sort(new SeqItemComparer()); selectedStopReasons = selectedStopReasons.OrderBy(o => o.srm_iSeq).ToList(); foreach (StopReasonMaster_srm_Info item in stopReasons) { if (!selectedStopReasons.Contains(item)) unSelectedStopReasons.Add(item); } //unSelectedStopReasons.Sort(new SeqItemComparer()); unSelectedStopReasons = unSelectedStopReasons.OrderBy(o => o.srm_iSeq).ToList(); FillStopReasonData(unSelectedStopReasons, lvUnSelectedStopReasons, true); FillStopReasonData(selectedStopReasons, lvSelectedStopReason, true); //ClearData(); tsbAdd.Enabled = false; m_SelectedMainObject = dcm; } this.Cursor = Cursors.Default; }
private string GetStopReasonMasterSQL(StopReasonMaster_srm_Info model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.srm_iRecordID != null) { strSql1.Append("srm_iRecordID,"); strSql2.Append("" + model.srm_iRecordID + ","); } if (model.srm_cReasonCode != null) { strSql1.Append("srm_cReasonCode,"); strSql2.Append("'" + model.srm_cReasonCode + "',"); } if (model.srm_cMachineType != null) { strSql1.Append("srm_cMachineType,"); strSql2.Append("'" + model.srm_cMachineType + "',"); } if (model.srm_cReasonType != null) { strSql1.Append("srm_cReasonType,"); strSql2.Append("'" + model.srm_cReasonType + "',"); } if (model.srm_cPlanType != null) { strSql1.Append("srm_cPlanType,"); strSql2.Append("'" + model.srm_cPlanType + "',"); } if (model.srm_cReasonName != null) { strSql1.Append("srm_cReasonName,"); strSql2.Append("'" + model.srm_cReasonName + "',"); } if (model.srm_iSeq != null) { strSql1.Append("srm_iSeq,"); strSql2.Append("" + model.srm_iSeq + ","); } if (model.srm_lIsParallelable != null) { strSql1.Append("srm_lIsParallelable,"); strSql2.Append("" + (model.srm_lIsParallelable ? 1 : 0) + ","); } if (model.srm_iPredictedTime != null) { strSql1.Append("srm_iPredictedTime,"); strSql2.Append("" + model.srm_iPredictedTime + ","); } if (model.srm_lIsAtive != null) { strSql1.Append("srm_lIsAtive,"); strSql2.Append("" + (model.srm_lIsAtive ? 1 : 0) + ","); } if (model.srm_lIsNoneTask != null) { strSql1.Append("srm_lIsNoneTask,"); strSql2.Append("" + (model.srm_lIsNoneTask ? 1 : 0) + ","); } if (model.srm_cAdd != null) { strSql1.Append("srm_cAdd,"); strSql2.Append("'" + model.srm_cAdd + "',"); } if (model.srm_dAddDate != null) { strSql1.Append("srm_dAddDate,"); strSql2.Append("'" + model.srm_dAddDate.ToString(this._sqlLiteDatetimeFormat) + "',"); } if (model.srm_cLast != null) { strSql1.Append("srm_cLast,"); strSql2.Append("'" + model.srm_cLast + "',"); } if (model.srm_dLastDate != null) { strSql1.Append("srm_dLastDate,"); strSql2.Append("'" + model.srm_dLastDate.ToString(this._sqlLiteDatetimeFormat) + "',"); } strSql.Append("insert into StopReasonMaster_srm("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); return strSql.ToString(); }
void SysToolBar_OnItemNew_Click(object sender, EventArgs e) { MenuItem itemMenu = new MenuItem(); itemMenu.Tag = "WindowUI.HBManagerTerminal.Management.RunningManagement.StopReasonAppSetting"; StopReasonMaster_srm_Info srmInfo = new StopReasonMaster_srm_Info(); //srmInfo.srm_cMachineType = this._dicPrinterType[this.cbxPrinterType.SelectedIndex].cmt_cValue; srmInfo.srm_cMachineType = this.cbxPrinterType.SelectedValue.ToString(); BaseForm form = this.ShowSubForm(itemMenu, this.BaseDockPanel, string.Empty, WeifenLuo.WinFormsUI.Docking.DockState.Document, srmInfo, Common.DefineConstantValue.EditStateEnum.OE_Insert); form.FromCloseCallBack += RefreshAllState; }
void SysToolBar_OnItemModify_Click(object sender, EventArgs e) { MenuItem itemMenu = new MenuItem(); itemMenu.Tag = "WindowUI.HBManagerTerminal.Management.RunningManagement.StopReasonAppSetting"; StopReasonMaster_srm_Info srmInfo = new StopReasonMaster_srm_Info(); srmInfo.srm_iRecordID = int.Parse(this._strCurrentID); BaseForm form = this.ShowSubForm(itemMenu, this.BaseDockPanel, string.Empty, WeifenLuo.WinFormsUI.Docking.DockState.Document, srmInfo, Common.DefineConstantValue.EditStateEnum.OE_Update); form.FromCloseCallBack += RefreshAllState; }
void SysToolBar_OnItemDelete_Click(object sender, EventArgs e) { if (this.ShowQuestionMessage("是否確定進行刪除操作?記錄ID:" + this._strCurrentID)) { StopReasonMaster_srm_Info srmInfo = new StopReasonMaster_srm_Info(); srmInfo.srm_iRecordID = int.Parse(this._strCurrentID); ReturnValueInfo rvInfo = this._IStopReasonBL.DeleteRecord(srmInfo); if (!rvInfo.isError && rvInfo.boolValue) { this.ShowInformationMessage("刪除成功。"); } else { this.ShowWarningMessage("刪除失敗,失敗信息:" + rvInfo.messageText); } RefreshAllState(); } }
/// <summary> /// 數據綁定 /// </summary> private void DataBinding() { StopReasonMaster_srm_Info srmSearch = new StopReasonMaster_srm_Info(); srmSearch.srm_cMachineType = this.cbxPrinterType.SelectedValue.ToString(); try { List<StopReasonMaster_srm_Info> listSrmInfos = this._IStopReasonBL.SearchRecord(srmSearch); srmSearch.srm_lIsAtive = false; listSrmInfos.AddRange(this._IStopReasonBL.SearchRecord(srmSearch)); listSrmInfos = listSrmInfos.OrderBy(d => d.srm_iSeq).ToList(); this.lvSRMInfo.Items.Clear(); lvSRMInfo.SetDataSource<StopReasonMaster_srm_Info>(listSrmInfos); } catch (Exception ex) { ShowErrorMessage(ex); } }