Imports EDSL.Entities
Imports EDSL.DAL
Public Partial Class ProductDeleteControl
  Inherits System.Web.UI.UserControl
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If IsPostBack = False then
      txtID.Value = Request.QueryString("id")
      lblName.Text = Request.QueryString("idtext")
    End If

    If Request.QueryString("type") = "C" then
      Session("txtProductType") = "C"
      lblNameHeader.Text = "Training course to be deleted"
    End If
  End Sub
  Protected Sub btnDelete_click(ByVal sender As Object, ByVal e As System.EventArgs) handles btnDelete.Click 
        Call Deleteit(txtID.Value, Convert.ToInt32(Request.QueryString("cid")))
  End Sub
    Private Sub Deleteit(ByVal intID As Integer, ByVal intCategoryID As Integer)
        Dim objMainAdmin As New dbMainProduct
        If objMainAdmin.DeleteItem(intID, intCategoryID, Session("passover")) = True Then
            If Request.QueryString("type") = "C" Then
                Response.Redirect("listCourse.aspx")
            Else
                Response.Redirect("list.aspx")
            End If
        Else
            If Request.QueryString("type") = "C" Then
                divErrorPanel.InnerHtml = "Error deleting training course"
            Else
                divErrorPanel.InnerHtml = "Error deleting product"
            End If
        End If
    End Sub
  Protected Sub btnBack_click(ByVal sender As Object, ByVal e As EventArgs) Handles btnBack.Click
     If Request.QueryString("r") = "e" then
      If Request.QueryString("type") = "C" then
        Response.Redirect("editCourse.aspx?id=" & txtID.Value)
      Else
        Response.Redirect("edit1.aspx?id=" & txtID.Value)
      End If
    Else
      If Request.QueryString("type") = "C" then
        Response.Redirect("listCourse.aspx")
      Else
        Response.Redirect("list.aspx")
      End If
    End If
  End Sub
End Class
