Ejemplo n.º 1
0
 protected void rptProduct_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     try
     {
         bool result = false;
         if (e.CommandName == "btnDelete")
         {
             Button     btnDelete = e.Item.FindControl("btnDelete") as Button;
             ProductORM prodORM   = new ProductORM();
             result = prodORM.Delete(Convert.ToInt32(btnDelete.CommandArgument));
             if (result)
             {
                 rptProduct.DataSource = prodORM.List();
                 rptProduct.DataBind();
             }
         }
         else if (e.CommandName == "btnUpdate")
         {
             Session["ProductID"] = e.CommandArgument;
             Server.Transfer("NewProduct.aspx");
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
 private void productDeleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string       productName  = lstwProducts.SelectedItems[0].Text;
         int          productID    = Convert.ToInt32(lstwProducts.SelectedItems[0].Tag);
         DialogResult dialogResult = MessageBox.Show("Seçili Ürünü Silmek İstediğinize Emin Misiniz ?", productName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dialogResult == DialogResult.Yes)
         {
             ProductORM prodORM = new ProductORM();
             bool       result  = prodORM.Delete(productID);
             if (result)
             {
                 MessageBox.Show("Ürün Silme İşleminiz Başarıyla Gerçekleştirildi", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 ListViewProductFill(Convert.ToInt32(cbCategories.SelectedValue));
             }
             else
             {
                 MessageBox.Show("İşlem Sırasında Bir Hata Meydana Geldi !", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
     catch (SqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }