Beispiel #1
0
        private void UpdateShoeSizes()
        {
            var sizes = SequenceQuery.GetOriginalSizes(SelectedSequence.id);

            if (sizes == null)
            {
                return;
            }

            ICollection <SizeRef> Size = new List <SizeRef>();
            int index = 0;

            foreach (var size in sizes)
            {
                index++;
                Size.Add(new SizeRef
                {
                    Index    = index,
                    Size     = ComponentQuery.GetShoeSize(ShareFuncs.GetInt(size.SizeId)).SizeName,
                    Quantity = ShareFuncs.GetInt(size.Quantity)
                });
            }

            try
            {
                DS_Size.DataSource = Size;
            }
            catch
            {
                DS_Size.DataSource = new List <SizeRef>();
            }
        }
Beispiel #2
0
 public SeqInfo(OriginalPOsequence _seq, int _cuttingQty, bool _finish)
 {
     id         = _seq.id;
     SeqNo      = ShareFuncs.GetInt(_seq.SequenceNo);
     SeqQty     = ShareFuncs.GetInt(_seq.Quantity);
     Finish     = _finish;
     CuttingQty = _cuttingQty;
 }
Beispiel #3
0
        private void EkanbanHisControl_Load(object sender, EventArgs e)
        {
            int height = 120;

            if (EKanbanHis.EKanbanClearHis.Count > 0)
            {
                ErrorHis = true;
                //this.Hide();
                //return;
            }

            EKanbanInterface eKanbanInterface = new EKanbanInterface();

            try
            {
                try
                {
                    eKanbanInterface        = Newtonsoft.Json.JsonConvert.DeserializeObject <EKanbanInterface>(EKanbanHis.Data);
                    DS_Interface.DataSource = eKanbanInterface;
                    lbStatus.Text           = ((SysActionCode)eKanbanInterface.SysActionCode).ToString();
                }
                catch { }

                if (EKanbanHis.EKanbanAddHis != null)
                {
                    DataTable table = new DataTable();
                    table.Columns.Add("Sequence No");
                    table.Columns.Add("Sequence Quantity");
                    table.Columns.Add("Add Time");
                    table.Columns.Add("Confirm Time");


                    foreach (var item in EKanbanHis.EKanbanAddHis)
                    {
                        string finishTime = "";
                        try
                        {
                            finishTime = ((SysActionCode)eKanbanInterface.SysActionCode == SysActionCode.EKANBAN_CONFIRM_ITEM) ? eKanbanInterface.LastUpdate.ToString() : "";
                        }
                        catch { }
                        table.Rows.Add(new object[] { item.SequenceNo, item.SequenceQty, item.DateTime, finishTime });
                        height += 20;
                    }

                    dataGridView1.DataSource = table;
                }
                TotaPrepareQty = 0;
                foreach (var item in EKanbanHis.EKanbanAddHis)
                {
                    TotaPrepareQty += ShareFuncs.GetInt(item.SequenceQty);
                }

                lbTotalQty.Text = TotaPrepareQty.ToString();

                this.Height = height;
            }
            catch { }
        }
Beispiel #4
0
        public PoInfo(IDbName _database, Schedule _schedule)
        {
            BuildingQuery buildingQuery = new BuildingQuery(_database);

            id        = _schedule.id;
            PoNumber  = _schedule.PoNumber;
            Model     = _schedule.Model;
            Article   = _schedule.Article;
            ModelName = _schedule.ModelName;
            Quantity  = _schedule.Quantity != null ? (int)_schedule.Quantity : 0;
            Line      = buildingQuery.GetProductionLine(ShareFuncs.GetInt(_schedule.ProductionLine_Id)).LineName;
        }
Beispiel #5
0
        public Schedule_t(IDbName database, Schedule _scheule)
        {
            SequenceQuery sequenceQuery = new SequenceQuery(database);
            var           po            = sequenceQuery.GetOriginalPo(_scheule);

            if (po != null)
            {
                OriginalPoId = po.id;
            }
            id       = _scheule.id;
            PoNumber = _scheule.PoNumber;
            PoQty    = ShareFuncs.GetInt(_scheule.Quantity);
        }
Beispiel #6
0
        private void GetSelectedSchedule()
        {
            if (lbSchedule.SelectedItem == null)
            {
                return;
            }

            SelectedSchedule       = lbSchedule.SelectedItem as Schedule;
            SelectedProductionLine = BuildingQuery.GetProductionLine(ShareFuncs.GetInt(SelectedSchedule.ProductionLine_Id));
            txtProductionLine.Text = SelectedProductionLine.LineName;

            UpdateOgiginalSequence();
        }
Beispiel #7
0
        public BDeviceCutTime(IDbName database, int deviceId, int totalCutTime)
        {
            BeamCutQuery = new BeamCutQuery(database);

            var statistic = BeamCutQuery.GetBMachineStatistic(deviceId, DateTime.Now);

            if (statistic == null)
            {
                statistic = BeamCutQuery.AddNewBcutStatistic(deviceId, DateTime.Now);
            }

            if (statistic.BDeviceCutTimeRecords != null)
            {
                foreach (var item in statistic.BDeviceCutTimeRecords)
                {
                    TotalCutTime += ShareFuncs.GetInt(item.TotalCutTime);
                }
            }

            var lastRecord = BeamCutQuery.Get_DeviceLastRecord(deviceId);

            if (lastRecord != null)
            {
                DateTime updateTime = (DateTime)lastRecord.UpdateTime;
                if (updateTime.DayOfYear == DateTime.Now.DayOfYear &&
                    updateTime.Minute == DateTime.Now.Minute &&
                    updateTime.Hour == DateTime.Now.Hour)
                {
                    // duplicate update detected
                    Exception = new RespException(false, "The cut time has been recorded", EKB_SYS_REQUEST.CUT_TIME_RECORD);
                    return;
                }
            }

            BDeviceCutTimeRecord record = new BDeviceCutTimeRecord
            {
                TotalCutTime         = totalCutTime,
                BeamCutDevice_Id     = deviceId,
                BMachineStatistic_Id = statistic.id,
            };

            if (!BeamCutQuery.AddNewBCutTimeRecord(record))
            {
                Exception = new RespException(true, "Add new record failed", EKB_SYS_REQUEST.CUT_TIME_RECORD);
                return;
            }

            TotalCutTime += totalCutTime;
        }
Beispiel #8
0
        public SequenceCtrl(Schedule _schedule, bool _displayHeader)
        {
            InitializeComponent();
            header   = _displayHeader;
            Schedule = new Schedule();

            if (Schedule != null)
            {
                Schedule = ScheduleQuery.GetSchedule(_schedule.id);
                ds_schedule.DataSource = Schedule;
                var ProductionLine = BuildingQuery.GetProductionLine(ShareFuncs.GetInt(Schedule.ProductionLine_Id));
                txProductionLine.Text = ProductionLine.LineName;
                txtUpdateTime.Text    = Schedule.ScheduleClass.LastModified.ToString("hh::mm: tt, dd/MM/yyyy");
            }

            OriginalPo = new OriginalPO();
            Draw();
        }
Beispiel #9
0
        public BeamInterface(BeamCutInterface BInterface, int place)
        {
            InitializeComponent();
            try
            {
                lbStartTime.Text = BInterface.StartCutTime.ToString();
                lbStopTime.Text  = BInterface.StopCutTime.ToString();
                BeamCutQuery  beamCutQuery  = new BeamCutQuery(_SERVER.ServerName.Database);
                ScheduleQuery scheduleQuery = new ScheduleQuery(_SERVER.ServerName.Database);
                SequenceQuery sequenceQuery = new SequenceQuery(_SERVER.ServerName.Database);
                BuildingQuery buildingQuery = new BuildingQuery(_SERVER.ServerName.Database);

                var clone_po = beamCutQuery.GetBeamCutPo(BInterface.BeamCutPo_Id);
                lbTotalPoCutQty.Text = clone_po.CuttingQuantity.ToString();
                lbComponent.Text     = clone_po.ComponentRef;

                var po       = sequenceQuery.GetOriginalPo(ShareFuncs.GetInt(BInterface.OriginalPo_Id));
                var schedule = scheduleQuery.GetSchedule(ShareFuncs.GetInt(BInterface.Schedule_Id));
                if (schedule == null)
                {
                    if (po != null)
                    {
                        schedule = scheduleQuery.GetSchedule(po);
                    }

                    if (schedule == null)
                    {
                        this.Hide();
                        Error = true;
                        return;
                    }
                }
                lbPlace.Text            = place.ToString();
                DS_Interface.DataSource = BInterface;
                DS_Po.DataSource        = schedule;
                lbLine.Text             = buildingQuery.GetProductionLine(ShareFuncs.GetInt(schedule.ProductionLine_Id)).LineName;
            }
            catch
            {
                this.Hide();
                Error = true;
                return;
            }
        }
Beispiel #10
0
        private void Login()
        {
            UserClass        = 0;
            _status          = false;
            lb_loginEXP.Text = "";

            User = EmpployeeQuery.GetAppUser(User.user, User.password);

            if (User == null)
            {
                lb_loginEXP.Text = "User name or password is invalid!";
                return;
            }
            else
            {
                UserClass = ShareFuncs.GetInt(User.userClass);
                if (UserClass == 0 || UserClass == 1)
                {
                    lb_loginEXP.Text = $"Login as Worker, change account to continous! ";
                }

                if (UserClass == 2)
                {
                    lb_loginEXP.Text = $"Login as Officer account successfully! ";
                }

                if (UserClass == 3)
                {
                    lb_loginEXP.Text = "Login as Admin account successfully! ";
                }

                if (UserClass >= RequiedUser)
                {
                    _status = true;
                    this.Close();
                }
            }
        }
Beispiel #11
0
        public RespSize(IDbName _database, int seq1Id, int seq2Id)
        {
            try
            {
                SequenceQuery sequenceQuery = new SequenceQuery(_database);
                BeamCutQuery  beamCutQuery  = new BeamCutQuery(_database);

                List <OriginalPOsequence> SeqList = new List <OriginalPOsequence>();

                var CloneSizes = beamCutQuery.GetBeamCutSizes(seq1Id, seq2Id);

                if (CloneSizes == null)
                {
                    Exception = new RespException(true, "CloneSizes is NULL", EKB_SYS_REQUEST.BEAM_GET_SIZE);
                    return;
                }

                SizeList = new List <Size_t>();
                foreach (var size in CloneSizes)
                {
                    SizeList.Add(new Size_t
                    {
                        SizeId     = ShareFuncs.GetInt(size.SizeId),
                        SizeQty    = ShareFuncs.GetInt(size.SizeQty),
                        CuttingQty = ShareFuncs.GetInt(size.CutQty),
                        Finish     = (size.SizeQty == size.CutQty ? true : false)
                    });
                    RespTotalCuttingQty += ShareFuncs.GetInt(size.CutQty);
                    RespTotalQty        += ShareFuncs.GetInt(size.SizeQty);
                }

                Exception = new RespException(false, "Get Size: OK", EKB_SYS_REQUEST.BEAM_GET_SIZE);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_SIZE);
            }
        }
Beispiel #12
0
        private void UpdateSelectedSchedule()
        {
            SelectedOriginalPo     = new OriginalPO();
            SelectedSchedule       = new Schedule();
            SelectedSequence       = new OriginalPOsequence();
            SelectedScheduleLine   = string.Empty;
            txtProductionLine.Text = string.Empty;
            if (lbSchedule.SelectedItem == null)
            {
                return;
            }


            SelectedSchedule = ScheduleQuery.GetSchedule((lbSchedule.SelectedItem as Schedule).id);

            SelectedProductionLine = BuildingQuery.GetProductionLine(ShareFuncs.GetInt(SelectedSchedule.ProductionLine_Id));

            txtProductionLine.Text = SelectedScheduleLine = SelectedProductionLine.LineName;

            UpdateModelComponent();

            UpdateOgiginalSequence();
        }
Beispiel #13
0
        public RespConfirmSize(IDbName database, int bInterfaceId, int sizeId, int sizeQty)
        {
            try
            {
                BeamCutQuery   = new BeamCutQuery(database);
                StockQuery     = new StockQuery(database);
                EmployeeQuery  = new EmployeeQuery(database);
                SequenceQuery  = new SequenceQuery(database);
                ScheduleQuery  = new ScheduleQuery(database);
                ComponentQuery = new ComponentQuery(database);

                var beamInterface = BeamCutQuery.GetBeamInterfaceById(bInterfaceId);
                if (beamInterface == null)
                {
                    Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE);
                    return;
                }

                var bdevice = BeamCutQuery.GetBeamCutDevice(beamInterface.BeamCutDevice_Id);

                if (bdevice == null)
                {
                    Exception = new RespException(true, "Can not find beam cut device", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE);
                    return;
                }

                var clonePo = BeamCutQuery.GetBeamCutPo(ShareFuncs.GetInt(beamInterface.BeamCutPo_Id));

                if (clonePo == null)
                {
                    Exception = new RespException(true, "Can not find clone Po", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE);
                    return;
                }

                var seq1 = BeamCutQuery.GetBeamCutSeq(ShareFuncs.GetInt(beamInterface.BeamCutStartSeq_Id));

                var seq2 = BeamCutQuery.GetBeamCutSeq(ShareFuncs.GetInt(beamInterface.BeamCutStopSeq_Id));

                int cutQty      = 0;
                int totalQty    = 0;
                int currentQty  = 0;
                int addQty      = 0;
                int seqTotalQty = 0;
                int seqQty      = 0;
                foreach (var seq in clonePo.BeamCutSeqs)
                {
                    if (seq.SequenceNo >= seq1.SequenceNo && seq.SequenceNo <= seq2.SequenceNo)
                    {
                        if (seq.Finish == false)
                        {
                            var sizes = BeamCutQuery.GetBeamCutSize(seq.id);

                            int seqcutQty = ShareFuncs.GetInt(seq.CutQty);
                            foreach (var size in sizes)
                            {
                                if (size.SizeId == sizeId)
                                {
                                    if (size.Finished != true && sizeQty > 0)
                                    {
                                        int oldval = ShareFuncs.GetInt(size.CutQty);

                                        int addval = ShareFuncs.GetInt(size.SizeQty) - oldval;

                                        if (sizeQty >= addval)
                                        {
                                            addval        = ShareFuncs.GetInt(size.SizeQty) - oldval;
                                            size.CutQty   = size.SizeQty;
                                            size.Finished = true;
                                            seqcutQty    += addval;
                                            sizeQty      -= addval;

                                            addQty += addval;
                                        }
                                        else
                                        {
                                            size.CutQty += sizeQty;
                                            seqcutQty   += sizeQty;
                                            addQty      += sizeQty;
                                            sizeQty      = 0;
                                        }
                                        size.BeamCutDevice_Id = beamInterface.BeamCutDevice_Id;
                                        size.Worker_Id        = beamInterface.Employee_Id;
                                        size.LastUpdate       = DateTime.Now;
                                        BeamCutQuery.UpdateBeamSize(size);
                                    }

                                    totalQty += ShareFuncs.GetInt(size.SizeQty);
                                    cutQty   += ShareFuncs.GetInt(size.CutQty);
                                }

                                currentQty += ShareFuncs.GetInt(size.CutQty);
                            }
                            seq.BeamCutDevice_Id = beamInterface.BeamCutDevice_Id;
                            seq.Worker_Id        = beamInterface.Employee_Id;
                            seq.CutQty           = seqcutQty;
                            seq.LastUpdate       = DateTime.Now;
                            seq.Finish           = seq.CutQty == seq.SequenceQty ? true : false;
                            BeamCutQuery.UpdateBeamCutSeq(seq);
                        }

                        seqTotalQty += ShareFuncs.GetInt(seq.CutQty);
                        seqQty      += ShareFuncs.GetInt(seq.SequenceQty);
                    }
                }

                if (seqTotalQty == seqQty)
                {
                    StopCutting = true;
                }

                int oldVal = beamInterface.CuttingQty != null ? (int)beamInterface.CuttingQty : 0;
                beamInterface.LastConfirmSize = DateTime.Now;
                beamInterface.CuttingQty      = addQty + oldVal;
                BeamCutQuery.UpdateBeamInterface(beamInterface);

                clonePo.LastUpdate       = DateTime.Now;
                clonePo.CuttingQuantity += addQty;
                if (clonePo.CuttingQuantity == clonePo.PoQuantity)
                {
                    clonePo.Finish     = true;
                    clonePo.FinishTime = DateTime.Now;
                }

                BeamCutQuery.UpdateBeamCutPo(clonePo);

                var statistic = BeamCutQuery.GetBMachineStatistic(ShareFuncs.GetInt(beamInterface.BeamCutDevice_Id), DateTime.Now);
                if (statistic == null)
                {
                    statistic = BeamCutQuery.AddNewBcutStatistic(ShareFuncs.GetInt(beamInterface.BeamCutDevice_Id), DateTime.Now);
                }

                BDeviceCutTimeRecord record = new BDeviceCutTimeRecord
                {
                    TotalCutTime         = 0,
                    BeamCutDevice_Id     = bdevice.id,
                    ConfirmQuantity      = addQty,
                    BMachineStatistic_Id = statistic.id,
                };

                if (!BeamCutQuery.AddNewBCutTimeRecord(record))
                {
                    Exception = new RespException(true, "Add new record failed", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE);
                }

                int temp = statistic.TotalCutQty != null ? (int)statistic.TotalCutQty : 0;
                statistic.TotalCutQty = temp + addQty;
                BeamCutQuery.UpdateBStatistic(statistic);

                RespTotalCuttingQty = ShareFuncs.GetInt(beamInterface.CuttingQty);
                SizeId = sizeId;
                CutQty = cutQty;
                Finish = (totalQty == cutQty ? true : false);

                Exception = new RespException(false, "Confirm Size: OK", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE);
            }
        }
Beispiel #14
0
        public EKanbanResponse(IDbName _database, int _ekanbanDeviceId)
        {
            EKanbanTaskQuery eKanbanTaskQuery = new EKanbanTaskQuery(_database);
            SequenceQuery    sequenceQuery    = new SequenceQuery(_database);
            ComponentQuery   componentQuery   = new ComponentQuery(_database);

            var ekanbanDevice = eKanbanTaskQuery.GetEKanbanDevice(_ekanbanDeviceId);

            var _Interface = eKanbanTaskQuery.GetLastEKanbanInterface(_ekanbanDeviceId);

            SizeList = new List <SizeInfo>();
            PartList = new List <PartInfo>();
            List <OriginalSize> originalSizes = new List <OriginalSize>();

            foreach (var item in _Interface.EKanbanLoadings)
            {
                var Seq = sequenceQuery.GetOriginalSequence(ShareFuncs.GetInt(item.OriginalSequence_Id));
                TotalCartQty += ShareFuncs.GetInt(Seq.Quantity);
                foreach (var size in Seq.OriginalSizes)
                {
                    originalSizes.Add(size);
                }
            }

            foreach (var item in originalSizes)
            {
                var foundSizes = SizeList.Where(i => i.SizeId == item.SizeId);
                if (foundSizes.Count() > 0)
                {
                    foundSizes.First().SizeQty += ShareFuncs.GetInt(item.Quantity);
                }
                else
                {
                    SizeList.Add(new SizeInfo(ShareFuncs.GetInt(item.SizeId), ShareFuncs.GetInt(item.Quantity)));
                }
            }

            Interface = new InterfaceInfo(_Interface);

            foreach (var item in _Interface.EkanbanComponents)
            {
                var Component = componentQuery.GetShoeComponent(ShareFuncs.GetInt(item.ShoeComponent_Id));
                PartList.Add(new PartInfo(ShareFuncs.ConvertToUnSign(Component.Reference)));
            }

            //if (DateTime.Now.Hour == 17)
            //{
            //    if (DateTime.Now.Minute > 50)
            //    {
            //        ScreenOff = true;
            //        ekanbanDevice.ScreenOff = true;
            //    }
            //}
            //else
            //{
            //    if (DateTime.Now.Hour > 17)
            //    {
            //        ScreenOff = true;
            //        ekanbanDevice.ScreenOff = true;
            //    }
            //}

            //if (DateTime.Now.Hour == 6 && DateTime.Now.Minute < 45)
            //{
            //    ScreenOff = false;
            //    ekanbanDevice.ScreenOff = false;
            //}

            ekanbanDevice.NetworkStatus = (int)SYS_MODELS._ENUM.SysActionCode.ONLINE;
            ekanbanDevice.LastOnline    = DateTime.Now;
            eKanbanTaskQuery.UpdateEKanbanDevice(ekanbanDevice);

            if (ekanbanDevice.ScreenOff == null)
            {
                ScreenOff = false;
            }
            else
            {
                ScreenOff = (bool)ekanbanDevice.ScreenOff;
            }
        }
Beispiel #15
0
        public BLastCut(IDbName database, int bdeviceId, int bInterfaceId)
        {
            BeamCutQuery   = new BeamCutQuery(database);
            StockQuery     = new StockQuery(database);
            EmployeeQuery  = new EmployeeQuery(database);
            SequenceQuery  = new SequenceQuery(database);
            ScheduleQuery  = new ScheduleQuery(database);
            ComponentQuery = new ComponentQuery(database);

            try
            {
                var bInterface = BeamCutQuery.GetLastInterface(bdeviceId);

                if (bInterface == null)
                {
                    Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);

                    bInterface = BeamCutQuery.GetBeamInterfaceById(bInterfaceId);
                    if (bInterface == null)
                    {
                        Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
                        return;
                    }
                }

                var bpo = BeamCutQuery.GetBeamCutPo(ShareFuncs.GetInt(bInterface.BeamCutPo_Id));

                if (bpo == null)
                {
                    Exception = new RespException(true, "Can not find clone Po", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
                    return;
                }

                var originalPo = SequenceQuery.GetOriginalPo(ShareFuncs.GetInt(bInterface.OriginalPo_Id));

                if (originalPo == null)
                {
                    Exception = new RespException(true, "Can not find Po", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
                    return;
                }

                BinterfaceId = bInterface.id;
                PoNumber     = originalPo.PoNumber;
                StartSeq     = ShareFuncs.GetInt(bInterface.StartSeqNo);
                StopSeq      = ShareFuncs.GetInt(bInterface.StopSeqNo);

                if (bInterface.StartCutTime != null)
                {
                    StartTime = ((DateTime)bInterface.StartCutTime).ToString("hh:mm tt, dd/MM/yyyy");
                }

                if (bInterface.StopCutTime != null)
                {
                    StopTime = ((DateTime)bInterface.StopCutTime).ToString("hh:mm tt, dd/MM/yyyy");
                }

                CutQty             = ShareFuncs.GetInt(bInterface.CuttingQty);
                CutTime            = ShareFuncs.GetInt(bInterface.BeamCutCounter);
                Employee_Id        = ShareFuncs.GetInt(bInterface.Employee_Id);
                Schedule_Id        = ShareFuncs.GetInt(bInterface.Schedule_Id);
                BeamCutPo_Id       = ShareFuncs.GetInt(bInterface.BeamCutPo_Id);
                BeamCutStartSeq_Id = ShareFuncs.GetInt(bInterface.BeamCutStartSeq_Id);
                Component_Id       = ShareFuncs.GetInt(bpo.Component_Id);
                BeamCutStopSeq_Id  = ShareFuncs.GetInt(bInterface.BeamCutStopSeq_Id);
                Finish             = bInterface.Finish != null ? (bool)bInterface.Finish : false;
                PoQty         = ShareFuncs.GetInt(originalPo.Quantity);
                OriginalPo_Id = ShareFuncs.GetInt(bInterface.OriginalPo_Id);

                var component = ComponentQuery.GetShoeComponent(ShareFuncs.GetInt(bpo.Component_Id));
                if (component != null)
                {
                    string comp = ShareFuncs.ConvertToUnSign(component.Reference);
                    Component = comp;
                }
                Exception = new RespException(false, "Get last cut: OK", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
            }
        }
Beispiel #16
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)
            { }
        }
Beispiel #17
0
        public OrderResult(BeamCutPo beamCutPo)
        {
            try
            {
                InitializeComponent();
                BeamCutPo = new BeamCutPo();
                BeamCutPo = beamCutPo;
                BeamCutQuery   beamCutQuery   = new BeamCutQuery(_SERVER.ServerName.Database);
                ComponentQuery componentQuery = new ComponentQuery(_SERVER.ServerName.Database);
                SequenceQuery  sequenceQuery  = new SequenceQuery(_SERVER.ServerName.Database);
                var            originalPo     = sequenceQuery.GetOriginalPo(beamCutPo.OriginalPo_Id);
                var            component      = componentQuery.GetShoeComponent(BeamCutPo.Component_Id);
                label2.Text = component != null ? component.Reference : "";
                var Binterface = beamCutQuery.GetBeamInterface(beamCutPo.id);

                int totalCutQty  = 0;
                int totalCutTime = 0;

                bool first = false;
                bool last  = false;

                double   totalTime = 0;
                DateTime?start = null, stop = null, last_update = null;

                foreach (var item in Binterface)
                {
                    if (!first)
                    {
                        if (item.StartCutTime != null)
                        {
                            start       = (DateTime)item.StartCutTime;
                            label9.Text = start != null?start.ToString() : "";
                        }
                        first = true;
                    }

                    totalCutTime += ShareFuncs.GetInt(item.BeamCutCounter);
                    totalCutQty  += ShareFuncs.GetInt(item.CuttingQty);
                    if (item.StopCutTime != null)
                    {
                        label7.Text = item.StopCutTime.ToString();
                    }

                    try
                    {
                        if (item.StopCutTime != null)
                        {
                            stop = (DateTime)item.StopCutTime;
                        }
                        else
                        {
                            stop = (DateTime)item.LastConfirmSize;
                        }
                        label11.Text = stop != null ? ((DateTime)stop).ToString() : "";

                        totalTime    = ((DateTime)stop - (DateTime)start).TotalSeconds;
                        label13.Text = $"{((int)totalTime / 60)}min {(int)totalTime % 60}sec";

                        label15.Text = $"{(int)(totalCutQty * 60 / totalTime)} c/min";
                    }
                    catch { }
                }

                label3.Text = totalCutQty.ToString();
                label5.Text = totalCutTime.ToString();
                TotalCutQty = totalCutQty;
            }
            catch { }
        }
Beispiel #18
0
        public RespPoInfo(IDbName _database, int scheduleId, int originalPoId, int componentId)
        {
            try
            {
                ScheduleQuery  scheduleQuery  = new ScheduleQuery(_database);
                SequenceQuery  sequenceQuery  = new SequenceQuery(_database);
                BeamCutQuery   beamCutQuery   = new BeamCutQuery(_database);
                SequenceQuery  SequenceQuery  = new SequenceQuery(_database);
                ComponentQuery componentQuery = new ComponentQuery(_database);

                var schedule = scheduleQuery.GetSchedule(scheduleId);

                var originalPo = SequenceQuery.GetOriginalPo(originalPoId);

                var shoeComponent = componentQuery.GetShoeComponent(componentId);

                if (schedule == null)
                {
                    if (originalPo == null)
                    {
                        Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }

                    schedule = scheduleQuery.GetSchedule(originalPo);

                    if (schedule == null)
                    {
                        Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }
                }

                if (shoeComponent == null)
                {
                    Exception = new RespException(true, "Can not find component", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                    return;
                }

                PoInfo = new PoInfo(_database, schedule);

                if (originalPo == null)
                {
                    Exception = new RespException(true, "Empty sequence file", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                    return;
                }

                var clonePo = beamCutQuery.FindClonePo(originalPo.id, componentId);

                if (clonePo != null)
                {
                    ClonePoId = clonePo.id;

                    SeqList = new List <SeqInfo>();
                    foreach (var item in clonePo.BeamCutSeqs)
                    {
                        SeqList.Add(new SeqInfo
                        {
                            id         = item.id,
                            CuttingQty = ShareFuncs.GetInt(item.CutQty),
                            SeqNo      = ShareFuncs.GetInt(item.SequenceNo),
                            SeqQty     = ShareFuncs.GetInt(item.SequenceQty),
                            Finish     = item.Finish == true ? true : false,
                        });
                    }
                }
                else
                {
                    var bClonePo = beamCutQuery.CloneOriginalPo(originalPo, shoeComponent);

                    if (bClonePo == null)
                    {
                        Exception = new RespException(true, "An error occured while requesting po information", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }

                    ClonePoId = bClonePo.id;

                    SeqList = new List <SeqInfo>();
                    foreach (var item in bClonePo.BeamCutSeqs)
                    {
                        SeqList.Add(new SeqInfo
                        {
                            id         = item.id,
                            CuttingQty = ShareFuncs.GetInt(item.CutQty),
                            SeqNo      = ShareFuncs.GetInt(item.SequenceNo),
                            SeqQty     = ShareFuncs.GetInt(item.SequenceQty),
                            Finish     = item.Finish == true ? true : false,
                        });
                    }
                }

                Exception = new RespException(false, "Get Poinfo: OK", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
            }
        }
Beispiel #19
0
        public RespFinishAll(IDbName database, int bInterfaceId, int cutCounter)
        {
            BeamCutQuery   BeamCutQuery   = new BeamCutQuery(database);
            StockQuery     StockQuery     = new StockQuery(database);
            EmployeeQuery  EmployeeQuery  = new EmployeeQuery(database);
            SequenceQuery  SequenceQuery  = new SequenceQuery(database);
            ScheduleQuery  ScheduleQuery  = new ScheduleQuery(database);
            ComponentQuery ComponentQuery = new ComponentQuery(database);

            try
            {
                var bInterface = BeamCutQuery.GetBeamInterfaceById(bInterfaceId);
                if (bInterface == null)
                {
                    Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.FINISH_ALL);
                    return;
                }

                var clonePo = BeamCutQuery.GetBeamCutPo(ShareFuncs.GetInt(bInterface.BeamCutPo_Id));
                if (clonePo == null)
                {
                    Exception = new RespException(true, "Invalid clone Po Id", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                int addQty = 0;
                foreach (var seq in clonePo.BeamCutSeqs)
                {
                    var currentSeq = BeamCutQuery.GetBeamCutSeq(seq.id);
                    if (currentSeq.SequenceNo < bInterface.SequenceNo + bInterface.TotalSequence)
                    {
                        foreach (var size in seq.BeamCutSizes)
                        {
                            addQty         += ShareFuncs.GetInt(size.SizeQty - size.CutQty);
                            size.CutQty     = size.SizeQty;
                            size.Finished   = true;
                            size.LastUpdate = DateTime.Now;
                            BeamCutQuery.UpdateBeamSize(size);
                        }

                        currentSeq.CutQty    += addQty;
                        currentSeq.LastUpdate = DateTime.Now;
                        currentSeq.Finish     = true;
                        BeamCutQuery.UpdateBeamCutSeq(currentSeq);
                    }
                }

                bInterface.BeamCutCounter += cutCounter;
                bInterface.CuttingQty     += addQty;
                bInterface.StopCutTime     = DateTime.Now;
                if (!BeamCutQuery.UpdateBeamInterface(bInterface))
                {
                    Exception = new RespException(true, "Can not update BInterface", EKB_SYS_REQUEST.FINISH_ALL);
                    return;
                }
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.FINISH_ALL);
            }
        }
Beispiel #20
0
        public ConfirmResponse(IDbName _database, int _ekanbanDeviceId, int _confirmQty)
        {
            try
            {
                EKanbanTaskQuery eKanbanTaskQuery = new EKanbanTaskQuery(_database);
                SequenceQuery    sequenceQuery    = new SequenceQuery(_database);
                ComponentQuery   componentQuery   = new ComponentQuery(_database);
                StockQuery       stockQuery       = new StockQuery(_database);
                ScheduleQuery    scheduleQuery    = new ScheduleQuery(_database);
                SysHistoryQuery  sysHistoryQuery  = new SysHistoryQuery(_database);


                var Interface = eKanbanTaskQuery.GetLastEKanbanInterface(_ekanbanDeviceId);
                var his       = sysHistoryQuery.GetEKanbanHistory(Interface);

                if (Interface.SysActionCode == (int)SYS_MODELS._ENUM.SysActionCode.EKANBAN_CONFIRM_ITEM)
                {
                    ConfirmSuccess = true;
                    EMessage       = "EKanban is already conform!";
                    return;
                }

                Interface.SysActionCode = (int)SYS_MODELS._ENUM.SysActionCode.EKANBAN_CONFIRM_ITEM;
                Interface.LastUpdate    = DateTime.Now;
                if (!eKanbanTaskQuery.UpdateEKanbanInterface(Interface))
                {
                    ConfirmSuccess = false;
                    EMessage       = "EKanban is already conform!";
                    return;
                }

                List <Schedule> schedules = new List <Schedule>();

                foreach (var item in Interface.EKanbanLoadings)
                {
                    var sch = scheduleQuery.GetSchedule(ShareFuncs.GetInt(item.OriginalPo_Id));
                    var Seq = sequenceQuery.GetOriginalSequence(ShareFuncs.GetInt(item.OriginalSequence_Id));
                    if (sch != null)
                    {
                        var stock = stockQuery.GetPrepareStockMeasure(sch);

                        if (stock != null)
                        {
                            StockConfirmSequence stockConfirm = new StockConfirmSequence
                            {
                                FinishTime      = DateTime.Now,
                                SequenceNo      = Seq.SequenceNo,
                                SequenceQty     = Seq.Quantity,
                                StockMeasure_Id = stock.id,
                            };

                            StockMessage = "Update stock message successfully";
                            if (!stockQuery.AddNewStockConfirm(stockConfirm))
                            {
                                StockMessage = "An error orcured while updating stock";
                            }

                            stock.ConfirmUpdateTime  = DateTime.Now;
                            stock.EKanbanConfirmQty += Seq.Quantity;
                            if (!stockQuery.UpdateStockMeasure(stock))
                            {
                                StockMessage = "An error orcured while updating stock";
                            }
                        }
                    }

                    item.SysActionCode = (int)SYS_MODELS._ENUM.SysActionCode.SEQUENCE_CONFORM;
                    item.LastUpdate    = DateTime.Now;
                    item.ConfirmQty    = _confirmQty;
                    eKanbanTaskQuery.UpdateEKanbanLoading(item);

                    string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(Interface);
                    his.Data     = jsonStr;
                    his.DateTime = DateTime.Now;
                    sysHistoryQuery.UpdateEKanbanHis(his);

                    EKanbanConfirmHis eKanbanConfirmHis = new EKanbanConfirmHis
                    {
                        Conform             = true,
                        DateTime            = DateTime.Now,
                        EKanbanHis_Id       = his.id,
                        OriginalSequence_Id = Seq.id,
                        SequenceNo          = Seq.SequenceNo,
                        SequenceQty         = Seq.Quantity,
                    };
                    sysHistoryQuery.AddNewConfirmHistory(eKanbanConfirmHis);
                }

                ConfirmSuccess = true;
                EMessage       = "EKanban is conform successfully";
            }
            catch (Exception e)
            {
                EMessage = e.Message;
            }
        }