static void PrintAcounts(Acount[] acounts) { foreach (IPrintable acount in acounts) { acount.PrintInfo(); } }
public void SingIn() { if (inputName.text.Length < 6 || inputPassword.text.Length < 6) { Debug.Log("El Nombre y la contraseña deben tener mas de 6 digitos"); return; } foreach (var acount in data.acounts) { if (acount.name.Equals(inputName.text)) { Debug.Log("Esta cuenta ya existe."); return; } } var newAcount = new Acount(inputName.text, inputPassword.text); data.acounts.Add(newAcount); newAcount.player.items.Add(new DataSystem.Item("Small Potion", 3)); newAcount.player.items.Add(new DataSystem.Item("Medium Potion", 3)); newAcount.player.items.Add(new DataSystem.Item("Big Potion", 3)); newAcount.player.items.Add(new DataSystem.Item("Catcher", 5)); //newAcount.player.slimes.Add(new DataSystem.Slime("Lava",100,100,10, SlimeType.Water.ToString())); DataManager.SaveData <Data>(data); Globals.playerName = inputName.text; SceneManager.LoadScene("QuestionScreen"); //SceneManager.LoadScene("MainScreen"); }
public void testAcountData(Acount acount) { string query = @"INSERT INTO dbo.ACOUNT ( id, name, dateOfBirt, sex, --1 la nam; 0 la nu. --typeWord gom admin; thu kho; thu quy; nhan vien ban hang. telephone , email, typeWord , userName, passwords, pay ) VALUES ( '" + acount.Id + @"', N'" + acount.Name + @"', '" + acount.DateOfBirt + @"', " + acount.Sex.ToString() + @", '" + acount.Telephone + @"', '" + acount.Email + @"', '" + acount.TypeWord + @"', '" + acount.UserName + @"', '" + acount.PassWord + @"', " + acount.Pay.ToString() + @" )"; DataProvider.Instance.ExcuteQuery(query); }
//При загрузке нашего приложения инстантно скрывается меню //Поле ввода пароля автоматически вводит * вместо символов private void main_Load(object sender, EventArgs e) { menu.Hide(); if (File.Exists("login.json")) { Acount acc = JsonConvert.DeserializeObject <Acount>(File.ReadAllText("login.json")); string login = Decrypt(acc.Login, acc.Password); string password = Decrypt(acc.Password, login); pass = password; accessPassCopy.Dispose(); loginTB.Dispose(); label1.Dispose(); label2.Dispose(); label3.Dispose(); accounts = JsonConvert.DeserializeObject <List <Acount> >(File.ReadAllText("accounts.json")); accessPass.TextChanged += new EventHandler(accessPass_TextChanged); } else { File.WriteAllText("accounts.json", ""); accessPassCopy.PasswordChar = '*'; accessPassCopy.TextChanged += new EventHandler(accessPassCopy_TextChanged); } accessPass.PasswordChar = '*'; }
public string Authenticate(string username, string password, Acount acount) { if (acount == null) { return(null); } else { var tokenHandler = new JwtSecurityTokenHandler(); var tokenKey = Encoding.ASCII.GetBytes(key); var tokenDescription = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim("ID", acount.ID.ToString()), new Claim(ClaimTypes.Role, acount.ObjectRole) }), Expires = DateTime.UtcNow.AddHours(1), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(tokenKey), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescription); return(tokenHandler.WriteToken(token)); } }
public async Task <int> create(UserAcountDetails user) { Acount a = new Acount() { Username = user.Username, Password = user.Password, ObjectRole = "ROLE_USER" }; _dbContext.Acounts.Add(a); Guid idAcount = a.ID; User u = new User() { Name = user.Name, School = user.School, Phone = user.Phone, Email = user.Email, Area = user.Area, ID_Acount = idAcount }; _dbContext.Users.Add(u); a.User = u; return(await _dbContext.SaveChangesAsync()); }
public void SetClient(SelectionWell sw, Objecte obj = null) { if (sw == null) { return; } client = Helpers.LogicHelper.ClientsLogic.FirstModel(sw.GetIDValue(C.SelectionWell.Well, C.Well.Object, C.Objecte.Client)); if (obj == null) { objecte = client.Objects.FirstOrDefault(x => AdresHelper.ComparisonAdres(x.Adres, Adres) || Acount.Split(',').FirstOrDefault(y => x.Accounts.Contains(y)) != null); } else { objecte = obj; } if (objecte != null) { List <string> ac = new List <string>(); foreach (var one in Acount.Split(',')) { if (!objecte.Accounts.Contains(one)) { ac.Add(one); } } if (ac.Count > 0) { objecte.SetAccounts(ac.ToArray()); } sample = Helpers.LogicHelper.SampleLogic.FirstModel(sw.SampleID); } }
public Acount DangNhap(string Email, string MatKhau) { int cnt = dataContext.TAIKHOANs.Where(p => p.EMAIL == Email && p.MATKHAU == MatKhau).ToList().Count; if (cnt == 0) { return(null); } TAIKHOAN tk = dataContext.TAIKHOANs.Where(p => p.EMAIL == Email && p.MATKHAU == MatKhau).FirstOrDefault(); Acount ac = new Acount(); ac.ID = tk.ID; ac.Name = tk.TEN; ac.Email = tk.EMAIL; if (tk.QUYEN == 1) { ac.Role = "Admin"; } else { ac.Role = "User"; } return(ac); }
/// <summary> /// Create an normal state /// </summary> /// <param name="balance">initial balance</param> /// <param name="acount">initial acount</param> public NormalMember(double balance, Acount acount) { this.Balance = balance; this.Acount = acount; this.UpperLimit = 300_000; this.LowerLimit = 0; this.Membership = Membership.NORMAL; }
/// <summary> /// Create an gold state /// </summary> /// <param name="balance">initial balance</param> /// <param name="acount">initial acount</param> public GoldMember(double balance, Acount acount) { this.Balance = balance; this.Acount = acount; this.LowerLimit = 500_000; this.UpperLimit = double.MaxValue; this.Membership = Membership.GOLD; }
/// <summary> /// Create an silver state /// </summary> /// <param name="balance">initial balance</param> /// <param name="acount">initial acount</param> public SilverMember(double balance, Acount acount) { this.Balance = balance; this.Acount = acount; this.LowerLimit = 300_000; this.UpperLimit = 500_000; this.Membership = Membership.SILVER; }
public async Task <int> createEntAcount(EntRegisterInfo entRegisterInfo) { var user = new UserRequest() { Username = entRegisterInfo.Username, Password = entRegisterInfo.Password }; var acount = await _acountService.get(user); if (acount != null) { return(0); } else { //var newacc = await _acountService.create(entRegisterInfo.Username, entRegisterInfo.Password, "ROLE_ENTERPRISE"); var newacc = new Acount() { Username = entRegisterInfo.Username, Password = entRegisterInfo.Password, ObjectRole = "ROLE_ENTERPRISE" }; _dbContext.Acounts.Add(newacc); var ent = new Enterprise() { Name = entRegisterInfo.Name, Email = entRegisterInfo.Email, Phone = entRegisterInfo.Phone, Skype = entRegisterInfo.Skype, Position = entRegisterInfo.Position }; if (entRegisterInfo.Gender == "male") { ent.Gender = true; } else { ent.Gender = false; } _dbContext.Enterprises.Add(ent); ent.Acount = newacc; var entInfo = new EnterpriseInfo() { Company_Name = entRegisterInfo.Company_name, Tax_Code = entRegisterInfo.Tax_code, Area = entRegisterInfo.Area, Phone = entRegisterInfo.Company_phone, Email = entRegisterInfo.Company_Email, Website = entRegisterInfo.Website, Scale = entRegisterInfo.Scale }; _dbContext.EnterpriseInfos.Add(entInfo); entInfo.Enterprise = ent; return(await _dbContext.SaveChangesAsync()); } }
public async Task <int> create(string username, string password, string objectRole) { Acount acount = new Acount() { Username = username, Password = password, ObjectRole = objectRole }; _dbContext.Acounts.Add(acount); return(await _dbContext.SaveChangesAsync()); }
public JsonResult ThanhToan(string SDT, string diachi, string yeucau) { Acount acount = (Acount)Session["Login"]; DONHANG a = new DONHANG(); a.MA = 0; a.DIACHI = diachi; a.YEUCAUGIAOHANG = yeucau; a.SDT = SDT; a.TAIKHOANID = acount.ID; a.TRANGTHAI = 0; // Đang giao hàng Shop_MVC_Context db = new Shop_MVC_Context(); db.DONHANGs.Add(a); try { db.SaveChanges(); Cart cart = (Cart)Session["Cart"]; string err = ""; a.TONGTIEN = 0; foreach (CHITIETDONHANG item in cart.ListItem) { item.DONHANGID = a.ID; a.TONGTIEN += new MatHangService().Find((int)item.MATHANGID, ref err).GIA *item.SOLUONG; db.CHITIETDONHANGs.Add(item); } a.TONGTIEN += a.TONGTIEN / 10; /// VAT db.SaveChanges(); cart.ListItem.Clear(); } catch (Exception ex) { return(Json(new { ok = false, exception = ex.Message })); } return(Json(new { ok = true, exception = "" } )); }
private void accessPassCopy_TextChanged(object sender, EventArgs e) { if (accessPassCopy.Text == accessPass.Text && loginTB.Text != "") { menu.Show(); string password = Encrypt(accessPass.Text, loginTB.Text); string login = Encrypt(loginTB.Text, password); Acount acc = new Acount("", "", login, password); File.WriteAllText("login.json", JsonConvert.SerializeObject(acc)); File.WriteAllText("accounts.json", ""); pass = accessPass.Text; FillBasicForm(); } }
static void Main(string[] args) { var titular = new Titular("alex", "Green"); //Titular titular = new Titular("Alex", "Green"); if (titular.Notifications.Count > 0) { foreach (Notification n in titular.Notifications) { Console.WriteLine(n.Message); } } Console.WriteLine("Saldo inicial ?"); //string saldoIni = Console.ReadLine(); string saldoIni = "s"; Acount acount; if (saldoIni.Substring(0, 1) == "s") { acount = new Acount("8532", TipoConta.Corrente, titular, 500.00); } else { acount = new Acount("8532", TipoConta.Corrente, titular); } Console.WriteLine($"Conta criada com saldo inicial = {acount.Balance}"); acount.depositar(200); Console.WriteLine($"Saldo = {acount.Balance}"); var sucesso = acount.sacar(300); if (sucesso == false) { var t = acount.Notifications.Count; foreach (Notification n in acount.Notifications) { Console.WriteLine(n.Message); } } else { Console.WriteLine($"Saldo = {acount.Balance}"); Console.WriteLine($"limite = {acount.Limite}"); } Console.ReadKey(); }
private void Btn_register_Click(object sender, EventArgs e) { if (CheckData()) { Acount data = new Acount(); data.uid = 1; data.FName = txt_First.Text; data.LName = txt_Last.Text; data.Email = txt_email.Text; data.Password = txt_Pass.Text; data.AddUser(); // var intent = new Intent(this, typeof(MainActivity)); // StartActivity(intent); } }
public void OnEnable() { foreach (Transform child in pivot.transform) { GameObject.Destroy(child.gameObject); } var data = DataManager.LoadData <Data>(); if (data == null) { Debug.Log("no hay data guardada: inicia el juego desde la Scena correspondiente 1 vez para generarlo. :D"); return; } var acount = data.GetAcount(Globals.playerName); #if UNITY_EDITOR if (acount == null) { acount = new Acount(Globals.playerName, Globals.playerName); } #endif foreach (var item in acount.player.items) { foreach (var rawItem in items) { if (item.name.Equals(rawItem.itemName) || item.name.Equals(rawItem.name)) { var newSlot = Instantiate(slot_Pref, pivot); newSlot.SetName(item.name); newSlot.Description = rawItem.description; newSlot.Image = (rawItem.sprite); newSlot.Amount = item.amount.ToString(); break; } } } }
private void btnChangePass_Click(object sender, EventArgs e) { List <TextBox> tbs = this.Controls.OfType <TextBox>().ToList(); if (tbs[0].Text == tbs[1].Text) { Acount acc = JsonConvert.DeserializeObject <Acount>(File.ReadAllText("login.json")); string login = Decrypt(acc.Login, acc.Password); string password = Decrypt(acc.Password, login); acc.Password = Encrypt(tbs[0].Text, login); acc.Login = Encrypt(login, acc.Password); File.WriteAllText("login.json", JsonConvert.SerializeObject(acc)); RewriteAccs(tbs[0].Text); pass = tbs[0].Text; MessageBox.Show("Пароль изменен!"); } else { MessageBox.Show("Введеные пароли не совпадают!"); } }
public void OnEnable() { foreach (Transform child in pivot.transform) { GameObject.Destroy(child.gameObject); } var data = DataManager.LoadData <Data>(); if (data == null) { Debug.Log("no hay data guardada: inicia el juego desde la Scena correspondiente 1 vez para generarlo. :D"); return; } var acount = data.GetAcount(Globals.playerName); #if UNITY_EDITOR if (acount == null) { acount = new Acount(Globals.playerName, Globals.playerName); } #endif foreach (var slime in acount.player.slimes) { foreach (var rawSlimes in slimes) { if (slime.mainType.Equals(rawSlimes.type.ToString())) { var newSlot = Instantiate(slot_Pref, pivot); newSlot.TextName = (slime.name); newSlot.TextWeigth = Math.Round(slime.weight, 2) + " Kg"; newSlot.Image = rawSlimes.InventoryImage; newSlot.BarAmount = slime.life / (slime.maxLife * 1f); break; } } } }
private void login(object sender, KeyPressEventArgs e) { var data = new Acount(); data.Username = txtUser.Text; data.Password = txtPass.Text; if (isValidated()) { if (data.checkAcount()) { if (data.Username == "azizfina") { new ShowDataMember("Admin").Show(); this.Close(); } } else { MessageBox.Show(data.checkAcount().ToString(), "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUser.Focus(); } } }
private void BtSignUp_Click(object sender, EventArgs e) { if (testAcountData() == "") { Acount acount = new Acount(); acount.Id = RandomIdDAO.Instance.randomID("ACOUNT"); acount.Name = tbName.Text; DateTime date = dtpDate.Value; acount.DateOfBirt = date.ToString("yyyyMMdd"); if (rbNam.Checked) { acount.Sex = 1; } else { acount.Sex = 0; } acount.Telephone = tbtelephone.Text; acount.Email = tbEmail.Text; acount.TypeWord = cbType.Text; acount.UserName = tbUserName.Text; acount.PassWord = tbPassWord.Text; acount.Pay = double.Parse(tbPay.Text); addAcountDataProvider.Instance.testAcountData(acount); MessageBox.Show("Đăng ký thành công!", "Thông Báo"); this.Hide(); } else { MessageBox.Show(testAcountData(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private static Logger logger = new Logger(typeof(UserManager)); //Logger.CreateLogger(typeof(UserManager)); /// <summary> /// 用户登录验证 /// </summary> /// <param name="name"></param> /// <param name="password"></param> /// <param name="verifyCode"></param> /// <returns></returns> public static LoginResult Login(this HttpContextBase context, string name, string password, string verifyCode) { if (context.Session["CheckCode"] != null && !string.IsNullOrWhiteSpace(context.Session["CheckCode"].ToString()) && context.Session["CheckCode"].ToString().Equals(verifyCode, StringComparison.CurrentCultureIgnoreCase)) { using (IAcountService servcie = DIFactory.GetContainer().Resolve <IAcountService>()) { Acount user = servcie.Set <Acount>().FirstOrDefault(u => u.name.Equals(name) || u.account.Equals(name));//账号查找 if (user == null) { return(LoginResult.NoUser); } //else if (!user.password.Equals(MD5Encrypt.Encrypt(password))) else if (!user.password.Equals(password)) { return(LoginResult.WrongPwd); } //else if (user.State == 1) //{ // return LoginResult.Frozen; //} else { //登录成功 写cookie session CurrentLoginUser currentUser = new CurrentLoginUser() { Id = user.id, Name = user.name, Account = user.account, Email = user.email, Password = user.password, LoginTime = DateTime.Now }; //都是asp.net解析的 #region Request //context.Request.Headers["User-Agent"]; //context.Request["Refer"]; //context.Request //Request 获取请求个各种参数, //Header里面的各种信息 //InputStream上传的文件 #endregion #region Response //context.Response //Response响应的 跨域、压缩、缓存、cookie、output + contentType #endregion #region Application context.Application.Lock(); //ASP.NET 应用程序内的多个会话和请求之间共享信息 context.Application.Lock(); //操作之前加锁 context.Application.Add("try", "die"); context.Application.UnLock(); object aValue = context.Application.Get("try"); aValue = context.Application["try"]; context.Application.Remove("命名对象"); context.Application.RemoveAt(0); context.Application.RemoveAll(); context.Application.Clear(); #endregion #region Items context.Items["123"] = "123";//单一会话,不同环境都可以用,比如在httpmodule获取到的信息,想传递给action;随着context释放 #endregion #region Server //辅助类 Server string encode = context.Server.HtmlEncode("<我爱我家>"); string decode = context.Server.HtmlDecode(encode); string physicalPath = context.Server.MapPath("/Home/Index");//只能做物理文件的映射 string encodeUrl = context.Server.UrlEncode("<我爱我家>"); string decodeUrl = context.Server.UrlDecode(encodeUrl); #endregion #region Cookie //context.Request.Cookies //HttpCookie cookie = context.Request.Cookies.Get("CurrentUser"); //if (cookie == null) //{ HttpCookie myCookie = new HttpCookie("CurrentUser"); myCookie.Value = JsonHelper.ObjectToString <CurrentLoginUser>(currentUser); myCookie.Expires = DateTime.Now.AddMinutes(5);//保存到硬盘 //5分钟后 硬盘cookie //不设置就是内存cookie--关闭浏览器就丢失 //改成过期 -1 过期 //修改cookie:不能修改,只能起个同名的cookie //myCookie.Domain//设置cookie共享域名 //myCookie.Path//指定路径能享有cookie context.Response.Cookies.Add(myCookie);//一定要输出 //} //前端只能获取name-value #endregion Cookie #region Session //context.Session.RemoveAll(); var sessionUser = context.Session["CurrentUser"]; context.Session["CurrentUser"] = currentUser; context.Session.Timeout = 3;//minute session过期等于Abandon #endregion Session logger.Debug(string.Format("用户id={0} Name={1}登录系统", currentUser.Id, currentUser.Name)); return(LoginResult.Success); } } } else { return(LoginResult.WrongVerify); } }
private void login_Click(object sender, EventArgs e) { #region 单选框 //if (Teacher.Checked) //{ // if (Acount.Text.Length <= 0 || Password.Text.Length <= 0) // { // MessageBox.Show("账号或者密码不能为空"); // } // if (Acount.Text == "Teacher" && Password.Text == "Teacher") // { // MessageBox.Show("老师登录成功"); // } // else // { // MessageBox.Show("你的账号或者密码出错"); // Acount.Clear();//清空输入的账号 // Password.Clear();//清空输入的密码 // Acount.Focus(); //获取焦点 // } //} //else //{ // if (Acount.Text.Length <= 0 || Password.Text.Length <= 0) // { // MessageBox.Show("账号或者密码不能为空"); // } // if (Acount.Text == "Student" && Password.Text == "Student") // { // MessageBox.Show("学生登录成功"); // } // else // { // MessageBox.Show("你的账号或者密码出错"); // Acount.Clear();//清空输入的账号 // Password.Clear();//清空输入的密码 // Acount.Focus(); //获取焦点 // } //} #endregion #region 多选框 if (ckTeacher.Checked) { if (Acount.Text.Length <= 0 || Password.Text.Length <= 0) { MessageBox.Show("账号或者密码不能为空"); } if (Acount.Text == "Teacher" && Password.Text == "Teacher") { MessageBox.Show("老师登录成功"); } else { MessageBox.Show("你的账号或者密码出错"); Acount.Clear(); //清空输入的账号 Password.Clear(); //清空输入的密码 Acount.Focus(); //获取焦点 } } else { if (Acount.Text.Length <= 0 || Password.Text.Length <= 0) { MessageBox.Show("账号或者密码不能为空"); } if (Acount.Text == "Student" && Password.Text == "Student") { MessageBox.Show("学生登录成功"); } else { MessageBox.Show("你的账号或者密码出错"); Acount.Clear(); //清空输入的账号 Password.Clear(); //清空输入的密码 Acount.Focus(); //获取焦点 } } #endregion }
private void tàiKhoảnToolStripMenuItem_Click(object sender, EventArgs e) { Acount acc = new Acount(); acc.Show(); }
private void userkeyDown(object sender, KeyEventArgs e) { var data = new Acount(); data.Username = txtUser.Text; data.Password = txtPass.Text; if (sender.Equals(txtUser)) { if (e.KeyCode == Keys.Enter) { txtPass.Focus(); } } else if (sender.Equals(txtPass)) { if (e.KeyCode == Keys.Enter) { string restriction; if (isValidated()) { if (data.checkAcount()) { if (data.Username == "azizfina" || data.Username == "saaaaaar") { restriction = "admin"; new ShowDataMember(restriction).Show(); this.Close(); } } else { MessageBox.Show("UserName or Password is Wrong!", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUser.Focus(); } } } else if (e.KeyCode == Keys.Escape) { txtUser.Focus(); } } else if (sender.Equals(btnLogin)) { if (e.KeyCode == Keys.Enter) { if (isValidated()) { if (data.checkAcount()) { if (data.Username == "azizfina") { new ShowDataMember("Admin").Show(); this.Close(); } } else { MessageBox.Show("UserName or Password is Wrong!", "warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUser.Focus(); } } } } }