protected void lvMyfvrt_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "DeleteMyfvrt") { try { lblMyfabourite.Text = string.Empty; int MyfabouriteID = Convert.ToInt32(e.CommandArgument); hdmyfvrt.Value = MyfabouriteID.ToString(); using (MyFavouriteRT receiverTransfer = new MyFavouriteRT()) { receiverTransfer.DeleteMyfabourite(MyfabouriteID); lblMyfabourite.Text = "Data successfully deleted..."; lblMyfabourite.ForeColor = System.Drawing.Color.Green; } } catch (Exception ex) { lblMyfabourite.Text = "Error : " + ex.Message; lblMyfabourite.ForeColor = System.Drawing.Color.Red; } } else if (e.CommandName == "EditMyfvrt") { try { using (AdGiverRT receiverTransfer = new AdGiverRT()) { lblMyfabourite.Text = string.Empty; string userEmailId = Convert.ToString(Session["UserName"]); AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId); using (MyFavouriteRT receiverTransferMyfvrt = new MyFavouriteRT()) { //int MaterialID = Convert.ToInt32(Request.QueryString["ID"]); List <MyFavourite> EmailIDfrmMyfvrt = receiverTransferMyfvrt.GetEmailIDfrmMyfvrt(userEmailId); if (adgiverEmailId.EmailID != null && EmailIDfrmMyfvrt != null && EmailIDfrmMyfvrt.Count > 0) { int UrlID = Convert.ToInt32(e.CommandArgument); MyFavourite url = receiverTransferMyfvrt.GetUrlFrmMyfvrt(UrlID); Response.Redirect("DetailPage?option=" + StringCipher.Encrypt(url.MaterialID.ToString())); } } } } catch (Exception ex) { lblMyfabourite.Text = "Error : " + ex.Message; lblMyfabourite.ForeColor = System.Drawing.Color.Red; } } }
protected void btnFvrt_Click(object sender, EventArgs e) { try { if (Session["UserName"] == null) { Response.Redirect("~/LoginPage"); } else { using (AdGiverRT receiverTransfer = new AdGiverRT()) { string userEmailId = Convert.ToString(Session["UserName"]); AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId); if (adgiverEmailId != null) { using (MyFavouriteRT receiverTransferMyfvrt = new MyFavouriteRT()) { int MaterialID = Convert.ToInt32(Session["detailID"]); MyFavourite EmailIDnMaterialID = receiverTransferMyfvrt.GetEmailIDnMaterialID(userEmailId, MaterialID); MyFavourite myFvrt = CreatemyFavrt(); if (EmailIDnMaterialID == null) { receiverTransferMyfvrt.AddMYFvrt(myFvrt); lblFvrt.Text = "You Add your Favourite Item Successfully..."; lblFvrt.ForeColor = System.Drawing.Color.DarkSlateBlue; } else { lblFvrt.Text = "This Item is already added to your Favourite..."; lblFvrt.ForeColor = System.Drawing.Color.Red; } } } else { lblFvrt.Text = "Data not Added..."; lblFvrt.ForeColor = System.Drawing.Color.Red; } } } } catch (Exception ex) { lblFvrt.Text = "Error : " + ex.Message; lblFvrt.ForeColor = System.Drawing.Color.Red; } }
private void LoadMyFavourite() { try { using (MyFavouriteRT receiverTransfer = new MyFavouriteRT()) { string EmailID = Session["UserName"].ToString(); lvMyfvrt.DataSource = receiverTransfer.GetMyFavouriteAllForListView(EmailID);; lvMyfvrt.DataBind(); } } catch (Exception ex) { lblMyfabourite.Text = "Error : " + ex.Message; lblMyfabourite.ForeColor = System.Drawing.Color.Red; } }