コード例 #1
0
        private void UpdateList()
        {
            items = new List <DataDataList>();


            //извлечение данных из 1с   начало
            var mContext = this;

            DataSetWS dataSetWS = new DataSetWS();

            string DatalistResult = string.Empty;

            try
            {
                DatalistResult = dataSetWS.GetList(mRef, AppVariable.Variable.getSessionParametersJSON());
            }
            catch (Exception e)
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, e.Message, ToastLength.Long).Show();
                    mContext.Finish();
                });
                return;
            }

            JObject jsonResult = JObject.Parse(DatalistResult);

            if (jsonResult.Property("Error") == null)
            {
                foreach (JObject Group in jsonResult["Data"])
                {
                    Newtonsoft.Json.Linq.JValue Name        = (Newtonsoft.Json.Linq.JValue)Group["Name"];
                    Newtonsoft.Json.Linq.JValue Ref         = (Newtonsoft.Json.Linq.JValue)Group["Ref"];
                    Newtonsoft.Json.Linq.JValue Description = (Newtonsoft.Json.Linq.JValue)Group["Description"];



                    items.Add(new DataDataList()
                    {
                        Name = (string)Name.Value, Description = (string)Description.Value, Ref = (string)Ref.Value
                    });
                }
            }
            else
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, (string)jsonResult.Property("Error").Value, ToastLength.Long).Show();
                    mContext.Finish();
                });
            }
            //извлечение данных из 1с   конец

            Button nButton = new Android.Support.V7.Widget.AppCompatButton(this)
            {
                Id = 0
            };

            nButton.Text   = "Очистить";
            nButton.Click += clearEquip;
            mLinearLayout.AddView(nButton);

            Button nButton2 = new Android.Support.V7.Widget.AppCompatButton(this)
            {
                Id = 1
            };

            nButton2.Text   = "Выбрать";
            nButton2.Click += finishEquip;
            mLinearLayout.AddView(nButton2);


            TableLayout mTableLayout = new TableLayout(this);
            var         param        = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

            mTableLayout.SetColumnStretchable(0, true);
            mTableLayout.SetColumnShrinkable(0, true);
            mLinearLayout.AddView(mTableLayout, param);



            var curId = 2;

            foreach (var itt in items)
            {
                TableRow mNewRow = new TableRow(this);
                mNewRow.SetGravity(GravityFlags.CenterVertical);
                mTableLayout.AddView(mNewRow);

                TextView mTextViewDesc = new TextView(this);
                mTextViewDesc.Text = itt.Name;
                mNewRow.AddView(mTextViewDesc);


                TextView nTextView = new TextView(this)
                {
                    Id = curId
                };
                nTextView.SetTextSize(Android.Util.ComplexUnitType.Sp, 18);
                nTextView.Text = getSelItemCount(itt.Ref);


                mElements.Add(curId, nTextView);

                mNewRow.AddView(nTextView);
                ImageButton myImageButton1 = new ImageButton(this)
                {
                    Id = curId + 1000
                };
                myImageButton1.SetImageResource(Resource.Drawable.ic_action_new);
                myImageButton1.Click += plusButtonClicked;
                mNewRow.AddView(myImageButton1);

                ImageButton myImageButton2 = new ImageButton(this)
                {
                    Id = curId + 2000
                };
                myImageButton2.SetImageResource(Resource.Drawable.ic_action_minus);
                myImageButton2.Click += minusButtonClicked;
                mNewRow.AddView(myImageButton2);

                curId++;
            }
        }
コード例 #2
0
        public void UpdateList()
        {
            itemsOrig = new List <DataDataList>();
            items     = itemsOrig;

            DataSetWS dataSetWS = new DataSetWS();

            string DatalistResult = string.Empty;

            try
            {
                DatalistResult = dataSetWS.GetList(mRef, AppVariable.Variable.getSessionParametersJSON());
            }
            catch (Exception e)
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, e.Message, ToastLength.Long).Show();
                    mContext.Finish();
                });
                return;
            }

            JObject jsonResult = JObject.Parse(DatalistResult);

            if (jsonResult.Property("Error") == null)
            {
                foreach (JObject Group in jsonResult["Data"])
                {
                    JValue Name        = (JValue)Group["Name"];
                    JValue Ref         = (JValue)Group["Ref"];
                    JValue Description = (JValue)Group["Description"];

                    int imgeID = Resource.Drawable.ic_document;
                    if (Group.Property("Image") != null)
                    {
                        JValue Image = (JValue)Group["Image"];
                        switch ((string)Image.Value)
                        {
                        case "Document":
                            imgeID = Resource.Drawable.ic_document;
                            break;

                        case "DocumentDeleted":
                            imgeID = Resource.Drawable.ic_document_deleted;
                            break;

                        case "DocumentAccept":
                            imgeID = Resource.Drawable.ic_document_accept;
                            break;
                        }
                    }

                    itemsOrig.Add(new DataDataList()
                    {
                        Name = (string)Name.Value, Description = (string)Description.Value, Image = imgeID, Ref = (string)Ref.Value
                    });
                }
                items = itemsOrig;
            }
            else
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, (string)jsonResult.Property("Error").Value, ToastLength.Long).Show();
                    mContext.Finish();
                });
            }
        }