예제 #1
0
 public bool AddNewClearHistory(EKanbanClearHis _ekanbanClearHis)
 {
     try
     {
         using (HistoryContext = new HistoryContext(database))
         {
             HistoryContext.EKanbanClearHis.Add(_ekanbanClearHis);
             HistoryContext.SaveChanges();
             return(true);
         }
     }
     catch { return(false); }
 }
예제 #2
0
        private void btn_Clear_Click(object sender, EventArgs e)
        {
            var dresult = MessageBox.Show("Do you really want to delete this Ekanban data?", "Question",
                                          MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dresult != DialogResult.Yes)
            {
                return;
            }

            int oldId = SelectedEKanbanInterface.id;

            ICollection <EKanbanLoading> EkanbanLoadings = EKanbanTaskQuery.GetEKanbanLoadings(SelectedEKanbanInterface.id);

            if (EKanbanTaskQuery.DeleteEKanbanInterface(SelectedEKanbanInterface))
            {
                MessageBox.Show("Clear Po from Ekanban succeesfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("An error orcured while delete Ekanban interface.\r\nError: Failed to delete Ekanban interface.", "Message",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            UpdateSelectedSchedule();
            UpdateSelectedEkanbanDevice();
            UpdateSelectedOriginalSequence();


            // Thêm mới Stock record
            var Stock = StockQuery.GetPrepareStockMeasure(SelectedSchedule);

            if (Stock == null)
            {
                return;
            }

            foreach (var item in EkanbanLoadings)
            {
                var seq = SequenceQuery.GetOriginalSequence(ShareFuncs.GetInt(item.OriginalSequence_Id));
                StockQuery.DeleteStockPreparing(Stock.id, ShareFuncs.GetInt(seq.SequenceNo));
            }

            try
            {
                // thêm mới history cho ekanban
                AppHistory his = new AppHistory
                {
                    SysActionCode = (int)SysActionCode.EKANBAN_CLEAR_ITEM,
                    DateTime      = DateTime.Now,
                    Description   = $"Clear Ekanban information: {SelectedEKanbanDevice.Name}",
                };

                SysHistoryQuery.AddNewAppHistory(his);

                var EkanbanHis = SysHistoryQuery.GetEKanbanHistoryByInterface(oldId);

                EKanbanClearHis addHis = new EKanbanClearHis
                {
                    DateTime      = DateTime.Now,
                    Removed       = true,
                    EKanbanHis_Id = EkanbanHis.id,
                };

                SysHistoryQuery.AddNewClearHistory(addHis);
            }
            catch (Exception ee)
            { }
        }