예제 #1
0
        public G_ProductCount Get_Product_Ccount(string pro_num)
        {
            try
            {
                G_ProductCount test = null;
                string         str  = @"{";
                str += "ProNum:'" + pro_num;  //아이디찾기에선 Name으로
                str += "'}";

                //// JSON 문자열을 파싱하여 JObject를 리턴
                JObject jo = JObject.Parse(str);

                UTF8Encoding encoder = new UTF8Encoding();
                byte[]       data    = encoder.GetBytes(jo.ToString()); // a json object, or xml, whatever...

                //request.Method = "POST";
                HttpWebRequest request = WebRequest.Create(Global.WCFURL + "Get_Product_Ccount") as HttpWebRequest;
                request.Method        = "POST";
                request.ContentType   = "application/json";
                request.ContentLength = data.Length;

                //request.Expect = "application/json";

                request.GetRequestStream().Write(data, 0, data.Length);

                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    if (response.StatusCode != HttpStatusCode.OK)
                    {
                        Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
                    }
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        var readdata = reader.ReadToEnd();
                        test = JsonConvert.DeserializeObject <G_ProductCount>(readdata);
                        return(test);
                    }
                }
            }
            catch
            {
                return(null);
            }
        }
예제 #2
0
        private void Showlist()
        {
            List <G_ProductInfo> productlist = new List <G_ProductInfo>();

            #region 네트워크 상태 확인
            var current_network = Connectivity.NetworkAccess;                                               // 현재 네트워크 상태
            if (current_network == NetworkAccess.Internet)                                                  // 네트워크 연결 가능
            {
                productlist = giftDBFunc.PostSelectPurchaseProductToIndex(Global.deal_select_category_num); // 상품 목록 가져오기
            }
            else
            {
                productlist = null;
            }
            #endregion


            #region 네트워크 연결 불가
            if (productlist == null) // 네트워크 연결 불가
            {
                Purchaselist_Grid.Children.Clear();
                Purchaselist_Grid.RowDefinitions.Clear();
                CustomLabel label = new CustomLabel
                {
                    Text              = "네트워크에 연결할 수 없습니다. 다시 시도해 주세요.",
                    Size              = 18,
                    TextColor         = Color.Black,
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center
                };
                Purchaselist_Grid.Children.Add(label, 0, 1);
                return;
            }
            #endregion

            #region 상품권 목록 검색 불가
            if (productlist.Count == 0)
            {
                Purchaselist_Grid.Children.Clear();
                Purchaselist_Grid.RowDefinitions.Clear();
                CustomLabel label = new CustomLabel
                {
                    Text              = "상품권 목록을 불러 올 수 없습니다!",
                    Size              = 18,
                    TextColor         = Color.Black,
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center
                };
                Purchaselist_Grid.Children.Add(label, 0, 1);         //실시간거래 그리드에 라벨추가
                return;
            }
            #endregion

            Purchaselist_Grid.Children.Clear();
            Purchaselist_Grid.RowDefinitions.Clear();

            int row = 0;

            var label_tap = new TapGestureRecognizer();
            label_tap.Tapped += async(s, e) =>
            {
                if (Global.isgiftlistcliecked)
                {
                    Global.isgiftlistcliecked = false;

                    Grid g = (Grid)s;
                    Global.deal_select_category_value = "구매";
                    await Navigation.PushAsync(new PurchasePage(ddp, productlist[int.Parse(g.BindingContext.ToString())], Global.deal_select_category_num));
                }
            };

            var label_tap2 = new TapGestureRecognizer();
            label_tap2.Tapped += async(s, e) =>
            {
                if (Global.isgiftlistcliecked)
                {
                    Global.isgiftlistcliecked = false;
                    await ddp.ShowMessage("품절상품입니다", "알림", "확인", async() =>
                    {
                        Global.isgiftlistcliecked = true;
                    });
                }
            };


            for (int i = 0; i < productlist.Count; i++)
            {
                G_ProductCount g_count = new G_ProductCount();
                #region 네트워크 상태 확인
                if (current_network == NetworkAccess.Internet) // 네트워크 연결 가능
                {
                    g_count = giftDBFunc.Get_Product_Ccount(productlist[i].PRONUM);
                }
                else
                {
                    g_count = null;
                }
                #endregion

                #region 네트워크 연결 불가
                if (g_count == null) // 네트워크 연결 불가
                {
                    CustomLabel label = new CustomLabel
                    {
                        Text              = "네트워크에 연결할 수 없습니다. 다시 시도해 주세요.",
                        Size              = 18,
                        TextColor         = Color.Black,
                        VerticalOptions   = LayoutOptions.Center,
                        HorizontalOptions = LayoutOptions.Center
                    };
                    Purchaselist_Grid.Children.Add(label, 0, 1);         //실시간거래 그리드에 라벨추가
                    return;
                }
                #endregion

                Purchaselist_Grid.RowDefinitions.Add(new RowDefinition {
                    Height = 100
                });
                Purchaselist_Grid.RowDefinitions.Add(new RowDefinition {
                    Height = 1
                });
                #region list 그리드
                Grid listgrid = new Grid
                {
                    Margin            = new Thickness(15, 5, 0, 5),
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    RowSpacing        = 0,
                    ColumnSpacing     = 0,
                    BindingContext    = i,
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = 100
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        }
                    }
                };
                #endregion

                CachedImage image = null;
                if (int.Parse(g_count.PAPER_GC_COUNT) == 0 && int.Parse(g_count.PIN_GC_COUNT) == 0)
                {
                    #region 이미지
                    image = new CachedImage
                    {
                        LoadingPlaceholder = Global.LoadingImagePath,
                        ErrorPlaceholder   = Global.NotFoundImagePath,
                        Source             = ImageSource.FromUri(new Uri(Global.server_ipadress + productlist[i].PRODUCTIMAGE)),
                        BackgroundColor    = Color.White,
                        VerticalOptions    = LayoutOptions.Center,
                        Aspect             = Aspect.AspectFill,
                        Margin             = 20,
                    };
                    #endregion
                }
                else
                {
                    #region 이미지
                    image = new CachedImage
                    {
                        LoadingPlaceholder = Global.LoadingImagePath,
                        ErrorPlaceholder   = Global.NotFoundImagePath,
                        Source             = ImageSource.FromUri(new Uri(Global.server_ipadress + productlist[i].PRODUCTIMAGE)),
                        BackgroundColor    = Color.White,
                        VerticalOptions    = LayoutOptions.Center,
                        Aspect             = Aspect.AspectFill,
                        Margin             = 20,
                    };
                    #endregion
                }

                #region label 그리드
                Grid labelgrid = new Grid
                {
                    Margin            = new Thickness(10, 0, 0, 0),
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    RowSpacing        = 5,
                    ColumnSpacing     = 0,
                    RowDefinitions    =
                    {
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        }
                    }
                };
                #endregion

                #region 상풍권 이름 Label
                CustomLabel Name_label = new CustomLabel
                {
                    Text              = productlist[i].PRODUCTTYPE + " " + productlist[i].PRODUCTVALUE,
                    Size              = 18,
                    TextColor         = Color.Black,
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Start
                };
                #endregion

                #region 할인율 Label
                var formattedString = new FormattedString();
                formattedString.Spans.Add(new Span
                {
                    Text       = "고객구매가(할인율) : ",
                    LineHeight = 1.8,
                    TextColor  = Color.Black
                });

                formattedString.Spans.Add(new Span
                {
                    Text       = productlist[i].PURCHASEDISCOUNTPRICE + " [" + productlist[i].PURCHASEDISCOUNTRATE + "%]",
                    LineHeight = 1.8,
                    TextColor  = Color.Red
                });

                CustomLabel discountrate_label = new CustomLabel
                {
                    FormattedText         = formattedString,
                    Size                  = 12,
                    TextColor             = Color.Black,
                    VerticalOptions       = LayoutOptions.Center,
                    VerticalTextAlignment = TextAlignment.Center,
                    HorizontalOptions     = LayoutOptions.Start
                };
                #endregion

                #region 상풍권 수량 Label

                /*
                 * var CountformattedString = new FormattedString();
                 * CountformattedString.Spans.Add(new Span
                 * {
                 *  Text = "지류 : ",
                 *  LineHeight = 1.8,
                 *  TextColor = Color.Black
                 * });
                 *
                 * CountformattedString.Spans.Add(new Span
                 * {
                 *  Text = test.PAPER_GC_COUNT + " 개",
                 *  LineHeight = 1.8,
                 *  TextColor = Color.FromHex("#ef7d1a")
                 * });
                 * CountformattedString.Spans.Add(new Span
                 * {
                 *  Text = " 핀번호 : ",
                 *  LineHeight = 1.8,
                 *  TextColor = Color.Black
                 * });
                 *
                 * CountformattedString.Spans.Add(new Span
                 * {
                 *  Text = test.PIN_GC_COUNT + " 개",
                 *  LineHeight = 1.8,
                 *  TextColor = Color.FromHex("#ef7d1a")
                 * });
                 * CustomLabel ProCount_label = new CustomLabel
                 * {
                 *  FormattedText = CountformattedString,
                 *  Size = 10,
                 *  VerticalOptions = LayoutOptions.Center,
                 *  YAlign = TextAlignment.Center,
                 *  HorizontalOptions = LayoutOptions.Start
                 * };
                 */
                #endregion

                #region label 그리드에 추가
                labelgrid.Children.Add(Name_label, 0, 0);         //약관 그리드에 라벨추가
                labelgrid.Children.Add(discountrate_label, 0, 1); //약관 그리드에 Radio이미지 추가
                //labelgrid.Children.Add(ProCount_label, 0, 2);         //약관
                #endregion

                #region label 그리드에 추가
                listgrid.Children.Add(image, 0, 0);     //부모그리드에 약관 그리드 추가
                listgrid.Children.Add(labelgrid, 1, 0); //약관 그리드에 라벨추가
                #endregion

                #region Purchaselist 그리드에 추가
                Purchaselist_Grid.Children.Add(listgrid, 0, row); //부모그리드에 약관 그리드 추가
                row++;
                #endregion

                #region list 그리드 클릭이벤트
                if (int.Parse(g_count.PAPER_GC_COUNT) != 0 || int.Parse(g_count.PIN_GC_COUNT) != 0)
                {
                    listgrid.GestureRecognizers.Add(label_tap); //라벨 클릭 이벤트 등록
                }
                else
                {
                    listgrid.GestureRecognizers.Add(label_tap2); //라벨 클릭 이벤트 등록
                }
                #endregion

                BoxView gridline = new BoxView
                {
                    BackgroundColor   = Color.FromHex("#f4f2f2"),
                    HeightRequest     = 1,
                    VerticalOptions   = LayoutOptions.End,
                    HorizontalOptions = LayoutOptions.FillAndExpand
                };
                Purchaselist_Grid.Children.Add(gridline, 0, row);
                row++;
            }
        }