Пример #1
0
        public Service.Product GetProductById(int id)
        {
            connectionName = dbc.ConnectDB(connect);
            Service.Product product = new Service.Product();

            using (SqlConnection conn = new SqlConnection(connectionName))
            {
                SqlCommand cmd = new SqlCommand("GetProductById", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@IdProduct", id);

                try
                {
                    conn.Open();

                    SqlDataReader dr = cmd.ExecuteReader();

                    if (dr.Read())
                    {
                        product.IdProduct = Convert.ToInt32(dr["IdProduct"]);
                        product.Name      = dr["Name"].ToString();
                        product.Price     = Convert.ToDouble(dr["Price"]);
                    }
                }
                catch (Exception)
                {
                }
                finally
                {
                    conn.Close();
                }
            }

            return(product);
        }
Пример #2
0
        public Product(Service.Product tv, Service.Profile profile)
        {
            string data1  = Environment.CurrentDirectory + "\\Content\\maets.cur";
            var    cursor = new Cursor(data1);

            this.Cursor = cursor;
            tv1         = tv;
            InitializeComponent();
            prof = profile;
            Inicialize(tv1);
            int p = 0;

            if (ShopWindows.mainfprofile.Count != 0)
            {
                for (int i = 0; i < ShopWindows.mainfprofile.Count; i++)
                {
                    if (ShopWindows.mainfprofile[i].Id == tv1.Id)
                    {
                        p++;
                    }
                }
                if (p != 0)
                {
                    btnBuy.Visibility     = Visibility.Hidden;
                    btnkorzina.Visibility = Visibility.Visible;
                }
            }
            if (check(tv))
            {
                BuyAlready.Visibility = Visibility.Visible;
                BuyAlready.ToolTip    = "Этот товар уже есть в вашей библиотеке, вы можете купить его только оптом(2+ штук))";
            }
        }
Пример #3
0
 private void BtnAdd_Click(object sender, RoutedEventArgs e)
 {
     if (tbDescription.Text == "" || tbDeveloper.Text == "" || tbPublisher.Text == "" || tbgameName.Text == "" || gamescreen.Count < 6 || price.Text == "")
     {
         System.Windows.MessageBox.Show("Не все поля заполнены!");
     }
     else
     {
         Service.Product yourgame = new Service.Product();
         yourgame.Name           = tbgameName.Text;
         yourgame.Description    = tbDescription.Text;
         yourgame.Developer      = tbDeveloper.Text;
         yourgame.Publisher      = tbPublisher.Text;
         yourgame.MainImage      = gamescreen[0];
         yourgame.RetailPrice    = Convert.ToDouble(price.Text);
         yourgame.WholesalePrice = Convert.ToDouble(price.Text);
         List <byte[]> scrs = new List <byte[]>();
         for (int i = 1; i < gamescreen.Count; i++)
         {
             scrs.Add(gamescreen[i]);
         }
         ShopWindows.client.AddModerationProduct(MainWindow.shopWindows.profile.Mail, yourgame, scrs.ToArray());
         System.Windows.MessageBox.Show("Успешно отправлено на модерацию");
         MainWindow.shopWindows.Visibility = Visibility.Visible;
         MainWindow.shopWindows.Refresh.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
         this.Close();
     }
 }
Пример #4
0
        public ModelProduct MakeModelProduct(Service.Product product)
        {
            DataProvider dp           = new DataProvider();
            ModelProduct modelProduct = new ModelProduct();

            modelProduct.Name        = product.Name;
            modelProduct.Image       = dp.GetImageFromByte(product.MainImage);
            modelProduct.Description = product.Description;
            return(modelProduct);
        }
Пример #5
0
        private bool FilterProductLibrary(object obj)
        {
            bool result = true;

            Service.Product product = obj as Service.Product;
            if (!string.IsNullOrWhiteSpace(FilterText) && product != null && !product.Name.Contains(FilterText) && !product.Description.Contains(FilterText))
            {
                result = false;
            }
            return(result);
        }
Пример #6
0
        public async Task <IActionResult> Save(Service.Product request)
        {
            var response = await GrpcCallerService.CallService <Service.SaveResponse>(async() => await _client.SaveAsync(request, deadline: DateTime.UtcNow.AddSeconds(30)));

            if (!response.IsSuccessful)
            {
                _logger.LogError($"{nameof(ProductServiceController)} call unsuccessful on Save: {response.Message}");
            }


            return(ResponseHelper.PrepareServiceCallResponse(this, response.ServiceResponse.ServiceProcessResult.IsSuccessful, response));
        }
Пример #7
0
        private void Delgame_Click(object sender, RoutedEventArgs e)
        {
            Service.Product idx  = profile.Games[mylibrary.SelectedIndex];
            string          path = GetPathToGame(idx.Id) + "\\" + idx.Name + ".exe";

            if (path != null && File.Exists(path))
            {
                File.Delete(path);
                Play.Visibility     = Visibility.Hidden;
                Download.Visibility = Visibility.Visible;
            }
        }
Пример #8
0
        private void leftmouse_mylibrary(object sender, EventArgs e)
        {
            Screenshoot.Items.Clear();
            Screenshoot1.Items.Clear();
            Screenshoot2.Items.Clear();
            Screenshoot3.Items.Clear();
            Screenshoot4.Items.Clear();
            Screenshoot5.Items.Clear();
            screns.Clear();
            Service.Product idx = profile.Games[mylibrary.SelectedIndex];

            screns.Add(idx.MainImage);
            List <byte[]> d = ShopWindows.client.GetGameImages(idx.Id).ToList();

            for (int h = 0; h < d.Count; h++)
            {
                screns.Add(d.ToList()[h]);
                modelProducts = new List <ModelImage>();
            }
            foreach (byte[] product in screns)
            {
                ModelImage modelProduct = new ModelImage();
                modelProducts.Add(modelProduct.MakeModelImage(product));
            }
            Screenshoot.Items.Add(modelProducts[0]);
            Screenshoot1.Items.Add(modelProducts[0 + 1]);
            Screenshoot2.Items.Add(modelProducts[0 + 2]);
            Screenshoot3.Items.Add(modelProducts[0 + 3]);
            Screenshoot4.Items.Add(modelProducts[0 + 4]);
            Screenshoot5.Items.Add(modelProducts[0 + 5]);

            string path = GetPathToGame(idx.Id) + "\\" + idx.Name + ".exe";

            if (path == null || !File.Exists(path))
            {
                Download.Visibility = Visibility.Visible;
                Play.Visibility     = Visibility.Hidden;
            }
            else
            {
                Download.Visibility = Visibility.Hidden;
                Play.Visibility     = Visibility.Visible;
            }
            int i = mylibrary.SelectedIndex;

            if (i != -1)
            {
                tbgamename.Visibility = Visibility.Visible;
                tbgamename.Text       = profile.Games[i].Name;
            }
        }
Пример #9
0
        public ModelProductCart MakeModelProductCart(Service.Product product)
        {
            DataProvider     dp           = new DataProvider();
            ModelProductCart modelProduct = new ModelProductCart();

            modelProduct.Id             = product.Id;
            modelProduct.Name           = product.Name;
            modelProduct.Image          = dp.GetImageFromByte(product.MainImage);
            modelProduct.How            = 1;
            modelProduct.Price          = 0;
            modelProduct.RetailPrice    = product.RetailPrice;
            modelProduct.WholesalePrice = product.WholesalePrice;
            return(modelProduct);
        }
Пример #10
0
        private void Play_Click(object sender, RoutedEventArgs e)
        {
            Service.Product idx  = profile.Games[mylibrary.SelectedIndex];
            string          file = GetPathToGame(idx.Id) + @"\" + idx.Name + ".exe";

            if (file != null && File.Exists(file))
            {
                System.Diagnostics.Process.Start(file);
            }
            else
            {
                WinForms.MessageBox.Show("Файл не найден");
            }
        }
Пример #11
0
        private void Download_Click(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog openFileDialog = new FolderBrowserDialog();

            Service.Product idg = profile.Games[mylibrary.SelectedIndex];
            //   openFileDialog.Filter = "All files (*.*)";
            // openFileDialog.CheckFileExists = false;
            openFileDialog.ShowDialog();
            string s = openFileDialog.SelectedPath;

            if (s != "")
            {
                s += @"\" + idg.Name;
                if (!File.Exists(s + "\\" + idg.Name + ".exe"))
                {
                    BackgroundWorker worker = new BackgroundWorker();
                    worker.RunWorkerCompleted   += worker_RunWorkerCompleted;
                    worker.WorkerReportsProgress = true;
                    worker.ProgressChanged      += worker_ProgressChanged;
                    worker.DoWork += worker_DoWork;
                    DownloadProduct downloadProduct = new DownloadProduct();
                    downloadProduct.path   = s;
                    downloadProduct.idUser = profile.ID;
                    downloadProduct.idGame = idg.Id;
                    SetPathToGame(s, idg.Id);
                    worker.RunWorkerAsync(downloadProduct);
                    MainWindow.shopWindows.Play.Visibility     = Visibility.Visible;
                    MainWindow.shopWindows.Download.Visibility = Visibility.Hidden;
                    //}
                    // dp.Download();
                }
                else
                {
                    UpdatePathToGame(s, idg.Id);
                    System.Windows.MessageBox.Show("По данному пути мы уже нашли эту игру, скачивать ничего не нужно");
                    Download.Visibility = Visibility.Hidden;
                    Play.Visibility     = Visibility.Visible;
                    //переназначить путь
                }
            }
        }
Пример #12
0
        public List <Product> GetAllProduct()
        {
            connectionName = dbc.ConnectDB(connect);

            List <Service.Product> productList = new List <Service.Product>();

            using (SqlConnection conn = new SqlConnection(connectionName))
            {
                SqlCommand cmd = new SqlCommand("GetAllProducts", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                try
                {
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        Service.Product product = new Service.Product();

                        product.IdProduct = Convert.ToInt32(dr["IdProduct"]);
                        product.Name      = dr["Name"].ToString();
                        product.Price     = Convert.ToDouble(dr["Price"]);

                        productList.Add(product);
                    }
                }
                catch (Exception)
                {
                    throw new ApplicationException("Error");
                }

                finally
                {
                    conn.Close();
                }

                return(productList);
            }
        }
Пример #13
0
        public bool check(Service.Product pr)
        {
            this.Title = "Maets";

            List <Service.Product> listpr = prof.Games.ToList();
            int q = 0;

            for (int i = 0; i < listpr.Count; i++)
            {
                if (listpr[i].Id == pr.Id)
                {
                    q++;
                }
            }
            if (q != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #14
0
        private void Inicialize(Service.Product productnow)
        {
            ocenka.Text = Convert.ToString(productnow.Rate);
            screns      = new List <byte[]>();
            screns.Add(productnow.MainImage);
            List <byte[]> d = ShopWindows.client.GetGameImages(productnow.Id).ToList();

            for (int i = 0; i < d.Count; i++)
            {
                screns.Add(d.ToList()[i]);
            }
            ;
            foreach (string janr in productnow.GameGenre)
            {
                janrs.Text += " " + janr + " ";
            }
            foreach (string minr in productnow.MinGameSysReq)
            {
                sysmin.Text += " " + minr + "\n";
            }
            foreach (string recr in productnow.RecGameSysReq)
            {
                sysrec.Text += " " + recr + "\n";
            }
            modelProducts = new List <ModelImage>();
            foreach (byte[] product in screns)
            {
                ModelImage modelProduct = new ModelImage();
                modelProducts.Add(modelProduct.MakeModelImage(product));
            }
            Back.IsEnabled = false;
            cms            = ShopWindows.client.GetAllGameComments(tv1.Id).ToList();
            modelComments  = new List <ModelProfileComment>();
            foreach (Tuple <Service.Comment, Service.Profile> product in cms)
            {
                ModelProfileComment modelComment = new ModelProfileComment();
                modelComments.Add(modelComment.MakeModelProfileComment(product));
            }
            for (int i = 0; i < modelComments.Count; i++)
            {
                if (modelComments[i].ID != MainWindow.shopWindows.profile.ID)
                {
                    Lvcomment.Items.Add(modelComments[i]);
                }
                else
                {
                    qqqq            = 1;
                    mycom_hint.Text = modelComments[i].Comment;
                    com.ToolTip     = "Вы можете оставить только один комментарий";
                }
            }
            Back.IsEnabled = false;
            if (modelComments.Count == 0)
            {
                nocomments.Visibility = Visibility.Visible;
                Lvcomment.Visibility  = Visibility.Hidden;
            }
            else
            {
                nocomments.Visibility = Visibility.Hidden;
                Lvcomment.Visibility  = Visibility.Visible;
            }
            if (!inmylibrary())
            {
                mycom_hint.Text  = "Только купившие игру пользователи могут оставлять на нее комментарии";
                mycomm.IsEnabled = false;
                com.IsEnabled    = false;
                ocenka.IsEnabled = false;
            }

            Screenshoot.Items.Add(modelProducts[ishop]);
            Screenshoot1.Items.Add(modelProducts[ishop + 1]);
            Screenshoot2.Items.Add(modelProducts[ishop + 2]);
            Screenshoot3.Items.Add(modelProducts[ishop + 3]);
            Screenshoot4.Items.Add(modelProducts[ishop + 4]);
            Screenshoot5.Items.Add(modelProducts[ishop + 5]);
            tbgameName.Text    = productnow.Name;
            tbDescription.Text = productnow.Description;
            tbDeveloper.Text   = productnow.Developer;
            tbPublisher.Text   = productnow.Publisher;
            //tbgame1.Text = productnow.Description + "\n" + productnow.Developer + "\n";
            price.Text    = Convert.ToString(productnow.RetailPrice);
            price.ToolTip = "Тут должна быть цена другая, но она пока не рабоатет";
            // Screenshoot.Source = dp.GetImageFromByte(tv.MainImage);
        }