示例#1
0
        async void GetNewPalletList()
        {
            try
            {
                var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.loadNewPalletURL(id, productPallet.ProductLinkId), this);

                clsResponse newPallet_response = JsonConvert.DeserializeObject <clsResponse>(content);

                if (newPallet_response.IsGood)
                {
                    newPallet      = JObject.Parse(content)["Result"].ToObject <clsPalletNew>();
                    unitBox.Text   = newPallet.DefaultProductUom;
                    statusBox.Text = newPallet.DefaultStockStatus;

                    foreach (clsKeyValue size in newPallet.PalletSize)
                    {
                        sizes.Add(size.Value);
                        string[] defaultSize = size.Value.Split('(');
                        if (defaultSize[1].Contains(newPallet.DefaultProductUom))
                        {
                            sizeBox.Text = size.Value;
                        }
                    }

                    foreach (clsKeyValue unit in newPallet.ProductUom)
                    {
                        units.Add(unit.Key);
                    }

                    foreach (clsKeyValue status_ in newPallet.StockStatus)
                    {
                        status.Add(status_.Key);
                    }

                    sizeBox.ComboBoxSource   = sizes;
                    unitBox.ComboBoxSource   = units;
                    statusBox.ComboBoxSource = status;

                    if (newPallet.ControlVolume != "H")
                    {
                        clsAttribute volume = new clsAttribute
                        {
                            Key     = "M3",
                            Caption = "M3",
                            Value   = newPallet.ControlVolume
                        };

                        newPallet.Attribute.Add(volume);
                    }

                    if (newPallet.ControlWeight != "H")
                    {
                        clsAttribute weight = new clsAttribute
                        {
                            Key     = "KG",
                            Caption = "KG",
                            Value   = newPallet.ControlWeight
                        };

                        newPallet.Attribute.Add(weight);
                    }

                    int row = 4, column = 0;
                    foreach (clsAttribute attr in newPallet.Attribute)
                    {
                        customDatePicker = null;
                        customEntry      = null;

                        grid.RowDefinitions.Add(new RowDefinition {
                            Height = GridLength.Star
                        });

                        Label fieldLbl = new Label
                        {
                            Text                  = attr.Caption,
                            FontAttributes        = FontAttributes.Bold,
                            VerticalTextAlignment = TextAlignment.Center
                        };

                        StackLayout entryStack = new StackLayout
                        {
                            Orientation = StackOrientation.Horizontal,
                            StyleId     = attr.Key
                        };

                        if (attr.Key == "ExpiryDate" || attr.Key == "MfgDate")
                        {
                            customDatePicker = new CustomDatePicker
                            {
                                StyleId           = attr.Key,
                                HorizontalOptions = LayoutOptions.FillAndExpand,
                                NullableDate      = null
                            };

                            customDatePicker.Unfocused += (object sender, FocusEventArgs e) =>
                            {
                                DateUnfocus(sender);
                            };

                            entryStack.Children.Add(customDatePicker);
                        }
                        else
                        {
                            customEntry = new CustomEntry
                            {
                                StyleId           = attr.Key,
                                HorizontalOptions = LayoutOptions.FillAndExpand,
                            };

                            customEntry.Completed += Handle_Completed;

                            customEntry.Behaviors.Add(new MaxLengthValidation {
                                MaxLength = 50
                            });

                            if (attr.Key == "M3" || attr.Key == "KG")
                            {
                                customEntry.Keyboard = Keyboard.Numeric;
                            }

                            entryStack.Children.Add(customEntry);
                        }


                        if (attr.Value == "M")
                        {
                            if (customEntry != null)
                            {
                                customEntry.LineColor = Color.LightYellow;
                            }
                            if (customDatePicker != null)
                            {
                                customDatePicker.BackgroundColor = Color.LightYellow;
                            }
                        }
                        else
                        {
                            if (customEntry != null)
                            {
                                customEntry.LineColor = Color.WhiteSmoke;
                            }
                            else if (customDatePicker != null)
                            {
                                customDatePicker.BackgroundColor = Color.WhiteSmoke;
                            }
                        }

                        if (attr.Key != "ExpiryDate" && attr.Key != "MfgDate" && attr.Key != "M3" && attr.Key != "KG")
                        {
                            Image scan = new Image
                            {
                                Source          = "barCode.png",
                                WidthRequest    = 60,
                                HeightRequest   = 30,
                                VerticalOptions = LayoutOptions.Center,
                                StyleId         = attr.Key
                            };

                            var scan_barcode = new TapGestureRecognizer
                            {
                                NumberOfTapsRequired = 1
                            };

                            scan_barcode.Tapped += (sender, e) =>
                            {
                                var image = sender as Image;

                                EntryScan(image);
                            };
                            scan.GestureRecognizers.Add(scan_barcode);

                            entryStack.Children.Add(scan);
                        }

                        grid.Children.Add(fieldLbl, column, row);
                        column++;
                        grid.Children.Add(entryStack, column, row);
                        row++;
                        column = 0;
                    }
                }
                else
                {
                    await DisplayAlert("Error", newPallet_response.Message, "OK");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");
            }
        }
示例#2
0
 public clsMethod(string refName, clsAttribute refAttribute)
 {
     referenceName      = refName;
     referenceAttribute = refAttribute;
 }