using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
namespace Project1.DeleteItem
{
/// <summary>
/// List Item Events
/// </summary>
public class DeleteItem : SPItemEventReceiver
{
/// <summary>
/// An item is being deleted.
/// </summary>
public override void ItemDeleting(SPItemEventProperties properties)
{
base.ItemDeleting(properties);
try
{
int ssss = properties.ListItemId;
SPSite site = properties.OpenSite();
SPSite site1 = properties.OpenSite();
SPSite site2 = properties.OpenSite();
//SPSite mySite = new SPSite(@"/Lists/ListAllEmailTemplates/");
//SPSite mySite1 = new SPSite(@"/Lists/EditEmailTemplate/");
//SPSite mySite2 = new SPSite(@"/Lists/ViewEmailTemplate/");
//SPWeb OWeb = mySite.OpenWeb();
//SPWeb OWeb1 = mySite1.OpenWeb();
//SPWeb OWeb2 = mySite2.OpenWeb();
SPWeb OWeb = properties.OpenWeb();
SPWeb OWeb1 = properties.OpenWeb();
SPWeb OWeb2 = properties.OpenWeb();
//TO Delete ListAllEmailTemplate
SPList OList = OWeb.Lists["ListAllEmailTemplates"];
SPListItem item = OList.GetItemById(ssss);
OWeb.AllowUnsafeUpdates = true;
item.Delete();
OWeb.AllowUnsafeUpdates = false;
//TO Delete EditEmailTemplate
SPList OList1 = OWeb1.Lists["EditEmailTemplate"];
SPListItem item1 = OList1.GetItemById(ssss);
OWeb1.AllowUnsafeUpdates = true;
item1.Delete();
OWeb1.AllowUnsafeUpdates = false;
//TO Delete ViewEmailTemplate
SPList OList2 = OWeb2.Lists["ViewEmailTemplate"];
SPListItem item2 = OList2.GetItemById(ssss);
OWeb2.AllowUnsafeUpdates = true;
item2.Delete();
OWeb2.AllowUnsafeUpdates = false;
}
catch (SPException Conflicts)
{
Conflicts.ToString();
}
}
}
}
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
namespace Project1.DeleteItem
{
/// <summary>
/// List Item Events
/// </summary>
public class DeleteItem : SPItemEventReceiver
{
/// <summary>
/// An item is being deleted.
/// </summary>
public override void ItemDeleting(SPItemEventProperties properties)
{
base.ItemDeleting(properties);
try
{
int ssss = properties.ListItemId;
SPSite site = properties.OpenSite();
SPSite site1 = properties.OpenSite();
SPSite site2 = properties.OpenSite();
//SPSite mySite = new SPSite(@"/Lists/ListAllEmailTemplates/");
//SPSite mySite1 = new SPSite(@"/Lists/EditEmailTemplate/");
//SPSite mySite2 = new SPSite(@"/Lists/ViewEmailTemplate/");
//SPWeb OWeb = mySite.OpenWeb();
//SPWeb OWeb1 = mySite1.OpenWeb();
//SPWeb OWeb2 = mySite2.OpenWeb();
SPWeb OWeb = properties.OpenWeb();
SPWeb OWeb1 = properties.OpenWeb();
SPWeb OWeb2 = properties.OpenWeb();
//TO Delete ListAllEmailTemplate
SPList OList = OWeb.Lists["ListAllEmailTemplates"];
SPListItem item = OList.GetItemById(ssss);
OWeb.AllowUnsafeUpdates = true;
item.Delete();
OWeb.AllowUnsafeUpdates = false;
//TO Delete EditEmailTemplate
SPList OList1 = OWeb1.Lists["EditEmailTemplate"];
SPListItem item1 = OList1.GetItemById(ssss);
OWeb1.AllowUnsafeUpdates = true;
item1.Delete();
OWeb1.AllowUnsafeUpdates = false;
//TO Delete ViewEmailTemplate
SPList OList2 = OWeb2.Lists["ViewEmailTemplate"];
SPListItem item2 = OList2.GetItemById(ssss);
OWeb2.AllowUnsafeUpdates = true;
item2.Delete();
OWeb2.AllowUnsafeUpdates = false;
}
catch (SPException Conflicts)
{
Conflicts.ToString();
}
}
}
}
No comments:
Post a Comment