protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { int totCnt = SafeValue.SafeInt(System.Configuration.ConfigurationManager.AppSettings["License"], 0); int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar("SELECT COUNT(SequenceId) FROM [User]"), 0); if (cnt - 1 >= totCnt) { throw new Exception("Error, pls contact your IT"); } else { ASPxGridView grd = sender as ASPxGridView; ASPxTextBox pwd = grd.FindEditFormTemplateControl("txtPwd") as ASPxTextBox; if (pwd.Text == "") { e.Cancel = true; throw new Exception("Please enter the password ."); } else { ASPxTextBox userId = grd.FindEditFormTemplateControl("txtCode") as ASPxTextBox; Encryption.EncryptClass encrypt = new Encryption.EncryptClass(); e.NewValues["Pwd"] = encrypt.DESEnCode(userId.Text, pwd.Text); } e.NewValues["IsActive"] = true; } }
public override bool ValidateUser(string userName, string password) { OPathQuery query = new OPathQuery(typeof(C2.User), "Name='" + userName + "'", "Name"); C2.User user = C2.Manager.ORManager.GetObject(query) as C2.User; if (user == null) { return(false); } Encryption.EncryptClass encrypt = new Encryption.EncryptClass(); return(SafeValue.SafeString(encrypt.DESEnCode(userName, password), "") == user.Pwd); // return (user.Pwd == password); }
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { ASPxGridView grd = sender as ASPxGridView; ASPxTextBox pwd = grd.FindEditFormTemplateControl("txtPwd") as ASPxTextBox; if (pwd.Text == "") { //e.Cancel = true; //throw new Exception("Please enter the password ."); } else { ASPxTextBox userId = grd.FindEditFormTemplateControl("txtCode") as ASPxTextBox; Encryption.EncryptClass encrypt = new Encryption.EncryptClass(); e.NewValues["Pwd"] = encrypt.DESEnCode(userId.Text, pwd.Text); } }
public void User_register_Submit(string info) { JObject jo = (JObject)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(Server.UrlDecode(info))); string mobile = SafeValue.SafeString(jo["account"]); string pw = SafeValue.SafeString(jo["password"]); string username = SafeValue.SafeString(jo["userName"]); bool status = false; string context = ""; Encryption.EncryptClass encrypt = new Encryption.EncryptClass(); string pw_mm = SafeValue.SafeString(encrypt.DESEnCode(username, pw), ""); List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>(); list.Add(new ConnectSql_mb.cmdParameters("@Name", username, SqlDbType.NVarChar, 100)); list.Add(new ConnectSql_mb.cmdParameters("@Pwd", pw_mm, SqlDbType.NVarChar, 100)); list.Add(new ConnectSql_mb.cmdParameters("@Tel", mobile, SqlDbType.NVarChar, 100)); string sql = string.Format(@"select * from [User] where Name=@Name,Tel=@Tel"); DataTable dt = ConnectSql_mb.GetDataTable(sql, list); if (dt.Rows.Count == 0) { sql = string.Format(@"insert into [User] (Name,Pwd,Email,Tel,Role,IsActive,CustId,Port) values(@Name,@Pwd,'',@Tel,'Client',1,'','')"); ConnectSql_mb.sqlResult result = ConnectSql_mb.ExecuteNonQuery(sql, list); status = result.status; if (!status) { context = result.context; } } else { context = "This user name or mobile have be registered"; } context = Common.StringToJson(context); Common.WriteJsonP(status, context); }
public void UserLogin_Login(string info) { string info_ = HttpUtility.UrlDecode(Server.UrlDecode(info)); JObject jo = (JObject)JsonConvert.DeserializeObject(info_); bool status = false; string context = Common.StringToJson(""); string account = jo["account"].ToString(); string pw = jo["password"].ToString(); if (account == null || account.Length <= 0) { context = Common.StringToJson("Request Account"); } else { List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>(); ConnectSql_mb.cmdParameters cpar = null; string sql = string.Format(@"select * from [user] where IsActive=1 and Tel=@Tel and Role='Client'"); cpar = new ConnectSql_mb.cmdParameters("@Tel", account, SqlDbType.NVarChar, 100); list.Add(cpar); DataTable dt = ConnectSql_mb.GetDataTable(sql, list); if (dt.Rows.Count > 0) { Encryption.EncryptClass encrypt = new Encryption.EncryptClass(); for (int i = 0; i < dt.Rows.Count; i++) { string PW_code = SafeValue.SafeString(encrypt.DESEnCode(dt.Rows[i]["Name"].ToString(), pw), ""); if (PW_code.Equals(dt.Rows[i]["Pwd"].ToString())) { sql = string.Format(@"select * from [user] where SequenceId=@SequenceId"); list = new List <ConnectSql_mb.cmdParameters>(); cpar = new ConnectSql_mb.cmdParameters("@SequenceId", dt.Rows[i]["SequenceId"], SqlDbType.Int); list.Add(cpar); DataTable dt1 = ConnectSql_mb.GetDataTable(sql, list); status = true; context = Common.DataRowToJson(dt1); //===========log C2.CtmJobEventLog lg = new C2.CtmJobEventLog(); lg.Platform_isMobile(); lg.Controller = dt.Rows[i]["Name"].ToString(); lg.Remark = dt.Rows[i]["Name"] + " Login"; lg.ActionLevel = "USER"; lg.log(); break; } } if (!status) { context = Common.StringToJson("Password error"); } } else { sql = string.Format(@"select * from [user] where IsActive=0 and Tel=@Tel"); dt = ConnectSql_mb.GetDataTable(sql, list); if (dt.Rows.Count > 0) { context = Common.StringToJson("Expire Account"); } else { context = Common.StringToJson("Account is not Exist"); } } } Common.WriteJsonP(status, context); }