Esempio n. 1
0
        //NavigationPage.SetHasNavigationBar(this, false);

        internal async void AddEntryPage()
        {
            var listdata = await StorageControl.PCLLoadCommand();//登録データ読み込み

            // カンマ区切りで分割して配列に格納する
            string[] stArrayData = listdata.Split('\n');

            var id = stArrayData.Length;

            Entry usercode   = code;
            Entry usercost   = stock;
            Entry usershares = price;



            ToolbarItems.Add(new ToolbarItem
            {                       // <-2
                Text    = "Cansel", // <-3
                Command = new Command(() => Navigation.PopAsync())
            });


            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Add.",
                Command = new Command(() => AddData(usercode, usercost, usershares, stArrayData))
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Ons the label clicked.
        /// </summary>
        /// <param name="ID"></param>
        public async static void Deleet(int ID)
        {
            //List<string> listdata = new List<string>();
            var listdata = await StorageControl.PCLLoadCommand();//登録データ読み込み

            // カンマ区切りで分割して配列に格納する
            string[] stArrayData = listdata.Split('\n');
            stArrayData[ID] = null;//削除行をnullで消す

            int i = 0;


            foreach (string row in stArrayData)
            {
                if (string.IsNullOrEmpty(row) != true)//null行を読み飛ばす
                {
                    stArrayData[i] = row;
                    i++;
                }
            }
            stArrayData[i] = "null";//最下行を消去する

            //要素数5の配列
            //int[] intArray = { 0, 1, 2, 3, 4 };
            //要素数を10に増やす
            Array.Resize(ref stArrayData, i);



            //// 配列内のデータをすべて\n区切りで連結する
            string CsvData = string.Join("\n", stArrayData);

            // UTF8のファイルの書き込み Edit.
            string write = await StorageControl.PCLSaveCommand(CsvData);//登録データ書き込み
        }
Esempio n. 3
0
        public async void DispSet(bool Refresh)
        {
            int     i                = 0;
            decimal TotalAssetAdd    = 0;
            decimal PayAssetpriceAdd = 0;

            try
            {
                // UTF8のファイルの書き込み Edit.
                //string write = await StorageControl.PCLSaveCommand("6758,200,1665\n9837,200,712\n6976,200,1846\n6502,0,0");//登録データ書き込み
                // List<Price> prices = Finance.Parse(await StorageControl.PCLLoadCommand());//登録データ読み込み
                List <Price> pricesanser = await Models.PasonalGetserchi();//登録データの現在値を取得する


                if (Refresh == true)
                {
                    ItemList.Clear();// 全て削除
                }

                foreach (Price item in pricesanser)
                {
                    ItemList.Add(new Price
                    {
                        Name      = item.Name,      // "Sony",
                        Stocks    = item.Stocks,    //保有数*
                        Itemprice = item.Itemprice, //
                        Prev_day  = item.Prev_day,  //前日比±**
                        Realprice = item.Realprice, //現在値*// 1000,
                        RealValue = item.RealValue, // 1
                        Idindex   = i,
                        // ButtonColor = item.Polar,
                        Polar = item.Polar,
                        // FirstLastName = item.FirstLastName,
                        Percent = item.Percent, //前日比%**// "5"
                        Gain    = item.Gain,    //損益Name
                    });


                    PayAssetpriceAdd = PayAssetpriceAdd + (pricesanser[i].Stocks * Convert.ToDecimal(pricesanser[i].Itemprice)); //株数*購入単価の合計
                    TotalAssetAdd    = TotalAssetAdd + (pricesanser[i].Stocks * Convert.ToDecimal(pricesanser[i].Realprice));    //現在評価額
                                                                                                                                 //Gain = item.Realprice - item.Itemprice;
                    i = ++i;
                }
                PayAssetprice = PayAssetpriceAdd;
                TotalAsset    = TotalAssetAdd;
                UptoAsset     = TotalAsset - PayAssetprice;
            }
            catch (System.IO.FileNotFoundException)
            {
                await View.DisplayAlert("登録データがありません", "Add.ボタンを押して登録して下さい。", "OK");

                await StorageControl.PCLSaveCommand("");//新規ファイル登録書き込み
            }
        }
Esempio n. 4
0
        public async static void DataStorageAdd(string[] Adddata)
        {
            //// カンマ区切りで分割して配列に格納する
            //string[] stArrayData = listdata.Split('\n');
            ////stArrayData[ID] = sender;

            ////// 配列内のデータをすべてカンマ区切りで連結する
            string CsvData = string.Join("\n", Adddata);

            //// UTF8のファイルの書き込み Edit.
            string write = await StorageControl.PCLSaveCommand(CsvData);//登録データ書き込み
        }
Esempio n. 5
0
        }//class to end

        /// <summary>
        /// Ons the label clicked.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public async static void DataStorage(int ID, string sender)
        {
            //List<string> listdata = new List<string>();
            var listdata = await StorageControl.PCLLoadCommand();//登録データ読み込み

            // カンマ区切りで分割して配列に格納する
            string[] stArrayData = listdata.Split('\n');
            stArrayData[ID] = sender;

            //// 配列内のデータをすべてカンマ区切りで連結する
            string CsvData = string.Join("\n", stArrayData);

            // UTF8のファイルの書き込み Edit.
            string write = await StorageControl.PCLSaveCommand(CsvData);//登録データ書き込み



            //string Usercost = usercost.Text;
            //string Usershares = usershares.Text;
            //string[] cols;
            ////string[] savedata;
            //string[] entrydata = new string[3];
            //string[] mergedArray = entrydata;//連結データ
            //string[] returncode = new string[] { "\n" };


            //    string response = await saveLoadCS.DataLoadAsync();//.Replace("\r", "").Split('\n');
            //    string[] rows = response.Split('\r');
            //    cols = rows;
            //    entrydata[0] = Usercode;//usercode.Text = "Code or Cost or Usershares failed";
            //    entrydata[1] = Usercost;
            //    entrydata[2] = Usershares;

            //    if (response != "")
            //    {
            //        foreach (string row in rows)
            //        {
            //            if (string.IsNullOrEmpty(row)) continue;
            //            cols = row.Split(',');
            //        }
            //        //Concatで連結して、ToArrayで配列にする
            //        mergedArray = cols.Concat(entrydata).ToArray();
            //    }

            //}
            //// 配列内のデータをすべてカンマ区切りで連結する
            //string CsvData = string.Join(",", mergedArray);
            //await saveLoadCS.DataSaveAsync(CsvData + "\n");
            //await DisplayAlert("SAVE", " is InputData", "OK");
            ////InsertRange メソッド
        }
Esempio n. 6
0
        //NavigationPage.SetHasNavigationBar(this, false);

        internal async void AddEntryPage()
        {
            var listdata = await StorageControl.PCLLoadCommand();//登録データ読み込み

            // カンマ区切りで分割して配列に格納する
            string[] stArrayData = listdata.Split('\n');

            var id = stArrayData.Length;
            var ID = new Label {
                Text = id.ToString(), TextColor = Color.Red
            };

            Entry usercode = new Entry {
                Placeholder = "Code", TextColor = Color.Black, Keyboard = Keyboard.Default
            };
            Entry usercost = new Entry {
                Placeholder = "Stock", TextColor = Color.Black, Keyboard = Keyboard.Numeric
            };
            Entry usershares = new Entry {
                Placeholder = "Value", TextColor = Color.Black, Keyboard = Keyboard.Numeric
            };


            Content = new StackLayout
            {
                Padding         = 20,
                BackgroundColor = Color.White,
                VerticalOptions = LayoutOptions.StartAndExpand,
                Children        = { ID, usercode, usercost, usershares, }
            };



            ToolbarItems.Add(new ToolbarItem
            {                       // <-2
                Text    = "Cansel", // <-3
                Command = new Command(() => Navigation.PopAsync())
            });


            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Add.",
                Command = new Command(() => AddData(id, usercode, usercost, usershares, stArrayData))
            });
        }
Esempio n. 7
0
        public async void RefDispSet()
        {
            int     i                = 0;
            decimal TotalAssetAdd    = 0;
            decimal PayAssetpriceAdd = 0;



            // UTF8のファイルの書き込み Edit.
            string write = await StorageControl.PCLSaveCommand("6758,200,1665\n9837,200,712\n6976,200,1846");//登録データ書き込み

            // List<Price> prices = Finance.Parse(await StorageControl.PCLLoadCommand());//登録データ読み込み
            List <Price> priceanser = await Models.PasonalGetserchi();//登録データの現在値を取得する


            foreach (Price item in priceanser)
            {
                ItemList.Add(new Price
                {
                    Name      = item.Name,                                                                                 // "Sony",
                    Stocks    = item.Stocks,                                                                               //保有数*
                    Itemprice = item.Itemprice,                                                                            // 2015,
                    Prev_day  = item.Prev_day,                                                                             //前日比±**
                    Realprice = item.Realprice,                                                                            //現在値*// 1000,
                    RealValue = item.RealValue,                                                                            // 100,
                    Percent   = item.Percent,                                                                              //前日比%**// "5"
                });
                PayAssetpriceAdd = PayAssetpriceAdd + (priceanser[i].Stocks * Convert.ToDecimal(priceanser[i].Itemprice)); //株数*購入単価の合計
                TotalAssetAdd    = TotalAssetAdd + (priceanser[i].Stocks * Convert.ToDecimal(priceanser[i].Realprice));    //現在評価額

                i = ++i;
            }

            PayAssetprice = PayAssetpriceAdd;
            TotalAsset    = TotalAssetAdd;
            UptoAsset     = TotalAsset - PayAssetprice;
        }
Esempio n. 8
0
        ///
        /// <summary>
        /// Pasonals the getserchi.
        /// </summary>
        /// <returns>The getserchi.</returns>
        public static async Task <List <Price> > PasonalGetserchi()//企業名を設定して現在値を取得する
        {
            string Value        = null;
            string YenRatio     = null;
            string PercentRatio = null;
            int    index        = 0;

            // UTF8のファイルの読み込み Edit.
            string responce = await StorageControl.PCLLoadCommand();//登録データ読み込み

            List <Price> prices = Finance.Parse(responce);

            foreach (Price price in prices)
            {
                string url = "http://stocks.finance.yahoo.co.jp/stocks/detail/?code=" + price.Name;// +".T";

                var    httpClient = new HttpClient();
                string str        = await httpClient.GetStringAsync(url);

                string searchWord = "stoksPrice";            //検索する文字列 ="stoksPrice">
                int    foundIndex = str.IndexOf(searchWord); //始めの位置を探す
                                                             //次の検索開始位置
                int nextIndex = foundIndex + searchWord.Length;
                try
                {
                    //次の位置を探す
                    foundIndex = str.IndexOf(searchWord, nextIndex);
                    if (foundIndex != -1)
                    {
                        int i = searchWord.Length + 2;//pricedata to point
                        for (; Convert.ToString(str[foundIndex + i]) != "<"; i++)
                        {
                            Value = Value + str[foundIndex + i];//current value 現在値
                        }
                    }
                    else
                    {
                        //price[0] = "Error";
                    }

                    string searchWord1 = "yjMSt";                  //検索する文字列前日比
                    int    foundIndex1 = str.IndexOf(searchWord1); //始めの位置を探す
                    int    i1          = searchWord1.Length + 2;

                    for (; Convert.ToString(str[foundIndex1 + i1]) != "("; i1++)
                    {
                        YenRatio = YenRatio + str[foundIndex1 + i1];//previous 前日比? ¥
                    }

                    if (Convert.ToString(str[foundIndex1 + i1 + 1]) == "-") //(-)下落
                    {
                        price.Polar = "Green";                              //(-)
                    }
                    else
                    {
                        price.Polar = "Red";//(+)
                    }


                    i1++;
                    for (; Convert.ToString(str[foundIndex1 + i1]) != ")"; i1++)
                    {
                        PercentRatio = PercentRatio + str[foundIndex1 + i1];//previous 前日比? %
                    }


                    if (Value == "---")
                    {
                        price.Realprice = 000;
                    }
                    else
                    {
                        price.Realprice = Convert.ToDecimal(Value);                           //現在値
                    }
                    price.Prev_day      = YenRatio;                                           //前日比±
                    price.Percent       = PercentRatio;                                       //前日比%
                    price.PayAssetprice = price.Stocks * price.Itemprice;                     //株数*購入単価
                    price.Gain          = (price.Realprice - price.Itemprice) * price.Stocks; //損益
                    price.RealValue     = (price.Stocks * price.Realprice);                   //個別利益


                    Value        = "";
                    YenRatio     = "";
                    PercentRatio = "";
                    index        = index + 1;
                }
                catch (Exception)
                {
                    price.Prev_day = "Close";
                    price.Polar    = "Gray";
                }
            }

            return(prices);//polarity;
        }//class to end