Пример #1
0
        public override void Delete()
        {
            try
            {
                if (objMaster.Current == null)
                {
                    return;
                }

                objMaster.Delete(objMaster.Current);



                OnNew();
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }
Пример #2
0
 public ActionResult Delete(int userId)
 {
     if (UserBO.GetById(userId) != null)
     {
         UserBO.Delete(userId);
         ModelState.AddModelError("", "Delete succeed");
     }
     else
     {
         return(RedirectToAction("NotFound", "Home"));
     }
     return(RedirectToAction("Index"));
 }
Пример #3
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            {
                int companyId = int.Parse(hdnSelectedCompanyID.Value.Trim());

                if (companyId > 0)
                {
                    try
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            CompanyBO objCompany = new CompanyBO(this.ObjContext);
                            objCompany.ID = companyId;
                            objCompany.GetObject();

                            List <UserBO> lstUsers = objCompany.UsersWhereThisIsCompany;
                            foreach (UserBO user in lstUsers)
                            {
                                UserBO objUser = new UserBO(this.ObjContext);
                                objUser.ID = user.ID;
                                objUser.GetObject();
                                objUser.Delete();
                            }

                            List <ClientBO> lstClient = objCompany.ClientsWhereThisIsDistributor;
                            foreach (ClientBO client in lstClient)
                            {
                                ClientBO objClient = new ClientBO(this.ObjContext);
                                objClient.ID = client.ID;
                                objClient.GetAllObject();
                                objClient.Delete();
                            }


                            objCompany.Delete();

                            this.ObjContext.SaveChanges();
                            ts.Complete();
                            this.PopulateDataGrid();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
Пример #4
0
        public ActionResult Delete(int userId)
        {
            ResponseViewModel resp = new ResponseViewModel();

            try
            {
                resp = UserObject.Delete(userId);
            }
            catch (Exception ex)
            {
                resp.Success = false;
                resp.Message = ex.Message;
            }

            return(Json(resp, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        public ServiceResult <ServiceResponse> DeleteUser(int id)
        {
            ServiceResult <ServiceResponse> result = new ServiceResult <ServiceResponse>();

            try
            {
                result.Data        = new ServiceResponse();
                result.Data.Status = (_userBO.Delete(id)) ? ServiceResponseStatus.Yes : ServiceResponseStatus.No;
            }
            catch (Exception ex)
            {
                result.HasError     = true;
                result.ErrorMessage = ex.Message;
            }

            return(result);
        }
Пример #6
0
        public override bool Delete(params object[] keys)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.EnterpriseNodeConnection.StartTransaction(IsolationLevel.ReadCommitted);

                var userBo = new UserBO();
                var obj    = userBo.Get(this.ConnectionHandler, keys);
                if (obj != null)
                {
                    if (!userBo.DeleteAssosiations(ConnectionHandler, obj))
                    {
                        throw new Exception("خطایی در حذف کاربر وجود دارد");
                    }

                    if (!userBo.Delete(this.ConnectionHandler, obj))
                    {
                        throw new Exception("خطایی در حذف کاربر وجود دارد");
                    }
                    if (!EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(this.EnterpriseNodeConnection).Delete(obj.Id))
                    {
                        throw new Exception("به دلیل وجود اطلاعات وابسته مجاز به حذف این کاربر نیستید");
                    }
                }

                this.ConnectionHandler.CommitTransaction();
                this.EnterpriseNodeConnection.CommitTransaction();
                return(true);
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.EnterpriseNodeConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.EnterpriseNodeConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
Пример #7
0
        void grdUsers_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
            {
                if (this.CanDelete == false)
                {
                    // ENUtils.ShowMessage("Permission Denied");
                    e.Cancel = true;
                }
                else
                {
                    UserBO objMaster = new UserBO();

                    try
                    {
                        objMaster.GetByPrimaryKey(grdUsers.CurrentRow.Cells["Id"].Value.ToInt());
                        if (objMaster.Current != null)
                        {
                            string userName  = objMaster.Current.UserName.ToStr();
                            string password  = objMaster.Current.Passwrd.ToStr();
                            string groupName = objMaster.Current.UM_SecurityGroup != null ? objMaster.Current.UM_SecurityGroup.GroupName : "";

                            objMaster.Delete(objMaster.Current);

                            OnNew();
                        }
                    }
                    catch (Exception ex)
                    {
                        if (objMaster.Errors.Count > 0)
                        {
                            ENUtils.ShowMessage(objMaster.ShowErrors());
                        }
                        else
                        {
                            ENUtils.ShowMessage(ex.Message);
                        }
                        e.Cancel = true;
                    }
                }
            }
        }