/// <summary> /// Deletes customTableItem. Called when the "Delete item" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool DeleteCustomTableItem() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text%'"; // Get the data DataSet customTableItems = customTableProvider.GetItems(customTableClassName, where, null); if (!DataHelper.DataSourceIsEmpty(customTableItems)) { // Loop through the individual items foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows) { // Create object from DataRow CustomTableItem deleteCustomTableItem = CustomTableItem.New(customTableItemDr, customTableClassName); // Delete custom table item from database deleteCustomTableItem.Delete(); } return(true); } } return(false); }
public void DeleteBrand(int brandID) { CustomTableItem brand = CustomTableItemProvider.GetItem(brandID, CustomTableName); if (brand != null) { brand.Delete(); } }
protected void gridData_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerCSafe()) { // Delete item action case "delete": if (CheckPermissions(PermissionsEnum.Delete)) { if (CustomTableClassInfo != null) { CustomTableItem item = CustomTableItemProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName); if (item != null) { item.Delete(); } } URLHelper.RefreshCurrentPage(); } break; // Move item up action case "moveup": if (CheckPermissions(PermissionsEnum.Modify)) { if (CustomTableClassInfo != null) { var item = CustomTableItemProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName); item.Generalized.MoveObjectUp(); } URLHelper.RefreshCurrentPage(); } break; // Move item down action case "movedown": if (CheckPermissions(PermissionsEnum.Modify)) { if (CustomTableClassInfo != null) { var item = CustomTableItemProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName); item.Generalized.MoveObjectDown(); } URLHelper.RefreshCurrentPage(); } break; } }
private bool DeleteCustomTableItem(DataClassInfo customTable) { try { if (customTable != null) { // Prepares the parameters string where = ""; // Gets the data DataSet customTableItems = _customTableProvider.GetItems(customTable.ClassName, where, null); if (!DataHelper.DataSourceIsEmpty(customTableItems)) { // Loops through the individual items foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows) { // Creates object from DataRow CustomTableItem deleteCustomTableItem = CustomTableItem.New(customTableItemDr, customTable.ClassName); // Deletes custom table item from database if (RadioButtonAll.Checked) { deleteCustomTableItem.Delete(); } } EventLogProvider.LogInformation("CustomTable", "Import delete", "Delete sucess"); return(true); } } } catch (Exception e) { EventLogProvider.LogInformation("CustomTable", "Import delete error", e.Message); } return(false); }
protected void gridData_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerCSafe()) { // Delete item action case "delete": if (CheckPermissions("Delete")) { if (CustomTableClassInfo != null) { CustomTableItem item = ctProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName); if (item != null) { item.Delete(); } } URLHelper.Redirect(URLHelper.Url.ToString()); } break; // Move item up action case "moveup": if (CheckPermissions("Modify")) { if (CustomTableClassInfo != null) { ctProvider.MoveItemUp(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName); } URLHelper.Redirect(URLHelper.Url.ToString()); } break; // Move item down action case "movedown": if (CheckPermissions("Modify")) { if (CustomTableClassInfo != null) { ctProvider.MoveItemDown(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName); } URLHelper.Redirect(URLHelper.Url.ToString()); } break; } }
public bool DeletePOS(int posID) { bool isDeleted = false; CustomTableItem posItem = CustomTableItemProvider.GetItem(posID, CustomTableName); if (posItem != null) { var isProductsExist = SKUInfoProvider.GetSKUs().WhereEquals("SKUProductCustomerReferenceNumber", posItem.GetStringValue("POSNumber", string.Empty)).Any(); if (!isProductsExist) { posItem.Delete(); isDeleted = true; } } return(isDeleted); }
protected void DeleteCustomTableItems() { // Prepares the code name (class name) of the custom table from which the record will be deleted string customTableClassName = "PbcLinear.ProductAssociations"; // Gets the custom table DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName); if (customTable != null) { // Gets the first custom table record whose value in the 'ItemText' starts with 'New text' CustomTableItem item = CustomTableItemProvider.GetItems(customTableClassName) .WhereStartsWith("ItemText", "New text") .FirstObject; if (item != null) { // Deletes the custom table record from the database item.Delete(); } } }
/// <summary> /// Deletes customTableItem. Called when the "Delete item" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool DeleteCustomTableItem() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text%'"; // Get the data DataSet customTableItems = customTableProvider.GetItems(customTableClassName, where, null); if (!DataHelper.DataSourceIsEmpty(customTableItems)) { // Loop through the individual items foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows) { // Create object from DataRow CustomTableItem deleteCustomTableItem = new CustomTableItem(customTableItemDr, customTableClassName); // Delete custom table item from database deleteCustomTableItem.Delete(); } return true; } } return false; }