ЭКОНОМИЧЕСКОЕ ОБОСНОВАНИЕ ЦЕЛЕСООБРАЗНОСТИ ПРОЕКТА



Данный проект сам по себе направлен на то, чтобы увеличить прибыль, извлекаемую из трейдинга, поскольку чем более выгодные предметы будут задействованы в процессах продажи и обмена, тем большую выгоду может извлечь человек, занимающийся трейдингом. Следующей причиной, делающей реализованный комплекс программ целесообразным для использования, – экономия средств, которые затрачиваются на приобретение подписок и доступов к базам на сайтах, рассмотренных в качестве примера. Каждый из них функционирует по принципу условно-бесплатного доступа: любой пользователь, не имеющий подписки, имеет доступ к ограниченной базе сайта, обычно это все предметы, цена которых на сайте OPSkinsне превышает двух долларов США. Доступ к полной базе же пользователь может получить, приобретая подписку, которая стоит в среднем $10в месяц. Да, эта сумма незначительная в условиях всего рынка – средняя цена на предметы, например, в игре Counter-Strike:GlobalOffensive составляет порядка 40-60 долларов. Однако не стоит забывать о том факте, что прибыль от трейдинга не имеет конкретного стабильного значения, а выражается в процентах, и чем большим банком обладает пользователь, тем больший объем прибыли он способен выручить. Благодарянесложным математическим расчетам выясняется, что имея начальный банк в 10 долларов, можно иметь 174 доллара через месяц, выручая всего по 10% от текущей суммы в день. С этой точки зрения проект является экономически целесообразным.

С другой стороны, я, как разработчик, могу капитализировать свой проект.Введениеподписки, аналогичной вышеописанным, и реализация в клиентской программе авторизации, а также базы пользователей на сервере позволят стать этому проекту коммерческим. Расширение функционала, внедрение решений, которых нет на ресурсах-конкурентах, либо которые реализованы на них некачественно, введение реферальной программы и программы лояльности, подразумевающих наличие различного рода бонусов за приглашение новых пользователей и пользование приложением в течение долгого промежутка времени, способны привлекать все большую и большую аудиторию, увеличивая прибыль.

 

Заключение

 

Данная работа посвящена разработке инструмента для трейдинга на базе сервиса цифровой дистрибуции Steam, а именно: таблицы сравнения цен на предметы на различных площадках.

В ходе выполнения работы были поставлены следующие цели:

· Анализ рынка существующих инструментов для трейдинга;

· Написание логики парсинга выбранных сайтов;

· Создание базы данных на основе полученных данных;

· Написание логики работы клиентского приложения;

· Разработка дизайна клиентского приложения;

· Тестирование.

По результатам выполнения работы каждая из поставленных целей была достигнута. Реализованный программный продукт удовлетворяет заявленным требованиям.

В процессе разработки был получен опыт работы с СУБД MySQL, подключенной к среде разработки VisualStudio, работы с трафиком сайта, с API, а также с программой BalsamiqMochups, позволившей построить макет будущего приложения.

Разработанный инструмент позволяет пользователям увеличить извлекаемую прибыль при занятии трейдингом, а при дополнительной доработке – введение авторизации, базы пользователей, платной подписки – данный продукт способен стать коммерческим.

В качестве дальнейшей разработки программы планируется добавление площадок в базу, добавление такого фильтра, как количество вещей на сайте, не исключена коммерциализация.

В связи с тем, что все поставленные задачи были выполнены, а заявленные требования удовлетворены, считаю, что цель работы достигнута.


СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ

1. Пан Е.А., Мартышенко С.Н. Социальная роль компьютерных игр в организации досуга студенческой молодежи [Электронный ресурс] // Молодежный научный форум: Общественные и экономические науки: электр. сб. ст. по мат. XXXVI междунар. студ. науч.-практ. конф. № 7(36). URL: https://nauchforum.ru/archive/MNF_social/7(36).pdf (дата обращения: 08.05.2018).

2. Приказ Минобразования РФ от 22 сентября 1998 г. N 2409 "О сертификации информационно-программных средств учебного назначения «Приложение 1. “Проект «Создание отраслевой системы сертификации средств информационных технологий в сфере образования”».

3. Макаров В. Парсинг: Что? Зачем? Как? [Электронный ресурс]: URL: http://parsing.valemak.com (дата обращения: 12.05.2018).

4. Свободная энциклопедия Википедия, статья «API» [Электронный ресурс]: URL: https://ru.wikipedia.org/wiki/API (дата обращения: 12.05.2018).

5. Русский Викисловарь, статья «Интерфейс» [Электронный ресурс]: URL: https://ru.wiktionary.org/wiki/интерфейс (дата обращения: 12.05.2018).

6. Руководство по языку C# [Электронный ресурс]: URL: https://docs.microsoft.com/ru-ru/dotnet/csharp/ (дата обращения: 02.05.2018).

7. ФедоровА. Microsoft Visual Studio. NET // КомпьютерПресс. 2001. №9. C.158-161.

8. Свободная энциклопедия Википедия, статья «MySQL» [Электронный ресурс]: URL : https://ru.wikipedia.org/wiki/MySQL (дата обращения 11.06.2018).

9. Denwer [Электронный ресурс]: URL: http://www.denwer.ru/about.html (дата обращения 10.06.2018).

10. Json.NETDocumentation [Электронный ресурс]: URL: http://www.denwer.ru/about.html (дата обращения 05.06.2018) – яз. англ.

11. MySQLConnectors [Электронный ресурс]: URL: https://dev.mysql.com/downloads/connector/ (дата обращения 10.06.2018).

12. Обзор BalsamiqMockups [Электронный ресурс]: URL: http://analyst.by/articles/balsamiq-mockups (дата обращения 13.06.2018).

 

Приложение А

Листинг основного класса серверного приложения

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Net;

using System.IO;

using System.Text.RegularExpressions;

using OtpSharp;

using Albireo.Base32;

using Newtonsoft.Json;

using Newtonsoft.Json.Linq;

using SqlConn;

using MySql.Data.MySqlClient;

using System.Data.Common;

 

namespace Diplom

{

public class Data

{

   public Item[] Prices;

}

 

public class Item

{

   public int app_id;

   public int context_id;

   public string market_hash_name;

   public string price;

   public string pricing_mode;

   public double skewness;

   public int created_at;

   public string icon_url;

   public string name_color;

   public string quality_color;

   public string rarity_color;

   public string instant_sale_price;

 

   public override string ToString()

   {

       return string.Format("{0} price: {1} instant: {2}", market_hash_name, price, instant_sale_price);

   }

}

 

public class Loot

{

   public Thing[] stuff;

}

 

public class Thing

{

   public string name;

   public string price;

   public string have;

   public string max;

 

   public override string ToString()

   {

       return string.Format("{0} price: {1} have: {2} max: {3}", name, price, have, max);

   }

}

 

class Secret_Code_Generator

{

   public static string Code()

   {

       var secret = "WUEPKKSLC4TTUGX4";

       // create the ToTP object with the Secret

       var totpgen = new Totp(Base32.Base32Encoder.Decode(secret));

 

       // generate current ToTP code

       return totpgen.ComputeTotp();

   }

}

class Parser

{

   public static string[,] AllTable_CS = new string[15000, 14]; // name, ops, opstime, bits, bitstime, bitsa, bitsatime, loot, loottime, money, moneytime, opslink, bitslink

   public static string[,] AllTable_DOTA = new string[35000, 10];

   public static void Fill()

   {

       for (int i = 0; i < 15000; i++)

       {

           for (int j = 0; j < 14; j++)

           {

               AllTable_CS[i, j] = "-";

           }

       }

       for (int i = 0; i < 35000; i++)

       {

           for (int j = 0; j < 10; j++)

           {

               AllTable_DOTA[i, j] = "-";

           }

       }

   }

 

   public static void GetAllLowestListPrices_OPskins (string url, string filename)

   {

       WebRequest req = WebRequest.Create(url);

       WebResponse resp = req.GetResponse();

       Stream stream = resp.GetResponseStream();

       StreamReader sr = new StreamReader(stream);

       string Out = sr.ReadToEnd();

 

       Out = Out.Replace(@"{""status"":1,""response"":{", "");

       sr.Close();

       StreamWriter sw = new StreamWriter(filename + ".txt");

 

       string splitstring = "},";

       string[] OutStr = Regex.Split(Out, splitstring);

 

       for (long i = 0; i < OutStr.Length; i++)

       {

 

           int index = OutStr[i].IndexOf(@",""quantity""");

           if (index > 0)

               OutStr[i] = OutStr[i].Substring(1, index - 1);

           string pattern = @""":{""price"":";

           Regex rgx = new Regex(pattern);

           OutStr[i] = rgx.Replace(OutStr[i], " price: ");

           int indStar = OutStr[i].IndexOf("u2605");

           int indTM = OutStr[i].IndexOf("u2122");

           if (indStar > 0)

           {

               Regex rgx1 = new Regex(@"\\u2605");

               OutStr[i] = rgx1.Replace(OutStr[i], "★");

           }

           if (indTM > 0)

           {

               Regex rgx2 = new Regex(@"\\u2122");

               OutStr[i] = rgx2.Replace(OutStr[i], "™");

           }

 

           int indSun1 = OutStr[i].IndexOf("u58f1");

           int indSun2 = OutStr[i].IndexOf("u5f10");

           if (indSun1 > 0)

           {

               Regex rgx3 = new Regex(@"\\u58f1");

               OutStr[i] = rgx3.Replace(OutStr[i], "壱");

           }

           if (indSun2 > 0)

           {

               Regex rgx4 = new Regex(@"\\u5f10");

               OutStr[i] = rgx4.Replace(OutStr[i], "弐");

           }

           int indDragon = OutStr[i].IndexOf("u9f8d");

           if (indDragon > 0)

           {

               Regex rgx5 = new Regex(@"\\u9f8d\\u738b");

               OutStr[i] = rgx5.Replace(OutStr[i], "龍王");

           }

           int indSeek = OutStr[i].IndexOf("u0026");

           if (indSeek > 0)

           {

               Regex rgx5 = new Regex(@"\\u0026");

               OutStr[i] = rgx5.Replace(OutStr[i], "&");

           }

           sw.WriteLine(OutStr[i]);

           if (OutStr[i].Contains("price:"))

           {

               string name = OutStr[i].Substring(0, OutStr[i].IndexOf(" price:"));

               string price = OutStr[i].Substring(OutStr[i].IndexOf(" price:") + 8);

               double conv = Convert.ToDouble(price);

               conv /= 100;

               price = Convert.ToString(conv);

               price = price.Replace(',', '.');

               if (filename.Contains("CS"))

               {

                   AllTable_CS[i, 0] = name;

                   AllTable_CS[i, 1] = price;

                   AllTable_CS[i, 2] = Convert.ToString(DateTime.Now);

                   name = name.Replace(' ', '+');

                   AllTable_CS[i, 12] = "https://opskins.com/?loc=shop_search&app=730_2&search_item=" + name + "&sort=lh";

               }

               else if (filename.Contains("DOTA"))

               {

                   AllTable_DOTA[i, 0] = name;

                   AllTable_DOTA[i, 1] = price;

                  AllTable_DOTA[i, 2] = Convert.ToString(DateTime.Now);

                   AllTable_DOTA[i, 8] = "https://opskins.com/?loc=shop_search&app=570_2&search_item=" + name + "&sort=lh";

               }

           }

       }

       sw.Close();

   }

 

   public static void GetAllLowestListPrices_Bitskins (string url, string filename) {

       WebRequest req = WebRequest.Create(url);

       WebResponse resp = req.GetResponse();

       Stream stream = resp.GetResponseStream();

       StreamReader sr = new StreamReader(stream);

       string Out = sr.ReadToEnd();

       Out = Out.Replace(@"{

""status"": ""success"",

", "");

       sr.Close();

       StreamWriter sw = new StreamWriter(filename + ".txt");

       Data data = JsonConvert.DeserializeObject<Data>(Out);

       foreach (Item item in data.Prices)

       {

           sw.WriteLine(item);

           if (filename.Contains("CS"))

           {

               for (int i = 0; i < AllTable_CS.GetLength(0); i++)

               {

                   if (item.market_hash_name == AllTable_CS[i,0])

                   {

                       AllTable_CS[i, 3] = item.price;

                      AllTable_CS[i, 4] = Convert.ToString(DateTime.Now);

                       if (item.instant_sale_price != " ")

                       {

                           AllTable_CS[i, 5] = item.instant_sale_price;

                           AllTable_CS[i, 6] = Convert.ToString(DateTime.Now);

                       }

                       string name = item.market_hash_name.Replace(' ', '+');

                       AllTable_CS[i, 13] = "https://bitskins.com/?market_hash_name="+ name + "&appid=730&is_stattrak=0&has_stickers=0&is_souvenir=0&show_trade_delayed_items=0&sort_by=price&order=asc";

                   }

                   else if (AllTable_CS[i, 0] == "-")

                   {

                       AllTable_CS[i, 0] = item.market_hash_name;

                       AllTable_CS[i, 3] = item.price;

                       AllTable_CS[i, 4] = Convert.ToString(DateTime.Now);

                       if (item.instant_sale_price != " ")

                       {

                           AllTable_CS[i, 5] = item.instant_sale_price;

                           AllTable_CS[i, 6] = Convert.ToString(DateTime.Now);

                       }

                       string name = item.market_hash_name.Replace(' ', '+');

                       AllTable_CS[i, 13] = "https://bitskins.com/?market_hash_name=" + name + "&appid=730&is_stattrak=0&has_stickers=0&is_souvenir=0&show_trade_delayed_items=0&sort_by=price&order=asc";

                   }

               }

           }

           else if (filename.Contains("DOTA"))

           {

               for (int i = 0; i < AllTable_DOTA.GetLength(0); i++)

               {

                   if (item.market_hash_name == AllTable_DOTA[i, 0])

                   {

                       AllTable_DOTA[i, 3] = item.price;

                       AllTable_DOTA[i, 4] = Convert.ToString(DateTime.Now);

                       string name = item.market_hash_name.Replace(' ', '+');

                       AllTable_DOTA[i, 9] = "https://bitskins.com/?market_hash_name=" + name + "&appid=570&sort_by=price&order=asc";

                   }

                   else if (AllTable_DOTA[i, 0] == "-")

                   {

                       AllTable_DOTA[i, 0] = item.market_hash_name;

                       AllTable_DOTA[i, 3] = item.price;

                       AllTable_DOTA[i, 4] = Convert.ToString(DateTime.Now);

                       string name = item.market_hash_name.Replace(' ', '+');

                       AllTable_DOTA[i, 9] = "https://bitskins.com/?market_hash_name=" + name + "&appid=570&sort_by=price&order=asc";

                   }

               }

           }

       }

       sw.Close();

   }

 

   public static void GetAllLowestPrices_LootFarm (string url, string filename)

   {

       WebRequest req = WebRequest.Create(url);

       WebResponse resp = req.GetResponse();

       Stream stream = resp.GetResponseStream();

       StreamReader sr = new StreamReader(stream);

       string Out = @"{ ""stuff"" :" + sr.ReadToEnd() + "}";

       sr.Close();

       StreamWriter sw = new StreamWriter(filename + ".txt");

       Loot loot = JsonConvert.DeserializeObject<Loot>(Out);

       foreach (Thing thing in loot.stuff)

       {

            sw.WriteLine(thing);

           if (filename.Contains("CS"))

           {

               for (int i = 0; i < AllTable_CS.GetLength(0); i++)

               {

                   if (thing.name == AllTable_CS[i, 0])

                  {

                       AllTable_CS[i, 7] = Convert.ToString(Convert.ToDouble(thing.price) / 100);

                       AllTable_CS[i, 8] = Convert.ToString(DateTime.Now);

                       AllTable_CS[i, 9] = thing.have + "/" + thing.max;

                   }

                   else if (AllTable_CS[i, 0] == "-")

                   {

                       AllTable_CS[i, 0] = thing.name;

                       AllTable_CS[i, 7] = Convert.ToString(Convert.ToDouble(thing.price) / 100);

                       AllTable_CS[i, 8] = Convert.ToString(DateTime.Now);

                       AllTable_CS[i, 9] = thing.have + "/" + thing.max;

                   }

               }

           }

           else if (filename.Contains("DOTA"))

           {

               for (int i = 0; i < AllTable_DOTA.GetLength(0); i++)

               {

                   if (thing.name == AllTable_DOTA[i, 0])

                   {

                       AllTable_DOTA[i, 5] = Convert.ToString(Convert.ToDouble(thing.price) / 100);

                       AllTable_DOTA[i, 6] = Convert.ToString(DateTime.Now);

                       AllTable_DOTA[i, 7] = thing.have + "/" + thing.max;

                   }

                   else if (AllTable_DOTA[i, 0] == "-")

                   {

                       AllTable_DOTA[i, 0] = thing.name;

                       AllTable_DOTA[i, 5] = Convert.ToString(Convert.ToDouble(thing.price) / 100);

                       AllTable_DOTA[i, 6] = Convert.ToString(DateTime.Now);

                       AllTable_DOTA[i, 7] = thing.have + "/" + thing.max;

                   }

               }

           }

       }

       sw.Close();

   }

 

   public static void GetAllLowestPrices_CSmoney()

   {

       string CSmoneyInventory = "https://cs.money/load_bots_inventory";

       string CSmoneyData = "https://cs.money/babeljs/database_skins/library_ru.js?v=194";

       WebRequest req = WebRequest.Create(CSmoneyData);

       req.Timeout = 100000;

       WebResponse resp = req.GetResponse();

       Stream stream = resp.GetResponseStream();

       StreamReader sr = new StreamReader(stream);

       string Out = sr.ReadToEnd();

       sr.Close();

       Out = Out.Replace("let skins_base = {", "");

 

       StreamWriter sw = new StreamWriter("csm_data.txt");

       string splitstring = "},";

       string[] OutStr = Regex.Split(Out, splitstring);

       StreamWriter test = new StreamWriter("test.txt");

       int nom = 1;

       for (int i = 0; i < OutStr.Length; i++)

       {

           string pat = @"{""m"":";

           Regex rg = new Regex(pat);

           OutStr[i] = rg.Replace(OutStr[i], "");

           OutStr[i] = OutStr[i] + " EnD";

           string pat1 = @""","".* EnD";

           Regex rg1 = new Regex(pat1);

           OutStr[i] = rg1.Replace(OutStr[i], " EnD");

           string ch = @" EnD";

           Regex rg2 = new Regex(ch);

           OutStr[i] = rg2.Replace(OutStr[i], "");

           string da = @"""";

           Regex rg3 = new Regex(da);

           OutStr[i] = rg3.Replace(OutStr[i], "");

           sw.WriteLine(OutStr[i]);

           if (i == OutStr.Length - 1)

               nom = Convert.ToInt32(OutStr[i].Substring(0, OutStr[i].IndexOf(':')));  

       }

       sw.Close();

 

       string[] Prices = new string [nom + 1];

 

       for (int i = 0; i < Prices.Length; i++)

           Prices[i] = "";

       for (int i = 0; i < OutStr.Length; i++)

       {

           if (OutStr[i].Contains(':')) {

               int n = Convert.ToInt32(OutStr[i].Substring(0, OutStr[i].IndexOf(':')));

               Prices[n] = OutStr[i].Substring(OutStr[i].IndexOf(':') + 1);

 

           }

       }

 

       WebRequest req1 = WebRequest.Create(CSmoneyInventory);

       req1.Timeout = 100000;

       WebResponse resp1 = req1.GetResponse();

       Stream stream1 = resp1.GetResponseStream();

       StreamReader sr1 = new StreamReader(stream1);

       string Out1 = sr1.ReadToEnd();

       Out1 = Out1.Remove(0, 2);

       sr1.Close();

       StreamWriter sw1 = new StreamWriter("csm_inv.txt");

       string split = "]},{";

       string[] OutStr1 = Regex.Split(Out1, split);

 

 

       for (int i = 0; i < OutStr1.Length; i++)

       {

           if (OutStr1[i].Contains(@"""o"":") && OutStr1[i].Contains(@"""p"":") && !OutStr1[i].Contains("add_price"))

           {

               string str = @"""id"":\[.*],""o"":";

               Regex rg = new Regex(str);

               OutStr1[i] = rg.Replace(OutStr1[i], "");

               OutStr1[i] += "\n";

               Regex rg1 = new Regex(@",""l"":.*,""p""");

               OutStr1[i] = rg1.Replace(OutStr1[i], " price");

               OutStr1[i] = OutStr1[i].Remove(OutStr1[i].IndexOf(','));

               if (OutStr1[i].Contains('.'))

               {

                   sw1.WriteLine(OutStr1[i]);

                   int num = Convert.ToInt32(OutStr1[i].Substring(0, OutStr1[i].IndexOf('p') - 1));

                   string p = OutStr1[i].Substring(OutStr1[i].IndexOf(':') + 1);

                   if (!Prices[num].Contains("price"))

                       Prices[num] = Prices[num] + " price: " + p;

               }

           }

       }

       sw1.Close();

 

       StreamWriter sw2 = new StreamWriter("CSmoneyAllPrices.txt");

       for (int i = 0; i < Prices.Length; i++)

       {

           if (Prices[i].Length > 0)

           {

               sw2.WriteLine(Prices[i]);

               if (Prices[i].Contains("price:"))

               {

                   string name = "";

                   string price = "";

                   if (Prices[i].Contains("Phase"))

                   {

                       name = Prices[i].Substring(0, Prices[i].IndexOf(" Phase"));

                       price = Prices[i].Substring(Prices[i].IndexOf(" price:") + 8);

                   }

                   else

                   {

                       name = Prices[i].Substring(0, Prices[i].IndexOf(" price:"));

                       price = Prices[i].Substring(Prices[i].IndexOf(" price:") + 8);

                   }

                   for (int j = 0; j < AllTable_CS.GetLength(0); j++)

                   {

                       if (name == AllTable_CS[j, 0])

                       {

                           AllTable_CS[j, 10] = price;

                           AllTable_CS[j, 11] = Convert.ToString(DateTime.Now);

 

                       }

                       else if (AllTable_CS[j, 0] == "-")

                       {

                           AllTable_CS[j, 0] = name;

                           AllTable_CS[j, 10] = price;

                           AllTable_CS[j, 11] = Convert.ToString(DateTime.Now);

                       }

                   }

               }

           }

       }

       sw2.Close();

   }

 

   static void Main(string[] args)

   {

       Fill();

 

       string OPskinsAllPrices_CS = "https://api.opskins.com/IPricing/GetAllLowestListPrices/v1/?appid=730";

       string File_OPskinsAllPrices_CS = "OPskinsAllPrices_CS";

       string OPskinsAllPrices_DOTA = "https://api.opskins.com/IPricing/GetAllLowestListPrices/v1/?appid=570";

       string File_OPskinsAllPrices_DOTA = "OPskinsAllPrices_DOTA";

 

       string API_code = "b6cbfc99-e65f-47a5-9af5-28b23790305c";

       string Security_code = Secret_Code_Generator.Code();

       string BitskinsAllPrices_CS = "https://bitskins.com/api/v1/get_all_item_prices/?api_key=" + API_code + "&code=" + Security_code + "&app_id=730";

       string File_BitskinsAllPrices_CS = "BitskinsAllPrices_CS";

       string BitskinsAllPrices_DOTA = "https://bitskins.com/api/v1/get_all_item_prices/?api_key=" + API_code + "&code=" + Security_code + "&app_id=570";

       string File_BitskinsAllPrices_DOTA = "BitskinsAllPrices_DOTA";

 

       string LootFarmAllPrices_CS = "https://loot.farm/fullprice.json";

       string LootFarmAllPrices_DOTA = "https://loot.farm/fullpriceDOTA.json";

       string File_LootFarmAllPrices_CS = "LootFarmAllPrices_CS";

       string File_LootFarmAllPrices_DOTA = "LootFarmAllPrices_DOTA";

 

       MySqlConnection conn = DBUtils.GetDBConnection();

       try

       {

           Console.WriteLine("Openning Connection ...");

 

           conn.Open();

 

           Console.WriteLine("Connection successful!");

       }

       catch (Exception e)

       {

           Console.WriteLine("Error: " + e.Message);

       }

 

       int cnt = 0;

 

       while (true) {

 

           GetAllLowestListPrices_OPskins(OPskinsAllPrices_CS, File_OPskinsAllPrices_CS);

           GetAllLowestListPrices_OPskins(OPskinsAllPrices_DOTA, File_OPskinsAllPrices_DOTA);

 

           Security_code = Secret_Code_Generator.Code();

           BitskinsAllPrices_CS = "https://bitskins.com/api/v1/get_all_item_prices/?api_key=" + API_code + "&code=" + Security_code + "&app_id=730";

           GetAllLowestListPrices_Bitskins(BitskinsAllPrices_CS, File_BitskinsAllPrices_CS);

           BitskinsAllPrices_DOTA = "https://bitskins.com/api/v1/get_all_item_prices/?api_key=" + API_code + "&code=" + Security_code + "&app_id=570";

           GetAllLowestListPrices_Bitskins(BitskinsAllPrices_DOTA, File_BitskinsAllPrices_DOTA);

 

           GetAllLowestPrices_LootFarm(LootFarmAllPrices_CS, File_LootFarmAllPrices_CS);

 

           GetAllLowestPrices_LootFarm(LootFarmAllPrices_DOTA, File_LootFarmAllPrices_DOTA);

 

           GetAllLowestPrices_CSmoney();

 

           if (cnt == 0)

           {

               string sql_dota = "insert into prices_dota (Name, OPSkins, OP_Date, BitSkins, Bit_Date, LootFarm, Loot_Date, Loot_Have, OP_Link, Bit_Link)" +

                   " values (@dname, @dOP, @dOPD, @dBit, @dBitD, @dLoot, @dLootD, @dLootH, @dOPL, @dBitL);";

               string sql_cs = "insert into prices_cs (Name, OPSkins, OP_Date, BitSkins, Bit_Date, Bit_Auto, Bit_Auto_Date, LootFarm, Loot_Date, Loot_Have, CSMoney, CSMoney_Date, OP_Link, Bit_Link)" +

                   " values (@cname, @cOP, @cOPD, @cBit, @cBitD, @cBitA, @cBitAD, @cLoot, @cLootD, @cLootH, @cCSM, @cCSMD, @cOPL, @cBitL);";

               for (int k = 0; k < 10; k++)

               {

                   MySqlCommand cmd_dota = conn.CreateCommand();

                   cmd_dota.CommandText = sql_dota;

                      cmd_dota.Parameters.Add("@dName", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 0];

                   cmd_dota.Parameters.Add("@dOP", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 1];

                   cmd_dota.Parameters.Add("@dOPD", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 2];

                   cmd_dota.Parameters.Add("@dBit", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 3];

                   cmd_dota.Parameters.Add("@dBitD", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 4];

                   cmd_dota.Parameters.Add("@dLoot", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 5];

                   cmd_dota.Parameters.Add("@dLootD", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 6];

                   cmd_dota.Parameters.Add("@dLootH", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 7];

                   cmd_dota.Parameters.Add("@dOPL", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 8];

                   cmd_dota.Parameters.Add("@dBitL", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 9];

                   int buf = cmd_dota.ExecuteNonQuery();

                   Console.WriteLine("Dota" + buf);

               }

               for (int k = 0; k < 10; k++)

               {

                   MySqlCommand cmd_csgo = conn.CreateCommand();

                   cmd_csgo.CommandText = sql_cs;

                   cmd_csgo.Parameters.Add("@cName", MySqlDbType.VarChar).Value = AllTable_CS[k, 0];

                     cmd_csgo.Parameters.Add("@cOP", MySqlDbType.VarChar).Value = AllTable_CS[k, 1];

                   cmd_csgo.Parameters.Add("@cOPD", MySqlDbType.VarChar).Value = AllTable_CS[k, 2];

                   cmd_csgo.Parameters.Add("@cBit", MySqlDbType.VarChar).Value = AllTable_CS[k, 3];

                   cmd_csgo.Parameters.Add("@cBitD", MySqlDbType.VarChar).Value = AllTable_CS[k, 4];

                   cmd_csgo.Parameters.Add("@cBitA", MySqlDbType.VarChar).Value = AllTable_CS[k, 5];

                   cmd_csgo.Parameters.Add("@cBitAD", MySqlDbType.VarChar).Value = AllTable_CS[k, 6];

                   cmd_csgo.Parameters.Add("@cLoot", MySqlDbType.VarChar).Value = AllTable_CS[k, 7];

                   cmd_csgo.Parameters.Add("@cLootD", MySqlDbType.VarChar).Value = AllTable_CS[k, 8];

                   cmd_csgo.Parameters.Add("@cLootH", MySqlDbType.VarChar).Value = AllTable_CS[k, 9];

                   cmd_csgo.Parameters.Add("@cCSM", MySqlDbType.VarChar).Value = AllTable_CS[k, 10];

                   cmd_csgo.Parameters.Add("@cCSMD", MySqlDbType.VarChar).Value = AllTable_CS[k, 11];

                   cmd_csgo.Parameters.Add("@cOPL", MySqlDbType.VarChar).Value = AllTable_CS[k, 12];

                   cmd_csgo.Parameters.Add("@cBitL", MySqlDbType.VarChar).Value = AllTable_CS[k, 13];

                   int buf = cmd_csgo.ExecuteNonQuery();

                   Console.WriteLine("CS" + buf);

               }

               cnt = 1;

           }

           else

           {

               string sql_dota = "update prices_dota set OPSkins = @dOP, OP_Date = @dOPD, BitSkins = @dBit, Bit_Date = @dBitD, LootFarm = @dLoot, Loot_Date = @dLootD, Loot_Have = @dLootH, OP_Link = @dOPL, Bit_Link = @dBitL where Name = @dName";

               string sql_cs = "update prices_cs set OPSkins = @cOP, OP_Date = @cOPD, BitSkins = @cBit, Bit_Date = @cBitD, Bit_Auto = @cBitA, Bit_Auto_Date = @cBitAD, LootFarm = @cLoot, Loot_Date = @cLootD, Loot_Have = @cLootH, CSMoney = @cCSM, CSMoney_Date = @cCSMD, OP_Link = @cOPL, Bit_Link = @cBitL where Name = @cName";

               for (int k = 0; k < 10; k++)

               {

                   MySqlCommand cmd_dota = conn.CreateCommand();

                   cmd_dota.CommandText = sql_dota;

                   cmd_dota.Parameters.Add("@dOP", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 1];

                   cmd_dota.Parameters.Add("@dOPD", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 2];

                   cmd_dota.Parameters.Add("@dBit", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 3];

                   cmd_dota.Parameters.Add("@dBitD", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 4];

                   cmd_dota.Parameters.Add("@dLoot", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 5];

                   cmd_dota.Parameters.Add("@dLootD", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 6];

                   cmd_dota.Parameters.Add("@dLootH", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 7];

                   cmd_dota.Parameters.Add("@dOPL", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 8];

                   cmd_dota.Parameters.Add("@dBitL", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 9];

                   cmd_dota.Parameters.Add("@dName", MySqlDbType.VarChar).Value = AllTable_DOTA[k, 0];

                   int buf = cmd_dota.ExecuteNonQuery();

               }

               for (int k = 0; k < 10; k++)

               {

                   MySqlCommand cmd_csgo = conn.CreateCommand();

                   cmd_csgo.CommandText = sql_cs;

                   cmd_csgo.Parameters.Add("@cOP", MySqlDbType.VarChar).Value = AllTable_CS[k, 1];

                   cmd_csgo.Parameters.Add("@cOPD", MySqlDbType.VarChar).Value = AllTable_CS[k, 2];

                   cmd_csgo.Parameters.Add("@cBit", MySqlDbType.VarChar).Value = AllTable_CS[k, 3];

                   cmd_csgo.Parameters.Add("@cBitD", MySqlDbType.VarChar).Value = AllTable_CS[k, 4];

                   cmd_csgo.Parameters.Add("@cBitA", MySqlDbType.VarChar).Value = AllTable_CS[k, 5];

                   cmd_csgo.Parameters.Add("@cBitAD", MySqlDbType.VarChar).Value = AllTable_CS[k, 6];

                   cmd_csgo.Parameters.Add("@cLoot", MySqlDbType.VarChar).Value = AllTable_CS[k, 7];

                   cmd_csgo.Parameters.Add("@cLootD", MySqlDbType.VarChar).Value = AllTable_CS[k, 8];

                   cmd_csgo.Parameters.Add("@cLootH", MySqlDbType.VarChar).Value = AllTable_CS[k, 9];

                   cmd_csgo.Parameters.Add("@cCSM", MySqlDbType.VarChar).Value = AllTable_CS[k, 10];

                   cmd_csgo.Parameters.Add("@cCSMD", MySqlDbType.VarChar).Value = AllTable_CS[k, 11];

                   cmd_csgo.Parameters.Add("@cOPL", MySqlDbType.VarChar).Value = AllTable_CS[k, 12];

                   cmd_csgo.Parameters.Add("@cBitL", MySqlDbType.VarChar).Value = AllTable_CS[k, 13];

                   cmd_csgo.Parameters.Add("@cName", MySqlDbType.VarChar).Value = AllTable_CS[k, 0];

                   int buf = cmd_csgo.ExecuteNonQuery();

}

           }

       }

   }

}

}

 

Листинг основного класса клиентского приложения

 

usingMySql.Data.MySqlClient;

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using SqlConn;

using System.Data.Common;

using Newtonsoft.Json;

using Newtonsoft.Json.Linq;

using System.IO;

using System.Diagnostics;

 

namespace Client_Parser

{

public partial class Form1 : Form

{

   MySqlConnection conn = DBUtils.GetDBConnection();

   List<string[]> data = new List<string[]>();

   List<double[]> diffs = new List<double[]>();

   List<string[]> basa = new List<string[]>();

 

   public class Commission

   {

       public string OPS_CS;

       public string OPS_Dota;

       public string Bit;

       public string Loot;

       public string CSM;

   }

 

   static StreamReader sr = new StreamReader("settings.ini");

   static string Out = sr.ReadToEnd();

   Commission cms = JsonConvert.DeserializeObject<Commission>(Out);

 

   public int Rules(int i)

   {

       int r = 1;

       if (textBox1.Text.Length > 0)

           if (dataGridView1.Rows[i].Cells[0].Value.ToString().IndexOf(textBox1.Text, StringComparison.OrdinalIgnoreCase) < 0)

               r *= 0;

       if (textBox2.Text.Length > 0)

       {

           if (textBox2.Text != "-")

           {

               if (Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value.ToString()) > Convert.ToDouble(textBox2.Text))

                   r *= 0;

           }

       }

       if (textBox3.Text.Length > 0)

       {

           if (textBox3.Text != "-")

           {

               if (Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value.ToString()) < Convert.ToDouble(textBox3.Text))

                   r *= 0;

           }

       }

       if (textBox4.Text.Length > 0)

       {

           if (textBox4.Text != "-")

           {

               if (Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value.ToString()) > Convert.ToDouble(textBox4.Text))

                   r *= 0;

           }

       }

       if (textBox5.Text.Length > 0)

       {

           if (textBox5.Text != "-")

           {

               if (Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value.ToString()) < Convert.ToDouble(textBox5.Text))

                   r *= 0;

           }

       }

       if (textBox6.Text.Length > 0)

       {

           if (textBox6.Text != "-")

           {

               if (Convert.ToDouble(dataGridView1.Rows[i].Cells[3].Value.ToString()) > Convert.ToDouble(textBox6.Text))

                   r *= 0;

           }

       }

       if (textBox7.Text.Length > 0)

       {

           if (textBox7.Text != "-")

           {

               if (Convert.ToDouble(dataGridView1.Rows[i].Cells[3].Value.ToString()) < Convert.ToDouble(textBox7.Text))

                   r *= 0;

           }

       }

       if (textBox8.Text.Length > 0)

       {

           if (textBox8.Text != "-")

           {

               if (Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value.ToString()) > Convert.ToDouble(textBox8.Text))

                   r *= 0;

           }

       }

       if (textBox9.Text.Length > 0)

       {

           if (textBox9.Text != "-")

           {

               if (Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value.ToString()) < Convert.ToDouble(textBox9.Text))

                   r *= 0;

           }

       }

       return r;

   }

 

   public void FillOnRules()

   {

       for (int i = 0; i < dataGridView1.Rows.Count; i++)

       {

           int ch = Rules(i);

           if (ch == 0)

               dataGridView1.Rows[i].Visible = false;

           else

               dataGridView1.Rows[i].Visible = true;

       }

   }

 

   public void FillWithCS ()

   {

       comboBox1.Items.Clear();

       comboBox1.Items.Add("OPSkins.com");

       comboBox1.Items.Add("BitSkins.com");

       comboBox1.Items.Add("BitSkins.com Auto");

       comboBox1.Items.Add("Loot.Farm");

       comboBox1.Items.Add("CS.Money");

       comboBox2.Items.Clear();

       comboBox2.Items.Add("OPSkins.com");

       comboBox2.Items.Add("BitSkins.com");

       comboBox2.Items.Add("BitSkins.com Auto");

       comboBox2.Items.Add("Loot.Farm");

       comboBox2.Items.Add("CS.Money");

   }

 

   public void FillWithDOTA()

   {

       comboBox1.Items.Clear();

       comboBox1.Items.Add("OPSkins.com");

       comboBox1.Items.Add("BitSkins.com");

       comboBox1.Items.Add("Loot.Farm");

       comboBox2.Items.Clear();

       comboBox2.Items.Add("OPSkins.com");

       comboBox2.Items.Add("BitSkins.com");

       comboBox2.Items.Add("Loot.Farm");

   }

 

   public void FillWithCS1()

   {

       comboBox3.Items.Clear();

       comboBox3.Items.Add("OPSkins.com");

       comboBox3.Items.Add("BitSkins.com");

       comboBox3.Items.Add("BitSkins.com Auto");

       comboBox3.Items.Add("Loot.Farm");

       comboBox3.Items.Add("CS.Money");

 

   }

 

   public void FillWithDOTA1()

   {

       comboBox3.Items.Clear();

       comboBox3.Items.Add("OPSkins.com");

       comboBox3.Items.Add("BitSkins.com");

       comboBox3.Items.Add("Loot.Farm");

 

   }

 

   public Form1()

   {

 

       InitializeComponent();

       sr.Close();

       textBox12.Text = cms.OPS_CS;

       textBox13.Text = cms.OPS_Dota;

       textBox14.Text = cms.Bit;

       textBox15.Text = cms.Loot;

       textBox16.Text = cms.CSM;

 

       tabPage1.Text = "Таблица";

       tabPage2.Text = "Настройки";

       tabPage3.Text = "Базацен";

 

       if (radioButton1.Checked)

       {

           FillWithCS();

       }

       else if (radioButton2.Checked)

       {

           FillWithDOTA();

       }

 

       if (radioButton3.Checked)

       {

           FillWithCS1();

       }

 

       else if(radioButton4.Checked)

       {

           FillWithDOTA1();

       }

   }

 

   private void radioButton2_CheckedChanged_1(object sender, EventArgs e)

   {

       if (radioButton2.Checked)

       {

           FillWithDOTA();

           comboBox1.Text = "Выберитеплощадку...";

           comboBox2.Text = "Выберитеплощадку...";

       }

       else

       {

           FillWithCS();

           comboBox1.Text = "Выберитеплощадку...";

           comboBox2.Text = "Выберитеплощадку...";

       }

 

   }

 

   private void radioButton1_CheckedChanged(object sender, EventArgs e)

   {

       if (radioButton1.Checked)

       {

           FillWithCS();

           comboBox1.Text = "Выберитеплощадку...";

           comboBox2.Text = "Выберитеплощадку...";

       }

       else

       {

           FillWithDOTA();

           comboBox1.Text = "Выберитеплощадку...";

           comboBox2.Text = "Выберитеплощадку...";

       }

   }

 

   private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)

   {

       int currC = dataGridView1.CurrentCell.ColumnIndex;

       int currR = dataGridView1.CurrentCell.RowIndex;

       if (currC == 0)

       {

           Clipboard.SetText(dataGridView1.Rows[currR].Cells[currC].Value.ToString());

       }

       if (currC == 5 || currC == 6)

       {

           var url = dataGridView1.Rows[currR].Cells[currC].Value.ToString();

           Process.Start(url);

       }

   }

 

   private void button1_Click(object sender, EventArgs e)

   {

       if (comboBox1.Text == "Выберитеплощадку..." || comboBox2.Text == "Выберитеплощадку...")

MessageBox.Show("Выберите площадку!", "Ошибка");

else if (comboBox1.Text == comboBox2.Text)

MessageBox.Show("Площадки должны быть разными!", "Ошибка");

else

       {

           string game = "";

           string req1 = "";

           string req2 = "";

           double comm1 = 1;

           double comm2 = 1;

           switch (comboBox1.Text)

           {

               case "OPSkins.com":

                   req1 = "OPSkins, OP_Date, ";

                   if (radioButton1.Checked)

                       comm1 = Convert.ToDouble(textBox12.Text);

                   else if (radioButton2.Checked)

                       comm1 = Convert.ToDouble(textBox13.Text);

                   break;

               case "BitSkins.com":

                   req1 = "BitSkins, Bit_Date, ";

                   comm1 = Convert.ToDouble(textBox14.Text);

                   break;

               case "BitSkins.com Auto":

                   req1 = "Bit_Auto, Bit_Auto_Date, ";

                   comm1 = Convert.ToDouble(textBox14.Text);

                   break;

               case "Loot.Farm":

                   req1 = "LootFarm, Loot_Date, ";

                   comm1 = Convert.ToDouble(textBox15.Text);

                   break;

               case "CS.Money":

                   req1 = "CSMoney, CSMoney_Date, ";

                   comm1 = Convert.ToDouble(textBox16.Text);

                   break;

           }

           switch (comboBox2.Text)

           {

               case "OPSkins.com":

                   req2 = "OPSkins, OP_Date, ";

                   if (radioButton1.Checked)

                       comm2 = Convert.ToDouble(textBox12.Text);

                   else if (radioButton2.Checked)

                       comm2 = Convert.ToDouble(textBox13.Text);

                   break;

               case "BitSkins.com":

                   req2 = "BitSkins, Bit_Date, ";

                   comm2 = Convert.ToDouble(textBox14.Text);

                   break;

               case "BitSkins.com Auto":

                   req2 = "Bit_Auto, Bit_Auto_Date, ";

                   comm2 = Convert.ToDouble(textBox14.Text);

                   break;

               case "Loot.Farm":

                   req2 = "LootFarm, Loot_Date, ";

                   comm2 = Convert.ToDouble(textBox15.Text);

                   break;

               case "CS.Money":

                   req2 = "CSMoney, CSMoney_Date, ";

                   comm2 = Convert.ToDouble(textBox16.Text);

                     break;

           }

           comm1 /= -100;

           comm2 /= -100;

           req2 += "OP_Link, Bit_Link ";

           if (radioButton1.Checked)

           {

               game = "prices_cs";

              }

           else if (radioButton2.Checked)

           {

               game = "prices_dota";

           }

           conn.Open();

           string sql = "select Name, " + req1 + req2 + "from " + game + ";";

           MySqlCommand cmd = new MySqlCommand();

           cmd.Connection = conn;

           cmd.CommandText = sql;

           data.Clear();

           diffs.Clear();

           dataGridView1.Rows.Clear();

           dataGridView1.Refresh();

 

           using (DbDataReader reader = cmd.ExecuteReader())

           {

               if (reader.HasRows)

               {

                   while (reader.Read())

                   {

                       data.Add(new string[7]);

                       diffs.Add(new double[2]);

                       data[data.Count - 1][0] = reader[0].ToString();

                       data[data.Count - 1][1] = reader[1].ToString().Replace('.', ',');

                       data[data.Count - 1][2] = reader[2].ToString();

                       data[data.Count - 1][3] = reader[3].ToString().Replace('.', ',');

                       data[data.Count - 1][4] = reader[4].ToString();

                       if (reader[1].ToString() != "-" && reader[3].ToString() != "-")

                       {

                           string p1 = reader[1].ToString();

                           if (p1.Contains('.'))

                                 p1 = p1.Replace('.', ',');

                           double pr1 = Convert.ToDouble(p1);

                           string p2 = reader[3].ToString();

                           if (p2.Contains('.'))

                               p2 = p2.Replace('.', ',');

                           double pr2 = Convert.ToDouble(p2);

                           double res1 = (pr2 * (1 - comm2) - pr1) / pr2 * 100;

                           double res2 = (pr1 * (1 - comm1) - pr2) / pr1 * 100;

                           diffs[diffs.Count - 1][0] = res1;

                           diffs[diffs.Count - 1][1] = res2;

                       }

                       else

                       {

                           diffs[diffs.Count - 1][0] = Convert.ToDouble(null);

                           diffs[diffs.Count - 1][1] = Convert.ToDouble(null);

                       }

                       data[data.Count - 1][5] = reader[5].ToString();

                       data[data.Count - 1][6] = reader[6].ToString();

                   }

               }

           }

           conn.Close();

 

           for (int i = 0; i < data.Count; i++)

           {

               if (diffs[i][0] != 0)

               {

                   TimeSpan rez1 = DateTime.Now - Convert.ToDateTime(data[i][2]);

                   TimeSpan rez2 = DateTime.Now - Convert.ToDateTime(data[i][4]);

                   int d1 = Convert.ToInt32(rez1.TotalSeconds);

                   int d2 = Convert.ToInt32(rez2.TotalSeconds);

                   bool ch = true;

                   if (textBox10.Text.Length > 0)

                   {

                       if (Convert.ToInt32(textBox10.Text) * 60 < d1)

                       {

                           ch = false;

 

                       }

                   }

                   if (textBox11.Text.Length > 0)

                   {

                       if (Convert.ToInt32(textBox11.Text) * 60 < d2)

                           ch = false;

                   }

                   if (ch)

                   {

                       dataGridView1.Rows.Add(data[i][0], data[i][1], data[i][3], diffs[i][0], diffs[i][1], data[i][5], data[i][6]);

                       dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].ToolTipText = data[i][2];

                          dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[2].ToolTipText = data[i][4];

                   }

               }

           }

           dataGridView1.Sort(dataGridView1.Columns[3], ListSortDirection.Descending);

           FillOnRules();

       }

   }

 

   private void button3_Click(object sender, EventArgs e)

   {

       textBox12.Text = "-5";

       textBox13.Text = "-10";

       textBox14.Text = "-5";

       textBox15.Text = "-3";

       textBox16.Text = "-3";

       button2_Click(sender, e);

   }

 

   private void textBox1_TextChanged(object sender, EventArgs e)

   {

 

       FillOnRules();

 

   }

 

   private void textBox3_TextChanged(object sender, EventArgs e)

   {

       if (textBox3.Text.Length > 0)

       {

           string buf = textBox3.Text.Substring(0, textBox3.Text.Length - 1);

           string symb = textBox3.Text.Substring(textBox3.Text.Length - 1);

 

           if (symb == "." || symb == ",")

           {

               if (!textBox3.Text.Contains(",") || !textBox3.Text.Contains("."))

                   textBox3.Text = buf + ",";

               else

                   textBox3.Text = buf;

           }

           else if (symb != "1" && symb != "2" && symb != "3" && symb != "4" && symb != "5" && symb != "6" && symb != "7" && symb != "8" && symb != "9" && symb != "0")

             {

               textBox3.Text = buf;

           }

           textBox3.SelectionStart = textBox3.Text.Length;

       }

       FillOnRules();

   }

 

   private void textBox2_TextChanged(object sender, EventArgs e)

   {

       if (textBox2.Text.Length > 0)

       {

           string buf = textBox2.Text.Substring(0, textBox2.Text.Length - 1);

           string symb = textBox2.Text.Substring(textBox2.Text.Length - 1);

 

           if (symb == "." || symb == ",")

           {

               if (!textBox2.Text.Contains(",") || !textBox2.Text.Contains("."))

                   textBox2.Text = buf + ",";

               else

                   textBox2.Text = buf;

           }

           else if (symb != "1" && symb != "2" && symb != "3" && symb != "4" && symb != "5" && symb != "6" && symb != "7" && symb != "8" && symb != "9" && symb != "0")

             {

               textBox2.Text = buf;

           }

           textBox2.SelectionStart = textBox2.Text.Length;

       }

       FillOnRules();

   }

 

   private void textBox4_TextChanged(object sender, EventArgs e)

   {

       if (textBox4.Text.Length > 0)

       {

           string buf = textBox4.Text.Substring(0, textBox4.Text.Length - 1);

           string symb = textBox4.Text.Substring(textBox4.Text.Length - 1);

 

           if (symb == "." || symb == ",")

           {

               if (!textBox4.Text.Contains(",") || !textBox4.Text.Contains("."))

                   textBox4.Text = buf + ",";

               else

                   textBox4.Text = buf;

           }

           else if (symb != "1" && symb != "2" && symb != "3" && symb != "4" && symb != "5" && symb != "6" && symb != "7" && symb != "8" && symb != "9" && symb != "0")

             {

               textBox4.Text = buf;

           }

           textBox4.SelectionStart = textBox4.Text.Length;

       }

       FillOnRules();

   }

 

   private void textBox5_TextChanged(object sender, EventArgs e)

   {

       if (textBox5.Text.Length > 0)

       {

           string buf = textBox5.Text.Substring(0, textBox5.Text.Length - 1);

           string symb = textBox5.Text.Substring(textBox5.Text.Length - 1);

           if (symb == "." || symb == ",")

           {

               if (!textBox5.Text.Contains(",") || !textBox5.Text.Contains("."))

                   textBox5.Text = buf + ",";

               else

                   textBox5.Text = buf;

           }

           else if (symb != "1" && symb != "2" && symb != "3" && symb != "4" && symb != "5" && symb != "6" && symb != "7" && symb != "8" && symb != "9" && symb != "0")

           {

               textBox5.Text = buf;

           }

           textBox5.SelectionStart = textBox5.Text.Length;

       }

       FillOnRules();

 

   }

 

   private void textBox6_TextChanged(object sender, EventArgs e)

   {

       if (textBox6.Text.Length > 0)

       {

           string buf = textBox6.Text.Substring(0, textBox6.Text.Length - 1);

           string symb = textBox6.Text.Substring(textBox6.Text.Length - 1);

 

           if (symb == "." || symb == ",")

           {

               if (!textBox6.Text.Contains(",") || !textBox6.Text.Contains("."))

                   textBox6.Text = buf + ",";

               else

                   textBox6.Text = buf;

           }

           else if (symb != "1" && symb != "2" && symb != "3" && symb != "4" && symb != "5" && symb != "6" && symb != "7" && symb != "8" && symb != "9" && symb != "0")

           {

               textBox6.Text = buf;

           }

          textBox6.SelectionStart = textBox6.Text.Length;

       }

       FillOnRules();

   }

 

   private void textBox7_TextChanged(object sender, EventArgs e)

   {

       if (textBox7.Text.Length > 0)

       {

           string buf = textBox7.Text.Substring(0, textBox7.Text.Length - 1);

           string symb = textBox7.Text.Substring(textBox7.Text.Length - 1);

 

           if (symb == "." || symb == ",")

           {

               if (!textBox7.Text.Contains(",") || !textBox7.Text.Contains("."))

                   textBox7.Text = buf + ",";

               else

                   textBox7.Text = buf;

           }

           else if (symb != "1" && symb != "2" && symb != "3" && symb != "4" && symb != "5" && symb != "6" && symb != "7" && symb != "8" && symb != "9" && symb != "0")

           {

               textBox7.Text = buf;

           }

           textBox7.SelectionStart = textBox7.Text.Length;

       }

       FillOnRules();

   }

 

   private void textBox8_TextChanged(object sender, EventArgs e)

   {

       if (textBox8.Text.Length > 0)

       {

           string buf = textBox8.Text.Substring(0, textBox8.Text.Length - 1);

           string symb = textBox8.Text.Substring(textBox8.Text.Length - 1);

           if (symb == "." || symb == ",")

           {

               if (!textBox8.Text.Contains(",") || !textBox8.Text.Contains("."))

                   textBox8.Text = buf + ",";

               else

                   textBox8.Text = buf;

           }

           else if (symb != "1" && symb != "2" && symb != "3" && symb != "4" && symb != "5" && symb != "6" && symb != "7" && symb != "8" && symb != "9" && symb != "0")

           {

               textBox8.Text = buf;

           }

           textBox8.SelectionStart = textBox8.Text.Length;

       }

       FillOnRules();

   }

 

   private void textBox9_TextChanged(object sender, EventArgs e)

   {

       if (textBox9.Text.Length > 0)

       {

           string symb = textBox9.Text.Substring(textBox9.Text.Length - 1);

           string buf = textBox9.Text.Substring(0, textBox9.Text.Length - 1);

 

           if (symb == "." || symb == ",")

           {

               if (!textBox9.Text.Contains(",") || !textBox9.Text.Contains("."))

                   textBox9.Text = buf + ",";

               else

                   textBox9.Text = buf;

           }

           else if (symb != "1" && symb != "2" && symb != "3" && symb != "4" && symb != "5" && symb != "6" && symb != "7" && symb != "8" && symb != "9" && symb != "0")

           {

               textBox9.Text = buf;

           }

           textBox9.SelectionStart = textBox9.Text.Length;

       }

       FillOnRules();

   }

 

   private void button2_Click(object sender, EventArgs e)

   {

       Commission cm = new Commission();

       cm.OPS_CS = textBox12.Text.Replace('.','.');

       cm.OPS_Dota = textBox13.Text.Replace('.', '.');

       cm.Bit = textBox14.Text.Replace('.', '.');

       cm.Loot = textBox15.Text.Replace('.', '.');

       cm.CSM = textBox16.Text.Replace('.', '.');

       textBox12.Text = textBox12.Text.Replace('.', '.');

       textBox13.Text = textBox13.Text.Replace('.', '.');

       textBox14.Text = textBox14.Text.Replace('.', '.');

       textBox15.Text = textBox15.Text.Replace('.', '.');

        textBox16.Text = textBox16.Text.Replace('.', '.');

       string New = JsonConvert.SerializeObject(cm);

       StreamWriter sw = new StreamWriter("settings.ini");

       sw.Write(New);

       sw.Close();

   }

 

   private void radioButton3_CheckedChanged(object sender, EventArgs e)

   {

       if (radioButton3.Checked)

       {

           FillWithCS1();

           comboBox3.Text = "Выберитеплощадку...";

       }

       else

       {

           FillWithDOTA1();

           comboBox3.Text = "Выберитеплощадку...";

       }

   }

 

   private void radioButton4_CheckedChanged(object sender, EventArgs e)

   {

       if (radioButton4.Checked)

       {

           FillWithDOTA1();

           comboBox3.Text = "Выберитеплощадку...";

       }

       else

       {

           FillWithCS1();

           comboBox3.Text = "Выберитеплощадку...";

       }

 

   }

 

   private void button4_Click(object sender, EventArgs e)

   {

       if (comboBox3.Text == "Выберитеплощадку...")

           MessageBox.Show("Выберитеплощадку!", "Ошибка");

       else

       {

           string game = "";

           string req1 = "";

           switch (comboBox3.Text)

           {

               case "OPSkins.com":

                   req1 = "OPSkins, OP_Date, ";

                   break;

               case "BitSkins.com":

                   req1 = "BitSkins, Bit_Date, ";

                   break;

               case "BitSkins.com Auto":

                   req1 = "Bit_Auto, Bit_Auto_Date, ";

                   break;

               case "Loot.Farm":

                   req1 = "LootFarm, Loot_Date, ";

                   break;

               case "CS.Money":

                   req1 = "CSMoney, CSMoney_Date, ";

                   break;

           }

           req1 += "OP_Link, Bit_Link ";

           if (radioButton3.Checked)

           {

               game = "prices_cs";

           }

           else if (radioButton4.Checked)

           {

               game = "prices_dota";

           }

           string name = textBox17.Text;

           conn.Open();

           string sql = "select Name, " + req1 + "from " + game + " where Name like '%" + name + "%';";

           MySqlCommand cmd = new MySqlCommand();

           cmd.Connection = conn;

           cmd.CommandText = sql;

           basa.Clear();

           dataGridView2.Rows.Clear();

           dataGridView2.Refresh();

           using (DbDataReader reader = cmd.ExecuteReader())

           {

               if (reader.HasRows)

               {

                   while (reader.Read())

                   {

                       basa.Add(new string[5]);

                       basa[basa.Count - 1][0] = reader[0].ToString();

                       basa[basa.Count - 1][1] = reader[1].ToString();

                       basa[basa.Count - 1][2] = reader[2].ToString();

                       basa[basa.Count - 1][3] = reader[3].ToString();

                       basa[basa.Count - 1][4] = reader[4].ToString();

}

               }

           }

           conn.Close();

 

           for (int i = 0; i < basa.Count; i++)

          {

               dataGridView2.Rows.Add(basa[i][0], basa[i][2], basa[i][3], basa[i][4]);

               dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells[1].ToolTipText = basa[i][1];

}

       }

   }

}

}

 

Листингкласса DBMySQLUtils

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using MySql.Data.MySqlClient;

 

namespace SqlConn

{

class DBMySQLUtils

{

 

   public static MySqlConnection

            GetDBConnection(string host, string database, string username, string password)

   {

       // Connection String.

       String connString = "Server=" + host + ";Database=" + database

           + ";User Id=" + username + ";password=" + password + ";SslMode=none";

 

       MySqlConnection conn = new MySqlConnection(connString);

 

return conn;

   }

 

}

}

 

Листингкласса DBUtils

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using MySql.Data.MySqlClient;

 

namespace SqlConn

{

class DBUtils

{

   public static MySqlConnection GetDBConnection()

   {

       string host = "127.0.0.1";

       string database = "diplom";

       string username = "root";

       string password = "";

 

       return DBMySQLUtils.GetDBConnection(host, database, username, password);

}

 

}

}


Дата добавления: 2018-08-06; просмотров: 190; Мы поможем в написании вашей работы!

Поделиться с друзьями:






Мы поможем в написании ваших работ!