Exemplo n.º 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtName.Text.Trim() == "")
        {
            AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请填写名称");
            return;
        }

        MojoCube.Web.User.List list = new MojoCube.Web.User.List();

        //修改
        if (ViewState["pk_User"] != null)
        {
            MojoCube.Api.File.Upload upload = new MojoCube.Api.File.Upload();
            upload.FilePath = "User/" + ViewState["pk_User"].ToString();
            upload.FileName = MojoCube.Api.Text.Function.DateTimeString(true);
            upload.DoFileUpload(fuPortrait);

            list.GetData(int.Parse(ViewState["pk_User"].ToString()));

            if (cbResetPsw.Checked)
            {
                list.Password = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5").ToLower();
            }

            list.fk_Department = int.Parse(ddlDepartment.SelectedValue);
            list.RoleValue     = int.Parse(ddlRole.SelectedValue);
            list.RoleList      = ddlRole.SelectedValue;
            list.Position      = int.Parse(ddlPosition.SelectedValue);
            list.UserName      = txtName.Text.Trim();
            list.NickName      = txtNickName.Text.Trim();
            list.FullName      = txtFullName.Text.Trim();
            list.FirstName     = MojoCube.Web.String.GetChineseName(txtFullName.Text.Trim(), false);
            list.LastName      = MojoCube.Web.String.GetChineseName(txtFullName.Text.Trim(), true);
            list.Phone1        = txtPhone1.Text.Trim();
            list.Email1        = txtEmail1.Text.Trim();
            list.Address1      = txtAddress1.Text.Trim();
            list.Birthday      = txtBirthday.Text.Trim();
            list.Education     = txtEducation.Text.Trim();
            list.School        = txtSchool.Text.Trim();
            list.BankAccount   = txtBankAccount.Text.Trim();
            list.IDNumber      = txtIDNumber.Text.Trim();
            list.Wages         = MojoCube.Web.String.ToDecimal(txtWages.Text.Trim());
            list.EntryTime     = txtEntryTime.Text.Trim();
            list.Skin          = ddlSkin.SelectedValue;
            list.Sex           = int.Parse(ddlSex.SelectedValue);

            if (upload.IsUpload)
            {
                list.ImagePath1 = upload.OldFilePath;
            }

            list.ModifyUser = int.Parse(Session["UserID"].ToString());
            list.ModifyDate = DateTime.Now.ToString();
            list.UpdateData(list.pk_User);
        }
        //新增
        else
        {
            list.UserName      = txtName.Text.Trim();
            list.Password      = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5").ToLower();
            list.TypeID        = 0;
            list.fk_Department = int.Parse(ddlDepartment.SelectedValue);
            list.RoleValue     = int.Parse(ddlRole.SelectedValue);
            list.RoleList      = ddlRole.SelectedValue;
            list.Position      = int.Parse(ddlPosition.SelectedValue);
            list.Number        = string.Empty;
            list.Skin          = ddlSkin.SelectedValue;
            list.Language      = "CHS";
            list.IsLock        = false;
            list.LastLoginIP   = string.Empty;
            list.LastLoginTime = DateTime.Now.ToString();
            list.NickName      = txtNickName.Text.Trim();
            list.FullName      = txtFullName.Text.Trim();
            list.FirstName     = MojoCube.Web.String.GetChineseName(txtFullName.Text.Trim(), false);
            list.MiddleName    = string.Empty;
            list.LastName      = MojoCube.Web.String.GetChineseName(txtFullName.Text.Trim(), true);
            list.Phone1        = txtPhone1.Text.Trim();
            list.Phone2        = string.Empty;
            list.Email1        = txtEmail1.Text.Trim();
            list.Email2        = string.Empty;
            list.Fax           = string.Empty;
            list.Line          = string.Empty;
            list.Wechat        = string.Empty;
            list.QQ            = string.Empty;
            list.Facebook      = string.Empty;
            list.Twitter       = string.Empty;
            list.Linkedin      = string.Empty;
            list.ZipCode       = string.Empty;
            list.Place         = string.Empty;
            list.Address1      = txtAddress1.Text.Trim();
            list.Address2      = string.Empty;
            list.Province      = 0;
            list.City          = 0;
            list.County        = 0;
            list.Zone          = 0;
            list.Sex           = int.Parse(ddlSex.SelectedValue);
            list.Height        = 0;
            list.Weight        = 0;
            list.Birthday      = txtBirthday.Text.Trim();
            list.Education     = txtEducation.Text.Trim();
            list.School        = txtSchool.Text.Trim();
            list.ImagePath1    = string.Empty;
            list.ImagePath2    = string.Empty;
            list.IDCardPath    = string.Empty;
            list.ResumePath    = string.Empty;
            list.Wages         = MojoCube.Web.String.ToDecimal(txtWages.Text.Trim());
            list.BankAccount   = txtBankAccount.Text.Trim();
            list.IDNumber      = txtIDNumber.Text.Trim();
            list.Source        = string.Empty;
            list.Note          = string.Empty;
            list.Remark        = string.Empty;
            list.EntryTime     = txtEntryTime.Text.Trim();
            list.IsQuit        = false;
            list.QuitTime      = DateTime.Now.ToString();
            list.fk_Company    = 0;
            list.CreateUser    = int.Parse(Session["UserID"].ToString());
            list.CreateDate    = DateTime.Now.ToString();
            list.ModifyUser    = 0;
            list.ModifyDate    = DateTime.Now.ToString();
            list.InsertData();
        }

        Response.Redirect("List.aspx?active=" + Request.QueryString["active"]);
    }
Exemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtFullName.Text.Trim() == "")
        {
            AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请填写真实姓名");
            return;
        }

        MojoCube.Web.User.List list = new MojoCube.Web.User.List();

        //修改
        if (Session["UserID"] != null)
        {
            MojoCube.Api.File.Upload upload = new MojoCube.Api.File.Upload();
            upload.FilePath = "User/" + Session["UserID"].ToString();
            upload.FileName = MojoCube.Api.Text.Function.DateTimeString(true);
            upload.DoFileUpload(fuPortrait);

            list.GetData(int.Parse(Session["UserID"].ToString()));

            if (txtPassword1.Text.Trim() != "")
            {
                if (txtPassword1.Text.Trim().Length < 6)
                {
                    AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请输入至少6位密码");
                    return;
                }

                if (txtPassword1.Text.Trim() != txtPassword2.Text.Trim())
                {
                    AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "两次输入密码不一致");
                    return;
                }

                list.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword1.Text.Trim(), "MD5").ToLower();
            }

            list.UserName    = txtName.Text.Trim();
            list.NickName    = txtNickName.Text.Trim();
            list.FullName    = txtFullName.Text.Trim();
            list.FirstName   = MojoCube.Web.String.GetChineseName(txtFullName.Text.Trim(), false);
            list.LastName    = MojoCube.Web.String.GetChineseName(txtFullName.Text.Trim(), true);
            list.Phone1      = txtPhone1.Text.Trim();
            list.Email1      = txtEmail1.Text.Trim();
            list.Address1    = txtAddress1.Text.Trim();
            list.Education   = txtEducation.Text.Trim();
            list.School      = txtSchool.Text.Trim();
            list.BankAccount = txtBankAccount.Text.Trim();
            list.IDNumber    = txtIDNumber.Text.Trim();
            list.Skin        = ddlSkin.SelectedValue;
            list.Sex         = int.Parse(ddlSex.SelectedValue);
            list.Birthday    = txtBirthday.Text.Trim();
            list.Note        = txtNote.Text.Trim();

            if (upload.IsUpload)
            {
                list.ImagePath1 = upload.OldFilePath;
            }

            list.ModifyUser = int.Parse(Session["UserID"].ToString());
            list.ModifyDate = DateTime.Now.ToString();
            list.UpdateData(list.pk_User);

            Response.Redirect("Profile.aspx");
        }
    }