예제 #1
0
        public static LicenseWS ParsedLicToLicenceWS(ParsedLicence parsedLic)
        {
            LicenseWS result = new LicenseWS();

            result.productSSCC    = parsedLic.codeSSCC;
            result.weightKG       = parsedLic.weightKG;
            result.weightLb       = parsedLic.weightLb;
            result.packingDate    = parsedLic.packingDate;
            result.productionDate = parsedLic.productionDate;
            result.expirationDate = parsedLic.ExpirationDate;
            result.saleDate       = parsedLic.SaleDate;
            result.licenseCode    = parsedLic.palletCode;

            return(result);
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState, Resource.Layout.frmReceivingDetails);

            translateScreen();

            // Récupération de la réception
            ReceptionWS reception = (ReceptionWS)ReceivingActivity.data;

            // Action clic pour clear le EditText
            clearTextOnClick(FindViewById <ImageButton>(Resource.Id.imClear), FindViewById <EditText>(Resource.Id.tfLicenseReceivingDetails));

            // Remplir champs de données par rapport à la réception
            FindViewById <TextView>(Resource.Id.tvNumRecieving).Text = reception.ReceptionNRI.ToString();
            FindViewById <TextView>(Resource.Id.tvnameProvider).Text = reception.SupplierCode;

            // Affichage de la dernière licence créer, si pas de licence alors on n'affiche rien
            if (licence != null)
            {
                if (licence.productNRI != 0)
                {
                    // Creation liste de nom produit
                    List <ProductDetailsWS> listProduct = OperationsWebService.getReceptionProductDetails(Configuration.securityToken, reception.ReceptionNRI, (int)Configuration.currentLanguage, Configuration.userInfos.NRI, null).OfType <ProductDetailsWS>().ToList();

                    // On parcourt la liste de produit pour trouver le produit qui correspond à la licence
                    foreach (ProductDetailsWS p in listProduct)
                    {
                        // Puis on affichage les information dans les TextView
                        if (licence.productNRI == p.NRI)
                        {
                            FindViewById <TextView>(Resource.Id.tvNameProduct).Text = p.code;
                            FindViewById <TextView>(Resource.Id.tvAmountQte).Text   = p.qtyPicked.ToString() + "/" + p.qtyToPick.ToString();
                            FindViewById <TextView>(Resource.Id.tvAmountPoids).Text = licence.weightKG.ToString() + " kg";
                        }
                    }
                }
            }

            // Action touche "Enter" pour accèder à la création d'une nouvelle licence
            EditText urlEditText = FindViewById <EditText>(Resource.Id.tfLicenseReceivingDetails);

            urlEditText.KeyPress += (object sender, View.KeyEventArgs e) => {
                e.Handled = false;
                CodeParser parser = new CodeParser();

                if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter)
                {
                    if (urlEditText.Text.ToString() != "")
                    {
                        urlEditText.Text.Replace(" ", "");
                        licence = new LicenseWS();

                        ParsedLicence parsedLicence = parser.getLicense(urlEditText.Text);
                        licence = Converts.ParsedLicToLicenceWS(parsedLicence);

                        if (licence.licenseCode == null)
                        {
                            licence.licenseCode = urlEditText.Text;
                            licence.parentNRI   = reception.ReceptionNRI;
                            data = reception;
                            StartActivity(new Intent(this, typeof(NewLicenseActivity)));
                        }
                        else
                        {
                            licence.parentNRI = reception.ReceptionNRI;
                            // Creation liste de nom produit
                            List <ProductDetailsWS> listProduct = OperationsWebService.getReceptionProductDetails(Configuration.securityToken, reception.ReceptionNRI, (int)Configuration.currentLanguage, Configuration.userInfos.Udp_NRI, Configuration.userInfos.Udp_Label).OfType <ProductDetailsWS>().ToList();


                            foreach (ProductDetailsWS pro in listProduct)
                            {
                                if (pro.SSCC.Contains(licence.productSSCC))
                                {
                                    licence.productNRI = pro.NRI;
                                }
                            }

                            if (licence.productNRI != 0)
                            {
                                data = reception;
                                var produit = OperationsWebService.pickLicenseReception(Configuration.securityToken, licence, (int)Configuration.currentLanguage, Configuration.userInfos.Udp_NRI, Configuration.userInfos.Udp_Label);
                                if (produit == null)
                                {
                                    Toast.MakeText(this, OperationsWebService.errorMessage, ToastLength.Long).Show();
                                    Recreate();
                                }
                                else
                                {
                                    Recreate();
                                }
                            }
                            else
                            {
                                if (Configuration.currentLanguage == CR_TTLangue.French_Canada)
                                {
                                    Toast.MakeText(this, Activities.ResourceFR.errProductNotPresent, ToastLength.Long).Show();
                                }
                                else
                                {
                                    Toast.MakeText(this, Activities.ResourceEN.errProductNotPresent, ToastLength.Long).Show();
                                }
                            }
                        }

                        e.Handled = true;
                    }
                    else
                    {
                        urlEditText.Text = "";
                        switch (Configuration.currentLanguage)
                        {
                        case  CR_TTLangue.French_Canada:
                            Toast.MakeText(this, Activities.ResourceFR.errEmptyFieldLicense, ToastLength.Long).Show();
                            break;

                        case  CR_TTLangue.English:
                            Toast.MakeText(this, Activities.ResourceFR.errEmptyFieldLicense, ToastLength.Long).Show();
                            break;
                        }
                    }
                }
            };

            // Action clic sur détails pour accèder à la liste de produit d'une reception
            FindViewById <ImageButton>(Resource.Id.imDetails).Click += async(sender, e) => {
                data   = reception;
                IsBusy = true;
                await Task.Delay(50);

                StartActivity(new Intent(this, typeof(ProductDetailsActivity)));
                IsBusy = false;
            };

            // Ne peut pas fonctionner, il faudrait ajouter une méthode dans les web services afin d'ajouter des licences sur une palette.

            /*// Action clic sur palette pour mettre toutes les licences crées sur la palette
             * FindViewById<Button>(Resource.Id.btnPalette).Click += async (sender, e) => {
             *  if (licences != null)
             *  {
             *
             *      IsBusy = true;
             *      await Task.Delay(50);
             *      var test1 = "1302";
             *      var test2 = "111";
             *      var codePalette = OperationsWebService.createPalletCode(Configuration.securityToken, ref test1, ref test2);
             *      string msg = "Licence non transférée : ";
             *      bool isSucess = true;
             *      licences.Remove(licence);
             *
             *      foreach (LicenseWS lic in licences)
             *      {
             *          if (!(OperationsWebService.relocateLicense(Configuration.securityToken, lic.licenseCode, codePalette, RELOCATION_DESTINATION.Pallet, Configuration.userInfos.warehouseNRI)))
             *          {
             *              isSucess = false;
             *              msg += lic.licenseCode + ", ";
             *          }
             *      }
             *      IsBusy = false;
             *      if (isSucess)
             *      {
             *          Toast.MakeText(this, "Les licences ont été transférées", ToastLength.Long).Show();
             *
             *      }
             *      else
             *      {
             *          Toast.MakeText(this, msg, ToastLength.Long).Show();
             *
             *      }
             *      Recreate();
             *  }
             *  else
             *  {
             *      Toast.MakeText(this, "Veuillez insérer des licences", ToastLength.Long).Show();
             *  }
             * };*/

            // Action clic sur bouton pour completer une reception
            FindViewById <Button>(Resource.Id.btnEndReceiving).Click += async(sender, e) => {
                IsBusy = true;
                await Task.Delay(50);

                OperationsWebService.completeReception(Configuration.securityToken, reception.ReceptionNRI);
                IsBusy      = false;
                mustRefresh = true;

                Finish();
            };
        }
예제 #3
0
    public ParsedLicence getLicense(string input)
    {
        ParsedLicence parsedLicense = new ParsedLicence();
        CultureInfo   provider      = CultureInfo.InvariantCulture;
        string        matchedGroup  = string.Empty;

        if (Regex.IsMatch(input, "^(01).*"))
        {
            bool groupParsed;
            while (input.Length > 0)
            {
                groupParsed = false;
                foreach (KeyValuePair <string, GroupDefinition> pair in patterns)
                {
                    string currentPattern = "^" + pair.Key + "(.{" + pair.Value.minLength.ToString() + "," + pair.Value.maxLength.ToString() + "})";

                    if (Regex.IsMatch(input, currentPattern))
                    {
                        matchedGroup = Regex.Split(input, currentPattern)[1];

                        switch (pair.Value.field)
                        {
                        case GroupDefinitionField.codeSSCC:
                        {
                            parsedLicense.codeSSCC = matchedGroup;
                            groupParsed            = true;
                            break;
                        }

                        case GroupDefinitionField.packingDate:
                        {
                            parsedLicense.packingDate = DateTime.ParseExact(matchedGroup, "yyMMdd", provider);
                            groupParsed = true;
                            break;
                        }

                        case GroupDefinitionField.productionDate:
                        {
                            parsedLicense.productionDate = DateTime.ParseExact(matchedGroup, "yyMMdd", provider);
                            groupParsed = true;
                            break;
                        }

                        case GroupDefinitionField.ExpirationDate:
                        {
                            parsedLicense.ExpirationDate = DateTime.ParseExact(matchedGroup, "yyMMdd", provider);
                            groupParsed = true;
                            break;
                        }

                        case GroupDefinitionField.SaleDate:
                        {
                            parsedLicense.SaleDate = DateTime.ParseExact(matchedGroup, "yyMMdd", provider);
                            groupParsed            = true;
                            break;
                        }

                        case GroupDefinitionField.weightKG:
                        {
                            parsedLicense.weightKG = parseWeight(matchedGroup);
                            groupParsed            = true;
                            break;
                        }

                        case GroupDefinitionField.weightLb:
                        {
                            parsedLicense.weightLb = parseWeight(matchedGroup);
                            groupParsed            = true;
                            break;
                        }

                        case GroupDefinitionField.Count:
                        {
                            parsedLicense.Count = Int32.Parse(matchedGroup);
                            groupParsed         = true;
                            break;
                        }

                        case GroupDefinitionField.palletCode:
                        {
                            parsedLicense.palletCode = matchedGroup;
                            groupParsed = true;
                            break;
                        }

                        default:
                        {
                            //throw new InvalidStringFormatException(input.Substring(0, 2));
                            break;
                        }
                        }

                        input = Regex.Split(input, currentPattern)[2];
                    }
                }
                if (!groupParsed)
                {
                    //throw new InvalidStringFormatException(input.Substring(0, 2));
                }
            }
        }
        else
        {
            //throw new InvalidStringFormatException(input.Substring(0, 2));
        }

        if (parsedLicense.weightKG == 0 & parsedLicense.weightLb != 0)
        {
            parsedLicense.weightKG = parsedLicense.weightLb * lbToKgRatio;
        }

        return(parsedLicense);
    }
예제 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState, Resource.Layout.frmPickingDetails);

            translateScreen();

            clearTextOnClick(FindViewById <ImageButton>(Resource.Id.imClear), FindViewById <EditText>(Resource.Id.tfLicensePickingDetails));

            SaleWS sale = (SaleWS)PickingListActivity.data;


            // Remplir champs de données par rapport à la réception
            FindViewById <TextView>(Resource.Id.tvNumPicking).Text = sale.saleNRI.ToString();
            FindViewById <TextView>(Resource.Id.tvnameClient).Text = sale.customerCode;

            // Action clic sur détails pour accèder à la liste de produit d'une reception
            FindViewById <ImageButton>(Resource.Id.imDetails).Click += async(sender, e) => {
                data   = sale;
                IsBusy = true;
                await Task.Delay(50);

                StartActivity(new Intent(this, typeof(ProductDetailsActivity)));
                IsBusy = false;
            };

            // Action clic sur bouton pour completer une reception
            FindViewById <Button>(Resource.Id.btnEndPicking).Click += async(sender, e) => {
                IsBusy = true;
                await Task.Delay(50);

                OperationsWebService.completeSale(Configuration.securityToken, sale.saleNRI);
                IsBusy      = false;
                mustRefresh = true;
                Finish();
            };

            // Affichage de la dernière licence créer, si pas de licence alors on n'affiche rien
            if (licence != null)
            {
                // Creation liste de nom produit
                List <ProductDetailsWS> listProduct = OperationsWebService.getSaleProductDetails(Configuration.securityToken, sale.saleNRI, (int)Configuration.currentLanguage, Configuration.userInfos.Udp_NRI).OfType <ProductDetailsWS>().ToList();

                foreach (ProductDetailsWS p in listProduct)
                {
                    // On parcourt la liste de produit pour trouver le produit qui correspond à la licence
                    foreach (PickedLicensesWS l in p.pickedProducts)
                    {
                        // Puis on affichage les information dans les TextView
                        if (licence.licenseCode == l.code)
                        {
                            FindViewById <TextView>(Resource.Id.tvNameProduct).Text = p.code;
                            FindViewById <TextView>(Resource.Id.tvAmountQte).Text   = p.qtyPicked.ToString();
                            FindViewById <TextView>(Resource.Id.tvAmountPoids).Text = l.weight.ToString() + " kg";
                        }
                    }
                }
            }

            EditText editText = FindViewById <EditText>(Resource.Id.tfLicensePickingDetails);

            editText.KeyPress += (object sender, View.KeyEventArgs e) => {
                e.Handled = false;

                CodeParser parser = new CodeParser();


                if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter)
                {
                    if (editText.Text.ToString() != "")
                    {
                        editText.Text.Replace(" ", "");
                        licence = new LicenseWS();

                        ParsedLicence parsedLicence = parser.getLicense(editText.Text);
                        licence = Converts.ParsedLicToLicenceWS(parsedLicence);

                        if (licence.licenseCode == null)
                        {
                            licence.licenseCode = editText.Text;
                        }

                        licence.parentNRI = sale.saleNRI;

                        var productResult = OperationsWebService.PickLicenseSale(Configuration.securityToken, licence, Configuration.userInfos.warehouseNRI, Configuration.userInfos.warehouseNRI, Configuration.userInfos.Udp_NRI);
                        if (productResult == null)
                        {
                            Toast.MakeText(this, OperationsWebService.errorMessage, ToastLength.Long).Show();
                            OperationsWebService.errorMessage = "";
                        }
                        else
                        {
                            switch (Configuration.currentLanguage)
                            {
                            case CR_TTLangue.French_Canada:
                            {
                                Toast.MakeText(this, "Licence ajoutée", ToastLength.Long).Show();

                                break;
                            }

                            case CR_TTLangue.English:
                            {
                                Toast.MakeText(this, "License added", ToastLength.Long).Show();
                                break;
                            }
                            }
                        }
                        data = sale;

                        Recreate();
                        e.Handled = true;
                    }
                    else
                    {
                        editText.Text = "";
                        switch (Configuration.currentLanguage)
                        {
                        case CR_TTLangue.French_Canada:
                        {
                            Toast.MakeText(this, Activities.ResourceFR.errEmptyFieldLicense, ToastLength.Long).Show();

                            break;
                        }

                        case CR_TTLangue.English:
                        {
                            Toast.MakeText(this, Activities.ResourceEN.errEmptyFieldLicense, ToastLength.Long).Show();
                            break;
                        }
                        }
                    }
                }
            };
        }