예제 #1
0
        void AddHaltReasonItem(ProjectBaseItemModel itemBaseReason, bool lIsAdd)
        {
            if (itemBaseReason == null)
            {
                return;
            }

            if (lIsAdd)
            {
                AddListviewItem(this.m_frmMacShutdownDetailBase.ListViewSelectedHaltReasonItems, itemBaseReason);
                m_Controller.AddHaltReasonItem(this.m_CurrentRecord.RecordID, itemBaseReason);
            }
            else
            {
                ListViewItem[] listExistItems = this.m_frmMacShutdownDetailBase.ListViewSelectedHaltReasonItems.Items.Find(itemBaseReason.Code.Trim(), true);
                if (listExistItems != null && listExistItems.Length > 0)
                {
                    this.m_frmMacShutdownDetailBase.ListViewSelectedHaltReasonItems.Items.Remove(listExistItems[0]);
                }
                m_Controller.RemoveHaltReasonItem(this.m_CurrentRecord.RecordID, itemBaseReason);
            }
        }
예제 #2
0
        /// <summary>
        /// 移除停機原因
        /// </summary>
        /// <param name="RecordID">停機記錄ID</param>
        /// <param name="reasonItem">停機原因項</param>
        public override void RemoveHaltReasonItem(Guid RecordID, ProjectBaseItemModel reasonBaseItem)
        {
            if (RecordID != Guid.Empty && reasonBaseItem != null)
            {
                ProjectMachineHaltRecord recHalt = base.MachineHaltRecords.Where(x => x.RecordID == RecordID).FirstOrDefault();
                if (recHalt != null)
                {
                    if (recHalt.StopReasons == null)
                    {
                        recHalt.StopReasons = new List<ProjectMachineHaltRecordReason>();
                    }
                    ProjectMachineHaltRecordReason reasonItem = recHalt.StopReasons.FirstOrDefault(x => x.StopReasonID.ToString() == reasonBaseItem.Code.Trim().ToString());
                    if (reasonItem != null)
                    {
                        recHalt.StopReasons.Remove(reasonItem);
                    }

                    SetPredictStopTime(recHalt);//設置停機預計時間

                    base.OnProductionChanged(recHalt);
                    base.OnProductionDataUpdate();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 新增停機原因
        /// </summary>
        /// <param name="RecordID">停機記錄ID</param>
        /// <param name="reasonItem">停機原因項</param>
        public override void AddHaltReasonItem(Guid RecordID, ProjectBaseItemModel reasonBaseItem)
        {
            if (RecordID != Guid.Empty && reasonBaseItem != null)
            {
                ProjectMachineHaltRecord recHalt = base.MachineHaltRecords.Where(x => x.RecordID == RecordID).FirstOrDefault();
                if (recHalt != null)
                {
                    if (recHalt.StopReasons == null)
                    {
                        recHalt.StopReasons = new List<ProjectMachineHaltRecordReason>();
                    }
                    if (!recHalt.StopReasons.Exists(x => x.StopReasonID.ToString() == reasonBaseItem.Code.Trim().ToString()))
                    {
                        ProjectMachineHaltRecordReason reasonItem = new ProjectMachineHaltRecordReason();
                        reasonItem.RecordID = Guid.NewGuid();
                        try
                        {
                            reasonItem.StopReasonID = int.Parse(reasonBaseItem.Code.Trim());
                        }
                        catch (Exception ex)
                        {
                            base.OnException(mc_ControllerName, "AddHaltReasonItem", ex.Message);
                            return;
                        }
                        reasonItem.PredictStopTime = (int)reasonBaseItem.PredictedTime * 60;
                        reasonItem.RecordEditStatus = 1;
                        recHalt.StopReasons.Add(reasonItem);

                        SetPredictStopTime(recHalt);//設置停機預計時間

                        base.OnProductionChanged(recHalt);
                        base.OnProductionDataUpdate();
                    }
                }
            }
        }
예제 #4
0
 /// <summary>
 /// 在選擇項列表增加項目
 /// </summary>
 /// <param name="itemBaseReason">源數據</param>
 private ListViewItem GetPrepareItem(ProjectBaseItemModel itemBaseReason)
 {
     ListViewItem lvItem = new ListViewItem();
     lvItem.Name = itemBaseReason.Code.Trim();
     lvItem.SubItems.Add(itemBaseReason.Description.Trim());
     return lvItem;
 }
예제 #5
0
 /// <summary>
 /// 在選擇項列表增加項目
 /// </summary>
 /// <param name="lvTarget">目標列表控件</param>
 /// <param name="itemBaseReason">源數據</param>
 private void AddListviewItem(ListView lvTarget, ProjectBaseItemModel itemBaseReason)
 {
     ListViewItem lvItem = GetPrepareItem(itemBaseReason);
     lvTarget.Items.Add(lvItem);
     lvTarget.Sorting = SortOrder.Ascending;
     ListViewColumnSorter sorter = new ListViewColumnSorter();
     sorter.SortColumn = 1;
     lvTarget.ListViewItemSorter = sorter;
 }
예제 #6
0
        /// <summary>
        /// 在選擇項列表增加項目
        /// </summary>
        /// <param name="item"></param>
        private ListViewItem GetPrepareItem(ProjectBaseItemModel ppBaseItem)
        {
            ListViewItem lvItem = new ListViewItem();
            lvItem.Name = ppBaseItem.Code.Trim();
            lvItem.SubItems.Add(ppBaseItem.Description.Trim());
            lvItem.SubItems.Add(ppBaseItem.PredictedTime.ToString());

            return lvItem;
        }
예제 #7
0
        /// <summary>
        /// 在選擇項列表增加項目
        /// </summary>
        /// <param name="item"></param>
        private void AddListviewItem(ProjectBaseItemModel ppBaseItem)
        {
            ListViewItem lvItem = GetPrepareItem(ppBaseItem);

            this._projectPrepareWorkBase.ListViewSelectedItems.Items.Add(lvItem);

            this._projectPrepareWorkBase.ListViewSelectedItems.Sorting = SortOrder.Ascending;
            ListViewColumnSorter sorter = new ListViewColumnSorter();
            sorter.SortColumn = 1;
            this._projectPrepareWorkBase.ListViewSelectedItems.ListViewItemSorter = sorter;
        }