Exemplo n.º 1
0
        public void Login()
        {
            bool   result;
            short  routes = 0;
            BAudit bAudit = new BAudit();
            BUser  bUser  = new BUser();
            EUser  eUser  = new EUser();

            eUser.CodeUser           = Aleatory.GetString(8);
            eUser.Name               = Aleatory.GetString(8);
            eUser.Password           = Aleatory.GetString(8);
            eUser.Email              = Aleatory.GetString(15);
            eUser.State              = Aleatory.GetShort();
            eUser.Audit.UserRegister = Aleatory.GetString(8);

            TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew);

            bUser.Delete(eUser);

            result = bUser.Login(eUser);
            if (result == false &&
                bUser.Message.Contains("usuario") &&
                bUser.Message.Contains("no existe"))
            {
                routes++;
            }

            eUser.State = 0;
            bUser.Insert(eUser);
            result = bUser.Login(eUser);
            if (result == false &&
                bUser.Message.Contains("El usuario") &&
                bUser.Message.Contains("no se encuentra 'Activo'."))
            {
                routes++;
            }

            eUser.State = 1;
            bUser.Update(eUser);
            result = bUser.Login(eUser);
            if (result == true && bUser.Message == "Ok")
            {
                routes++;
            }

            bUser.Delete(eUser);
            eUser.Password = "******";
            bUser.Insert(eUser);
            eUser.Password = "******";
            result         = bUser.Login(eUser);
            if (result == false && bUser.Message == "Password incorrecto.")
            {
                routes++;
            }

            ts.Dispose();

            Assert.AreEqual(routes, 4);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sự kiện xảy ra khi thực hiện các thao tác trên danh sách  Công văn đi
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void grvListDocument_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     //-- Sửa Công văn đi
     if (e.CommandName.Equals("cmdEdit", StringComparison.OrdinalIgnoreCase))
     {
         //-- Chuyển tới trang sửa  Công văn đi
         Response.Redirect("/DocumentSend/DocumentEdit.aspx?DocumentId=" + e.CommandArgument.ToString());
     }
     //--Xóa  Công văn đi
     else if (e.CommandName.Equals("cmdDelete", StringComparison.OrdinalIgnoreCase))
     {
         BUser ctl = new BUser();
         try
         {
             //-- THực hiện xóa  Công văn đi
             ctl.Delete(e.CommandArgument.ToString());
             //--Load lại danh sách  Công văn đi
             BindData();
         }
         catch (Exception ex)
         {
             //--Load lại danh sách  Công văn đi
             BindData();
         }
     }
     //--Khóa  Công văn đi
     else if (e.CommandName.Equals("cmdUnApprove", StringComparison.OrdinalIgnoreCase))
     {
         BUser ctl = new BUser();
         try
         {
             //-- THực hiện cập nhật trạng thái
             ctl.UpdateStatus(e.CommandArgument.ToString(), UserStatus.UnApprove.ToString("D"));
             //--Load lại danh sách  Công văn đi
             BindData();
         }
         catch (Exception ex)
         {
             //--Load lại danh sách  Công văn đi
             BindData();
         }
     }
     //--Duyệt  Công văn đi
     else if (e.CommandName.Equals("cmdApprove", StringComparison.OrdinalIgnoreCase))
     {
         BUser ctl = new BUser();
         try
         {
             //-- THực hiện cập nhật trạng thái
             ctl.UpdateStatus(e.CommandArgument.ToString(), UserStatus.Approve.ToString("D"));
             //--Load lại danh sách  Công văn đi
             BindData();
         }
         catch (Exception ex)
         {
             //--Load lại danh sách  Công văn đi
             BindData();
         }
     }
 }
Exemplo n.º 3
0
        protected void ZButton4_Click(object sender, EventArgs e)
        {
            string  key = PubCom.GetRepeaterKey(rplist, "cbselect");
            SysUser su  = bu.GetUserByUserID(key);

            if (su != null && su.UserLoginName == Constants.AdminName)
            {
                Message.ShowWrong(this, "超级管理员不能删除");
            }
            else
            {
                if (bu.Delete(key) == 1)
                {
                    // 插入日志
                    SysOperateLog log = new SysOperateLog();
                    log.LogID           = StringHelper.getKey();
                    log.LogType         = LogType.帐户信息.ToString();
                    log.LogObjectID     = su.UserID;
                    log.LogObjectName   = "[" + su.UserLoginName + "]" + su.UserName;
                    log.OperateUser     = GetLogUserName();
                    log.OperateDate     = DateTime.Now;
                    log.LogOperateType  = "用户删除";
                    log.LogBeforeObject = JsonHelper.Obj2Json <SysUser>(su);

                    bsol.Insert(log);


                    Message.ShowOKAndReflashOfDelete(this, "删除成功", "zbquery");
                }
                else
                {
                    Message.ShowWrong(this, "删除失败");
                }
            }
        }
Exemplo n.º 4
0
        public ActionResult Delete(UserModel userModel)
        {
            try
            {
                var userEntity   = helperSession.mapping.CreateMapper().Map <UserModel, EUser>(userModel);
                var codeCompany  = "00";
                var userRegister = "Admin";
                if (helperSession.Company != null)
                {
                    codeCompany = helperSession.Company.CodeCompany;
                }
                if (helperSession.User != null)
                {
                    userRegister = helperSession.User.CodeUser;
                }
                userEntity.Audit.CodeCompany  = codeCompany;
                userEntity.Audit.UserRegister = userRegister;
                using (TransactionScope ts = new TransactionScope())
                {
                    userBussines.Delete(userEntity);
                    ts.Complete();
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }

            ViewBag.IsDelete         = true;
            userModel.CompaniesModel = GetCompanies(userModel);
            return(View(userModel));
        }
Exemplo n.º 5
0
        private void dgv_UserManage_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView gv = (DataGridView)sender;

            if (gv.Columns[e.ColumnIndex].Name == "Operate")
            {
                if (e.RowIndex < rowcount - 1)
                {
                    if (DialogResult.OK == MessageBoxEx.Show("确认要删除吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk))
                    {
                        if (BUse.Delete(" where DOCTOR_ID=" + Convert.ToInt32(gv.Rows[e.RowIndex].Cells["DOCTOR_ID"].Value.ToString())) >= 0)
                        {
                            FindUserInfo("");//刷新表格
                        }
                        else
                        {
                            MessageBoxEx.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    if (!gv.Rows[e.RowIndex].IsNewRow)
                    {
                        gv.Rows.RemoveAt(e.RowIndex);
                    }
                }
            }
            if (gv.Columns[e.ColumnIndex].Name == "Edit")//修改历史数据
            {
                SetDataGridViewRowEditModel(e.RowIndex);
                gv.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.DarkGray;
                htRow.Add(i++, e.RowIndex.ToString());
            }
            if (gv.Columns[e.ColumnIndex].Name == "Choose")
            {
                string[] strArray = gv.Rows[e.RowIndex].Cells[e.ColumnIndex - 1].Value.ToString().Split(',');

                if (strArray.Length > 0)
                {
                    for (int i = 0; i < lv_role.Items.Count; i++)
                    {
                        int j = Array.IndexOf(strArray, lv_role.Items[i].Text);
                        if (j >= 0)
                        {
                            lv_role.Items[i].Checked = true;
                        }
                        else
                        {
                            lv_role.Items[i].Checked = false;
                        }
                    }
                }
                this.p_role.Visible  = true;
                this.p_role.Location = new Point(MousePosition.X - this.p_role.Width, MousePosition.Y - 90);
                currentRowCount      = e.RowIndex;
            }
        }
Exemplo n.º 6
0
        public void Insert()
        {
            short            routes       = 0;
            BAudit           bAudit       = new BAudit();
            EAudit           eAudit       = null;
            BUser            bUser        = new BUser();
            EUser            eUser        = new EUser();
            EUser            insertedUser = null;
            TransactionScope ts           = new TransactionScope(TransactionScopeOption.RequiresNew);

            eUser.CodeUser           = Aleatory.GetString(8);
            eUser.Name               = Aleatory.GetString(8);
            eUser.Password           = Aleatory.GetString(8);
            eUser.Email              = Aleatory.GetString(15);
            eUser.State              = Aleatory.GetShort();
            eUser.Audit.UserRegister = Aleatory.GetString(8);

            if (bUser.Select(eUser) != null)
            {
                bUser.Delete(eUser);
            }

            if (bUser.Select(eUser) == null)
            {
                routes++;
            }

            bUser.Insert(eUser);

            insertedUser = bUser.Select(eUser);

            if (insertedUser != null)
            {
                routes++;
            }

            string hash = bUser.CalculateHash(eUser);

            if (insertedUser.Password == hash)
            {
                routes++;
            }

            eAudit = bAudit.Select(eUser.Audit).
                     Where(x => x.UserRegister == eUser.Audit.UserRegister &&
                           x.Code == eUser.Audit.Code &&
                           x.TypeEvent == "Insert").FirstOrDefault();
            if (eAudit != null)
            {
                routes++;
            }

            ts.Dispose();

            Assert.AreEqual(routes, 4);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Thực hiện thao tác
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtAccept_Click(object sender, EventArgs e)
        {
            BUser ctl = new BUser();

            switch (ddlAction.SelectedValue)
            {
            //-- Xóa
            case "Delete":
                foreach (GridViewRow r in grvListDocument.Rows)
                {
                    HtmlInputCheckBox chk = (HtmlInputCheckBox)r.FindControl("chkCheckUser");
                    if (chk.Checked)
                    {
                        //-- THực hiện xóa  Công văn đến
                        ctl.Delete(grvListDocument.DataKeys[r.RowIndex].Value.ToString());
                    }
                }
                //-- Load lại  Công văn đến
                BindData();
                break;

            //-- Duyệt
            case "Approve":
                foreach (GridViewRow r in grvListDocument.Rows)
                {
                    HtmlInputCheckBox chk = (HtmlInputCheckBox)r.FindControl("chkCheckUser");
                    if (chk.Checked)
                    {
                        //-- THực hiện duyệt  Công văn đến
                        ctl.UpdateStatus(grvListDocument.DataKeys[r.RowIndex].Value.ToString(), UserStatus.Approve.ToString("D"));
                    }
                }
                //-- Load lại  Công văn đến
                BindData();
                break;

            //-- Khóa
            case "UnApprove":
                foreach (GridViewRow r in grvListDocument.Rows)
                {
                    HtmlInputCheckBox chk = (HtmlInputCheckBox)r.FindControl("chkCheckUser");
                    if (chk.Checked)
                    {
                        //-- THực hiện xóa  Công văn đến
                        ctl.UpdateStatus(grvListDocument.DataKeys[r.RowIndex].Value.ToString(), UserStatus.UnApprove.ToString("D"));
                    }
                }
                //-- Load lại  Công văn đến
                BindData();
                break;
            }
        }
Exemplo n.º 8
0
        public UserResponse DeleteUser([FromBody] UserRequest request)
        {
            UserResponse response = new UserResponse();

            BaseRequest baseRequest = new BaseRequest();
            MUser       user        = new MUser();

            try
            {
                baseRequest.Language = request.Language;
                baseRequest.Session  = request.Session;

                /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }
                /*************FIN DEL METODO*************/

                user.UserId = request.User.UserId;

                int Val = 0;

                user.UserId = BUser.Delete(user, ref Val);

                if (Val.Equals(0))
                {
                    response.Code    = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.Success;
                }
                else if (Val.Equals(2))
                {
                    response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = String.Format(Messages.ErrorDelete, "User");
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = ex.Message;
            }


            response.User = user;

            return(response);
        }
Exemplo n.º 9
0
 /// <summary>
 /// 删除
 /// </summary>
 private void MasterToolBar_DoDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK)
     {
         try
         {
             GetCurrentSelectedTable();
             if (_currentUserTable != null)
             {
                 bUser.Delete(_currentUserTable.CODE, _currentUserTable.COMPANY_CODE);
                 Search(this.pgControl.GetCurrentPage());
             }
             else
             {
                 MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         _currentUserTable = null;
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Sự kiện xảy ra khi thực hiện các thao tác trên danh sách người dùng
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void grvListUsers_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     //-- Phân quyền người dùng
     if (e.CommandName.Equals("cmdUserGroup", StringComparison.OrdinalIgnoreCase))
     {
         //-- Chuyển tới trang phân quyền người dùng
         Response.Redirect("GroupForUser.aspx?username="******"&" + GenParamRedirect());
     }
     //-- Sửa người dùng
     else if (e.CommandName.Equals("cmdEdit", StringComparison.OrdinalIgnoreCase))
     {
         //-- Chuyển tới trang sửa người dùng
         Response.Redirect("Edit.aspx?username="******"cmdResetPass", StringComparison.OrdinalIgnoreCase))
     {
         BUser Bobj = new BUser();
         Bobj.Update(e.CommandArgument.ToString(), Common.ECommon.GetMd5String("nganson"));
     }
     //--Xóa người dùng
     else if (e.CommandName.Equals("cmdDelete", StringComparison.OrdinalIgnoreCase))
     {
         BUser ctl = new BUser();
         try
         {
             //-- THực hiện xóa người dùng
             ctl.Delete(e.CommandArgument.ToString());
             //--Load lại danh sách người dùng
             BindData();
         }
         catch (Exception ex)
         {
             //--Load lại danh sách người dùng
             BindData();
         }
     }
     //--Khóa người dùng
     else if (e.CommandName.Equals("cmdUnApprove", StringComparison.OrdinalIgnoreCase))
     {
         BUser ctl = new BUser();
         try
         {
             //-- THực hiện cập nhật trạng thái
             ctl.UpdateStatus(e.CommandArgument.ToString(), UserStatus.UnApprove.ToString("D"));
             //--Load lại danh sách người dùng
             BindData();
         }
         catch (Exception ex)
         {
             //--Load lại danh sách người dùng
             BindData();
         }
     }
     //--Duyệt người dùng
     else if (e.CommandName.Equals("cmdApprove", StringComparison.OrdinalIgnoreCase))
     {
         BUser ctl = new BUser();
         try
         {
             //-- THực hiện cập nhật trạng thái
             ctl.UpdateStatus(e.CommandArgument.ToString(), UserStatus.Approve.ToString("D"));
             //--Load lại danh sách người dùng
             BindData();
         }
         catch (Exception ex)
         {
             //--Load lại danh sách người dùng
             BindData();
         }
     }
 }