protected void ddlPrinter_SelectedIndexChanged(object sender, EventArgs e) { try { int visuallayout = int.Parse(((System.Web.UI.WebControls.WebControl)(sender)).Attributes["vlid"].ToString()); if (visuallayout > 0) { using (TransactionScope ts = new TransactionScope()) { VisualLayoutBO objVisualLayout = new VisualLayoutBO(this.ObjContext); objVisualLayout.ID = visuallayout; objVisualLayout.GetObject(); objVisualLayout.Printer = int.Parse(((System.Web.UI.WebControls.ListControl)(sender)).SelectedValue); this.ObjContext.SaveChanges(); ts.Complete(); } } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while saving Printer in ViewVisualLayout.aspx page", ex); } // this.pageIndex = pageIndex; this.PopulateVisualLayouts(); }
protected void btnDelete_Click(object sender, EventArgs e) { int vlId = int.Parse(this.hdnSelectedID.Value); if (vlId > 0) { using (TransactionScope ts = new TransactionScope()) { try { VisualLayoutBO objVisualLayout = new VisualLayoutBO(this.ObjContext); objVisualLayout.ID = vlId; objVisualLayout.GetObject(); List <ImageBO> lstVisualLayoutImages = objVisualLayout.ImagesWhereThisIsVisualLayout; foreach (ImageBO image in lstVisualLayoutImages) { ImageBO objImage = new ImageBO(this.ObjContext); objImage.ID = image.ID; objImage.GetObject(); objImage.Delete(); this.ObjContext.SaveChanges(); } List <VisualLayoutAccessoryBO> lstVisualLayoutAccessory = objVisualLayout.VisualLayoutAccessorysWhereThisIsVisualLayout; foreach (VisualLayoutAccessoryBO Accessory in lstVisualLayoutAccessory) { VisualLayoutAccessoryBO objVisualLayoutAccessory = new VisualLayoutAccessoryBO(this.ObjContext); objVisualLayoutAccessory.ID = Accessory.ID; objVisualLayoutAccessory.GetObject(); objVisualLayoutAccessory.Delete(); this.ObjContext.SaveChanges(); } // Delete from Visual Layout Fabric table records befor deleting Visual layout List <VisualLayoutFabricBO> lstVisualLayoutFabrics = objVisualLayout.VisualLayoutFabricsWhereThisIsVisualLayout; foreach (VisualLayoutFabricBO fabric in lstVisualLayoutFabrics) { VisualLayoutFabricBO objVisualLayoutFabric = new VisualLayoutFabricBO(this.ObjContext); objVisualLayoutFabric.ID = fabric.ID; objVisualLayoutFabric.GetObject(); objVisualLayoutFabric.Delete(); this.ObjContext.SaveChanges(); } objVisualLayout.Delete(); this.ObjContext.SaveChanges(); ts.Complete(); //Delete try { string folderLocation = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\VisualLayout\\" + vlId.ToString(); if (Directory.Exists(folderLocation)) { Directory.Delete(folderLocation, true); } } catch { } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while deleting visual layout", ex); } } this.PopulateVisualLayouts(); } }