Esempio n. 1
0
        private void AggEvent_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            // eRFXLImpType impType = eRFXLImpType.QA;

            if (e.SelectedObjects.Count > 0)
            {
                using (IObjectSpace os = Application.CreateObjectSpace())
                {
                    RepackLotSerialNo selectedSerialNo = (RepackLotSerialNo)e.SelectedObjects[0];

                    eSerialTypes stype;

                    stype = eSerialTypes.sequential;
                    stype = selectedSerialNo.RepackLot.RepackItem.SerialType;
                    string strGtin = selectedSerialNo.RepackLot.RepackItem.Gtin;

                    switch (stype)
                    {
                    case eSerialTypes.sequential:

                        throw new NotImplementedException();


                    case eSerialTypes.RFXcel:

                        RFEXCEL rfc = new RFEXCEL(strGtin, 0, Application, impType);
                        rfc.PostAggEvent(e);

                        break;

                    default:

                        break;
                    }
                }
                View.ObjectSpace.Refresh();

                MessageOptions options = new MessageOptions();
                options.Duration     = 20000;
                options.Message      = string.Format("Agg event");
                options.Type         = InformationType.Info;
                options.Web.Position = InformationPosition.Top;
                options.Win.Caption  = "Succeeded";
                options.Win.Type     = WinMessageType.Alert;

                Application.ShowViewStrategy.ShowMessage(options);
            }
            //throw new NotImplementedException();
        }
Esempio n. 2
0
        private void GenSerialNo_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
        {
            // eRFXLImpType impType = eRFXLImpType.Production;
            IObjectSpace objectSpace = Application.CreateObjectSpace();
            // IObjectSpace objectSpace = ObjectSpace.CreateNestedObjectSpace();


            RepackLotGenerate lotGenSerial = (RepackLotGenerate)e.PopupWindowView.CurrentObject;
            RepackLots        lsg          = lotGenSerial.LotId;

            RepackLots   RL = (RepackLots)objectSpace.GetObjectByKey(typeof(RepackLots), lsg.Oid);
            eSerialTypes stype;
            int          snumber = 1965;

            if (lsg == null)
            {
                stype = eSerialTypes.sequential;
            }
            stype = RL.RepackItem.SerialType;

            //lsg.RepackItem.SerialType;
            switch (stype)
            {
            case eSerialTypes.sequential:
            {
                int lastSerialNumber = 0;
                lastSerialNumber = RL.LastSerialNumber;
                //Generates Partials
                for (int i = 1; i < lotGenSerial.QtyOfPartial + 1; i++)
                {
                    lastSerialNumber++;
                    string            snum      = lastSerialNumber.ToString().PadLeft(2, '0');
                    RepackLotSerialNo LotSerial = objectSpace.CreateObject <RepackLotSerialNo>();
                    LotSerial.RepackLot = RL;
                    LotSerial.LabelType = eLabelType.InnerCarton;
                    LotSerial.GTIN      = RL.RepackItem.Gtin;
                    LotSerial.isPartial = true;
                    LotSerial.GTIN      = RL.RepackItem.Gtin;
                    LotSerial.SerialNo  = RL.LotId.PadRight(2, '0') + snum;
                    LotSerial.Save();
                }
                //Generates non partials
                for (int i = 1; i < lotGenSerial.QtyToGenerate + 1; i++)
                {
                    lastSerialNumber++;
                    string            snum      = lastSerialNumber.ToString().PadLeft(2, '0');
                    RepackLotSerialNo LotSerial = objectSpace.CreateObject <RepackLotSerialNo>();
                    LotSerial.RepackLot = RL;
                    LotSerial.LabelType = eLabelType.InnerCarton;
                    LotSerial.GTIN      = RL.RepackItem.Gtin;

                    LotSerial.GTIN     = RL.RepackItem.Gtin;
                    LotSerial.SerialNo = RL.LotId.PadRight(2, '0') + snum;
                    LotSerial.Save();
                }


                RL.LastSerialNumber = lastSerialNumber;
                RL.Save();
                break;
            }

            case eSerialTypes.Random:
                Random getRandom = new Random();

                for (int i = 0; i < lotGenSerial.QtyToGenerate; i++)
                {
                    IObjectSpace      objectSpace2 = Application.CreateObjectSpace();
                    RepackLotSerialNo LotSerial    = objectSpace2.CreateObject <RepackLotSerialNo>();
                    LotSerial.RepackLot = RL;
                    LotSerial.LabelType = eLabelType.InnerCarton;
                    LotSerial.GTIN      = RL.RepackItem.Gtin;
                    LotSerial.SerialNo  = lotGenSerial.LotId.ToString() + snumber.ToString("000000") + getRandom.Next(3, 999999).ToString("000000");
                    LotSerial.Save();
                }
                break;

            case eSerialTypes.RFXcel:
                string  gtin = RL.RepackItem.Gtin;
                RFEXCEL rfc  = new RFEXCEL(gtin, lotGenSerial.QtyToGenerate, Application, impType);
                //************************************************
                //
                // Go Get  Serial Number from RXexcel
                //
                //***********************************************
                rfc.PostRequest(gtin, lotGenSerial.QtyToGenerate, e);

                for (int i = 0; i < lotGenSerial.QtyToGenerate; i++)
                {
                    // string is1 = "12345.6789.1111111111";

                    //int lastdot = is1.LastIndexOf(".");
                    //string is2 = is1.Substring(lastdot +1 );
                    RepackLotSerialNo LotSerial = objectSpace.CreateObject <RepackLotSerialNo>();
                    LotSerial.RepackLot = RL;
                    LotSerial.LabelType = eLabelType.InnerCarton;
                    LotSerial.SerialNo  = rfc.SerialList[i];
                    LotSerial.sGTIN     = rfc.sGTIN[i];
                    LotSerial.GTIN      = RL.RepackItem.Gtin;


                    //LotSerial.SerialNo = RL.LotId.ToString() + snumber.ToString("000000") + i + 1.ToString("000000");
                    LotSerial.Save();
                }
                break;
            }
            objectSpace.CommitChanges();
            ObjectSpace.Refresh();
            MessageOptions options = new MessageOptions();

            options.Duration     = 20000;
            options.Message      = string.Format("{0} Serial Number for Lot {1} has been entered", lotGenSerial.QtyToGenerate, lotGenSerial.LotId.LotId.ToString());
            options.Type         = InformationType.Success;
            options.Web.Position = InformationPosition.Right;
            options.Win.Caption  = "Success";
            options.Win.Type     = WinMessageType.Alert;
            //options.OkDelegate = () => {
            //    IObjectSpace os = Application.CreateObjectSpace(typeof(Customer));
            // DetailView newTaskDetailView = Application.CreateDetailView(os, os.CreateObject<ItemRequest>());
            // Application.ShowViewStrategy.ShowViewInPopupWindow(newTaskDetailView);
            //};
            Application.ShowViewStrategy.ShowMessage(options);
        }