Ejemplo n.º 1
0
    protected void btnUrunEkle_Click(object sender, EventArgs e)
    {                                    // YENİ ÜRÜN KAYDI YAPILIYOR
        if (UploadTest.HasFile == false) //  GÖRSEL SEÇİLMEDİ İSE HATA VERİYOR.
        {
            // No file uploaded!
            Label1.Text = "Ürün için uygun bir görsel giriniz.";
        }
        else
        {
            try
            {
                proxy = new ServiceReference1.ServiceClient();
                ServiceReference1.product objcust =                                 //EKLENECEK ÜRÜNÜ TANIMLIYOR
                                                    new ServiceReference1.product() //EKLENECEK ÜRÜNÜ TANIMLIYOR
                {                                                                   //EKLENECEK ÜRÜNÜ TANIMLIYOR
                    pname   = TextBox1.Text,                                        //EKLENECEK ÜRÜNÜ TANIMLIYOR
                    brand   = TextBox2.Text,                                        //EKLENECEK ÜRÜNÜ TANIMLIYOR
                    comment = TextBox3.Text,                                        //EKLENECEK ÜRÜNÜ TANIMLIYOR
                    price   = Convert.ToDouble(TextBox4.Text),                      //EKLENECEK ÜRÜNÜ TANIMLIYOR
                    pimage  = UploadTest.FileName,                                  //EKLENECEK ÜRÜNÜ TANIMLIYOR
                    stoch   = Convert.ToInt32(TextBox6.Text)                        //EKLENECEK ÜRÜNÜ TANIMLIYOR
                };
                proxy.InsertProduct(objcust);                                       // ÜRÜNÜ EKLİYOR

                ClearTextBoxes(this);                                               // Sayfa içindeki TextBoxları temizliyor.
                rptView.DataSource = proxy.GetProduct();
                rptView.DataBind();
                Label1.Text = "Ürün depoya eklenmiştir.";
            }
            catch (Exception)
            {
                Label1.Text = "Ürün kaydı oluşturulamamıştır. Lütfen girmiş olduğunuz bilgileri kontrol ediniz.";
                //throw;
            }
        }
    }