Exemple #1
0
 public BeamCutInterface AddNewBeamCutInterface(BeamCutInterface binterface)
 {
     try
     {
         using (BeamCutContext = new BeamCutContext(database))
         {
             var result = BeamCutContext.BeamCutInterfaces.Add(binterface);
             BeamCutContext.SaveChanges();
             return(result);
         }
     }
     catch { return(null); }
 }
Exemple #2
0
 public bool UpdateBeamInterface(BeamCutInterface binterface)
 {
     try
     {
         using (BeamCutContext = new BeamCutContext(database))
         {
             BeamCutContext.Entry(binterface).State = EntityState.Modified;
             BeamCutContext.SaveChanges();
             return(true);
         }
     }
     catch { return(false); }
 }
Exemple #3
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;
            }
        }
Exemple #4
0
        // start cutting construction
        public RespCutting(IDbName database, int deviceId, int workerId, int clonePoId, int seq1Id, int seq2Id, 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 worker = EmployeeQuery.GetEmployee(workerId);
                if (worker == null)
                {
                    Exception = new RespException(true, "Invalid worker Id", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                var bdevice = BeamCutQuery.GetBeamCutDevice(deviceId);
                if (bdevice == null)
                {
                    Exception = new RespException(true, "Invalid device Id", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

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

                var originalPo = SequenceQuery.GetOriginalPo(clonePo.OriginalPo_Id);

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

                var component = ComponentQuery.GetShoeComponent(clonePo.Component_Id);

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

                var schedule = ScheduleQuery.GetSchedule(originalPo);

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

                var order = BeamCutQuery.GetBDeviceOrder(originalPo, deviceId);

                var startSeq = BeamCutQuery.GetBeamCutSeq(seq1Id);

                var stopSeq = BeamCutQuery.GetBeamCutSeq(seq2Id);

                if (startSeq == null || stopSeq == null)
                {
                    Exception = new RespException(true, "Invalid clone Seq Id", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                int[] qty = BeamCutQuery.GetTotalSelectSequenceQty(startSeq, stopSeq);

                if (qty == null)
                {
                    qty = new int[] { 0, 0 }
                }
                ;

                int bId = binterfaceId;
                BeamCutInterface binterface = BeamCutQuery.GetBeamInterfaceById(binterfaceId);

                int scheduleId = 0;
                if (schedule != null)
                {
                    scheduleId = schedule.id;
                }

                if (binterface == null)
                {
                    binterface = new BeamCutInterface
                    {
                        Employee_Id        = workerId,
                        BeamCutDevice_Id   = deviceId,
                        BeamCutPo_Id       = clonePoId,
                        OriginalPo_Id      = clonePo.OriginalPo_Id,
                        BeamCutStartSeq_Id = seq1Id,
                        BeamCutStopSeq_Id  = seq2Id,
                        TotalSelectedQty   = qty[0],
                        TotalSelectCutQty  = qty[1],
                        Schedule_Id        = scheduleId,
                        StartSeqNo         = startSeq.SequenceNo,
                        StopSeqNo          = stopSeq.SequenceNo,
                        StartCutTime       = DateTime.Now,
                        CuttingQty         = 0,
                        BeamCutCounter     = 0,
                        BDeviceOrder_Id    = order != null ? order.id : 0,
                    };

                    var beamInterface = BeamCutQuery.AddNewBeamCutInterface(binterface);
                    if (beamInterface == null)
                    {
                        Exception = new RespException(true, "Add new BInterface error", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                        return;
                    }
                    bId = beamInterface.id;
                }

                StockMeasure stockMeasure = StockQuery.GetStockMeasure(schedule);

                if (stockMeasure == null)
                {
                    var stock = StockQuery.AddNewStockMeasure(schedule);
                }

                Exception = new RespException(false, "Start cutting: OK", EKB_SYS_REQUEST.BEAM_START_CUTTING);

                InterfaceId = bId;
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_START_CUTTING);
            }
        }