Ejemplo n.º 1
0
    protected void user_add_Click(object sender, EventArgs e)
    {
        int type;

        if (user_type.Text == "医生")
        {
            type = 3;
        }
        else
        {
            type = 1;
        }
        if (UsersService.AddUsers(user_num.Text, user_name.Text, type, user_password.Text, user_sex.Text, int.Parse(user_age.Text), user_phone.Text, user_department.SelectedItem.Text.Trim()) != -1)
        {
            Response.Write("<script language=javascript>window.alert('添加用户成功');</script>");
            user_num.Text      = ""; user_name.Text = "";
            user_password.Text = "";
            user_age.Text      = "";
            user_phone.Text    = "";
        }
        else
        {
            Response.Write("<script language=javascript>window.alert('该用户编号已存在,请输入其他编号!');</script>");
        }
    }
Ejemplo n.º 2
0
        protected void BtnSubmit_OnClick(object sender, EventArgs e)
        {
            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            var file = UploadImage(FileUpload1, "../../upload/users/");

            Model917.Users users = new Model917.Users()
            {
                Users_Account  = this.txtAccount.Text.Trim(),
                Users_Password = this.txtPassword.Text.Trim(),
                Users_NickName = this.txtNickName.Text.Trim(),
                Users_RolesId  = Guid.Parse(this.ddlRolesList.SelectedValue),
                Users_Photo    = (file == null ? "def.png" : file)
            };
            Response.Write("<script>alert('" + file + "')</script>");
            var res = usersSvc.AddUsers(users);

            if (res > 0)
            {
                Response.Write("<script>alert('添加成功');location.href='Users_List.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');location.href='Users_List.aspx'</script>");
            }
        }
        public IActionResult Create([FromBody] UserAdminViewDto userAdminViewDto)
        {
            var userAdminView = Mapper.Map <UserAdminView>(userAdminViewDto);

            try
            {
                // save
                UsersService.AddUsers(userAdminView);
                return(Ok(userAdminView));
            }
            catch (Exception ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }