Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            buttonAddBook.Enabled = false;
            button3.Enabled       = true;
            button2.Enabled       = true;

            DataGridViewRow row            = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex];
            string          SelectedPIDsrt = row.Cells[0].Value.ToString();
            int             SelectedPID    = Int32.Parse(SelectedPIDsrt);

            PublicSelectedPID = SelectedPID;

            Com.Product SelectedProduct = AllBookProducts.Where(W => W.PID == SelectedPID).SingleOrDefault();

            richTextBox1.Text = SelectedProduct.Description;
            textBoxName.Text  = SelectedProduct.Name;
            textBox13.Text    = SelectedProduct.Price.ToString();
            textBox14.Text    = SelectedProduct.Discount.ToString();
            int ImgCount = Int32.Parse(SelectedProduct.Img);

            checkBox2.Checked = SelectedProduct.Available;
            var     serializer = new JavaScriptSerializer();
            SpecObj spec       = serializer.Deserialize <SpecObj>(SelectedProduct.specifications);

            textBox1.Text  = spec.Nevisande;
            textBox3.Text  = spec.GerdAavari;
            textBox2.Text  = spec.Nasher;
            textBox5.Text  = spec.Mozoo;
            textBox10.Text = spec.Vazn;
            textBox4.Text  = spec.NobateChap;
            textBox6.Text  = spec.SaleChap;
            textBox7.Text  = spec.TedadeSafhe;
            textBox8.Text  = spec.Ghat;
            textBox9.Text  = spec.Shabok;
            textBox11.Text = spec.MonasebBaraye;
            for (int i = 0; i < ImgCount; i++)
            {
                try
                {
                    System.Net.WebRequest  request  = System.Net.WebRequest.Create("https://www.hasma.ir/FitnessResource/Product/" + SelectedProduct.PID.ToString() + "/" + ImgCount + ".jpg");
                    System.Net.WebResponse response = request.GetResponse();
                    Stream responseStream           = response.GetResponseStream();
                    publicBitmapBookSelected = new Bitmap(responseStream);
                    imageList1.Images.Add(publicBitmapBookSelected);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 2
0
        private async void button3_Click(object sender, EventArgs e)
        {
            SpecObj spec = new SpecObj()
            {
                GerdAavari    = textBox3.Text,
                Ghat          = textBox8.Text,
                MonasebBaraye = textBox11.Text,
                Mozoo         = textBox5.Text,
                Nasher        = textBox2.Text,
                Nevisande     = textBox1.Text,
                NobateChap    = textBox4.Text,
                SaleChap      = textBox6.Text,
                Shabok        = textBox11.Text,
                TedadeSafhe   = textBox7.Text,
                Vazn          = textBox10.Text,
            };

            Com.Product UpProduct = new Com.Product()
            {
                PID            = PublicSelectedPID,
                CatID          = 1,
                Available      = checkBox2.Checked,
                Description    = richTextBox1.Text,
                Discount       = Int32.Parse(textBox14.Text),
                Img            = "",
                Name           = textBoxName.Text,
                Price          = Int32.Parse(textBox13.Text),
                specifications = JsonConvert.SerializeObject(spec)
            };

            var xx = await PostToServerUpdateProduct(UpProduct);

            Console.WriteLine(xx);
            if (xx == "Error")
            {
                MessageBox.Show("آپدیت نشد مشکل در سرور.");
            }
            else
            {
                MessageBox.Show("آپدیت شد.");
                GetDataANDRefreshGridView();

                listView1.Items.Clear();
                imageList1.Images.Clear();
                textBox3.Text     = "";
                textBox8.Text     = "";
                textBox11.Text    = "";
                textBox5.Text     = "";
                textBox2.Text     = "";
                textBox1.Text     = "";
                textBox4.Text     = "";
                textBox6.Text     = "";
                textBox11.Text    = "";
                textBox7.Text     = "";
                textBox10.Text    = "";
                richTextBox1.Text = "";
                textBox14.Text    = "";
                textBoxName.Text  = "";
                textBox13.Text    = "";
            }
        }