Example #1
0
    private void DeleteUser()
    {
        string strError = "";

        if (userList.Contains("$"))
        {
            if (Commons.ShowConfirmMessage(Lang.GetMessageByLanguage("000012", Commons.Culture, Commons.ResourceMessage).Replace("$Count$", userList.Split('$').Length.ToString())))
            {
                strError = busUser.DeleteListUser(userList, User.UserInfo.Username, User.UserInfo.LanguageID);
            }
        }
        else
        {
            if (Commons.ShowConfirmMessage(Lang.GetMessageByLanguage("000005", Commons.Culture, Commons.ResourceMessage)))
            {
                strError = busUser.DeleteUser(userList, User.UserInfo.Username, User.UserInfo.LanguageID);
            }
        }

        if (strError.Equals(""))
        {
            LoadAllData();
        }
        else
        {
            Commons.ShowMessage(strError, 0);
        }
    }
Example #2
0
        private async Task DeleteUser()
        {
            user_code_list = "";
            foreach (int index in grvUser.GetSelectedRows())
            {
                user_code_list = string.Join("$", user_code_list, grvUser.GetRowCellDisplayText(index, gcolUsername));
            }

            if (user_code_list.Length > 0)
            {
                user_code_list = user_code_list.Substring(1);
            }

            SYS_tblUserDRO result = new SYS_tblUserDRO();

            result.ResponseItem.Message = "ready";
            if (!string.IsNullOrEmpty(user_code_list))
            {
                try
                {
                    if (user_code_list.Contains("$"))
                    {
                        if (CommonEngine.ShowConfirmMessageAlert(LanguageEngine.GetMessageCaption("000012", ConfigEngine.Language).Replace("$Count$", user_code_list.Split('$').Length.ToString())))
                        {
                            CommonEngine.ShowWaitForm(this.ParentForm);
                            result = await SYS_tblUserBUS.DeleteUser(user_code_list, CommonEngine.userInfo.Username, ConfigEngine.Language, new SYS_tblActionLogDTO
                            {
                                Activity      = BaseConstant.COMMAND_INSERT_EN,
                                UserID        = CommonEngine.userInfo.UserID,
                                LanguageID    = ConfigEngine.Language,
                                ActionVN      = BaseConstant.COMMAND_DELETE_VI,
                                ActionEN      = BaseConstant.COMMAND_DELETE_EN,
                                FunctionID    = "10",
                                DescriptionVN = string.Format("Tài khoản '{0}' vừa xóa thành công người dùng có các tên tài khoản '{1}'.", CommonEngine.userInfo.UserID, user_code_list.Replace("$", ", ")),
                                DescriptionEN = string.Format("Account '{0}' has deleted user successfully with username are '{1}'.", CommonEngine.userInfo.UserID, user_code_list.Replace("$", ", "))
                            });
                        }
                    }
                    else
                    {
                        if (CommonEngine.ShowConfirmMessageAlert(LanguageEngine.GetMessageCaption("000005", ConfigEngine.Language)))
                        {
                            CommonEngine.ShowWaitForm(this.ParentForm);
                            result = await SYS_tblUserBUS.DeleteUser(user_code_list, CommonEngine.userInfo.Username, ConfigEngine.Language, new SYS_tblActionLogDTO
                            {
                                Activity      = BaseConstant.COMMAND_INSERT_EN,
                                UserID        = CommonEngine.userInfo.UserID,
                                LanguageID    = ConfigEngine.Language,
                                ActionVN      = BaseConstant.COMMAND_DELETE_VI,
                                ActionEN      = BaseConstant.COMMAND_DELETE_EN,
                                FunctionID    = "10",
                                DescriptionVN = string.Format("Tài khoản '{0}' vừa xóa thành công người dùng có tên tài khoản '{1}'.", CommonEngine.userInfo.UserID, user_code_list),
                                DescriptionEN = string.Format("Account '{0}' has deleted user successfully with username is '{1}'.", CommonEngine.userInfo.UserID, user_code_list)
                            });
                        }
                    }

                    if (!CommonEngine.CheckValidResponseItem(result.ResponseItem))
                    {
                        return;
                    }
                    if (!result.ResponseItem.Message.Equals("ready"))
                    {
                        if (string.IsNullOrEmpty(result.ResponseItem.Message))
                        {
                            GetAllUsers();
                        }
                        else
                        {
                            CommonEngine.ShowMessage(result.ResponseItem.Message, 0);
                        }
                    }
                }
                catch (Exception ex)
                {
                    CommonEngine.ShowExceptionMessage(ex);
                }
                finally
                {
                    CommonEngine.CloseWaitForm();
                }
            }
            else
            {
                CommonEngine.ShowMessage("000027", IMC.Helper.MessageType.Warning, true);
            }
        }