protected void cmdGetpassword_Click(object sender, EventArgs e) { try { if (CFunctions.IsNullOrEmpty(gp_txtUsername.Text) || !CFunctions.IsAlpha(gp_txtUsername.Text)) { gp_lblError.Text = CCommon.Get_Definephrase(Definephrase.Invalid_username); return; } if (CFunctions.IsNullOrEmpty(gp_txtEmail.Text) || !CFunctions.IsEmail(gp_txtEmail.Text)) { gp_lblError.Text = CCommon.Get_Definephrase(Definephrase.Invalid_email); return; } CUser DALUser = new CUser(); UserInfo info = DALUser.Getinfo(gp_txtUsername.Text.Trim()); if (info == null) { gp_lblError.Text = CCommon.Get_Definephrase(Definephrase.Invalid_username_notexist); return; } else { if (info.Email != gp_txtEmail.Text.Trim()) { gp_lblError.Text = CCommon.Get_Definephrase(Definephrase.Invalid_username_email); return; } string passwordold = info.Password; string passwordnew = CFunctions.Randomstr(6); if (DALUser.Updatestr(info.Id.ToString(), "password", CFunctions.MBEncrypt(passwordnew))) { info.Password = passwordnew; CCommon.Session_Set(Sessionparam.USERREGISTER, info); pnlGetpassword.Controls.Clear(); Label lbl = new Label(); lbl.Text = CCommon.Get_Definephrase(Definephrase.Getpassword_done); lbl.CssClass = "control"; pnlGetpassword.Controls.Add(lbl); ScriptManager.RegisterStartupScript(this, this.GetType(), "Createuser", "Createuser();", true); } else { DALUser.Updatestr(info.Id.ToString(), "password", passwordold); gp_lblError.Text = CCommon.Get_Definephrase(Definephrase.Getpassword_error); } } } catch (Exception ex) { throw ex; } }
protected void cmdSave_Click(object sender, EventArgs e) { try { if (!this.Validata()) return; lstError = new List<Errorobject>(); UserInfo info = this.Take(); if (info == null) { lstError = Form_GetError(lstError, Errortype.Error, Definephrase.Takeinfo_error, "", null); Master.Form_ShowError(lstError); return; } CConstants.State.Existed vlExist = (new CUser()).Exist(info); if (vlExist == CConstants.State.Existed.Name) { lstError = Form_GetError(lstError, Errortype.Error, Definephrase.Exist_username, "", null); Master.Form_ShowError(lstError); return; } if (this.Save(info)) { // update permittion for all user in group CUser VDAL = new CUser(); List<UserInfo> list = VDAL.Wcmm_Getlistuser(info.Id); if (list != null && list.Count > 0) { foreach (UserInfo _info in list) { _info.iRight = info.iRight.copy(); VDAL.Save(_info); } } lstError = Form_GetError(lstError, Errortype.Completed, Definephrase.Save_completed, "", null); Master.Form_ShowError(lstError); if (chkSaveoption_golist.Checked) this.Load_Info(info.Id); Form_SaveOption(!chkSaveoption_golist.Checked); } else { lstError = Form_GetError(lstError, Errortype.Error, Definephrase.Save_error, "", null); Master.Form_ShowError(lstError); } } catch (Exception ex) { CCommon.CatchEx(ex); } }