private void DeleteCustomer() { // Prepare the parameters // string where = "CustomerLastName LIKE N'My New%'"; // Delete user // UserInfo user = UserInfoProvider.GetUserInfo("My new user"); // UserInfoProvider.DeleteUser(user); // Get the data DataSet customers = CustomerInfoProvider.GetCustomers(null, null); if (!DataHelper.DataSourceIsEmpty(customers)) { foreach (DataRow customerDr in customers.Tables[0].Rows) { // Create object from DataRow CustomerInfo deleteCustomer = new CustomerInfo(customerDr); // Delete the customer CustomerInfoProvider.DeleteCustomerInfo(deleteCustomer); } //return true; } //return false; }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { URLHelper.Redirect("Customer_Edit_Frameset.aspx?customerid=" + Convert.ToString(actionArgument)); } else if (actionName == "delete") { int customerId = ValidationHelper.GetInteger(actionArgument, 0); // Check module permissions if (!ECommerceContext.IsUserAuthorizedToModifyCustomer()) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers"); return; } // Check customers dependencies if (CustomerInfoProvider.CheckDependencies(customerId)) { ShowError(GetString("Ecommerce.DeleteDisabled")); return; } // Delete CustomerInfo object from database CustomerInfoProvider.DeleteCustomerInfo(customerId); UniGrid.ReloadData(); } }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { var id = ValidationHelper.GetInteger(actionArgument, 0); if (actionName == "edit") { URLHelper.Redirect(UIContextHelper.GetElementUrl("CMS.Ecommerce", "EditCustomersProperties", false, id)); } else if (actionName == "delete") { // Check module permissions if (!ECommerceContext.IsUserAuthorizedToModifyCustomer()) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers"); return; } // Get customer to be deleted var customer = CustomerInfoProvider.GetCustomerInfo(id); // Check customers dependencies if ((customer != null) && customer.Generalized.CheckDependencies()) { ShowError(ECommerceHelper.GetDependencyMessage(customer)); return; } // Delete CustomerInfo object from database CustomerInfoProvider.DeleteCustomerInfo(customer); UniGrid.ReloadData(); } }