public bool Login(string userName, string passWord) { ACCOUNT obj = new ACCOUNT(userName, passWord); context.setState(new LoginState()); return(context.doAction(obj)); }
public IHttpActionResult PutACCOUNT(string id, ACCOUNT aCCOUNT) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != aCCOUNT.ACCOUNTID) { return(BadRequest()); } db.Entry(aCCOUNT).State = EntityState.Modified; db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ACCOUNTExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ACCOUNT getAccountByUserName(string userName) { ACCOUNT _accObj = new ACCOUNT(); string _connectionString = DataSource.getConnectionString("swagbaseCoolString"); SqlConnection con = new SqlConnection(_connectionString); SqlCommand cmd = new SqlCommand("SELECT * FROM ACCOUNT WHERE Username = '******';", con); try { con.Open(); SqlDataReader dar = cmd.ExecuteReader(); if (dar.Read()) { _accObj.Username = dar["Username"] as string; _accObj.Password = dar["Password"] as string; _accObj.Rank = Convert.ToInt32(dar["Rank"]); } } catch (Exception aObj) { throw aObj; } finally { if (con != null) { con.Close(); } } return(_accObj); }
public bool Insert_Teacher(TEACHER tc) { var tmp = Exist_Teacher(tc.Email); if (tmp == -1) { db.TEACHERs.Add(tc); db.SaveChanges(); var bien_tmp = Exist_Teacher(tc.Email); if (bien_tmp != -1) { ACCOUNT tk = new ACCOUNT(); tk.IDTeacher = bien_tmp; tk.Username = tc.Email; tk.Password = Encryptor.MD5Hash(tc.Email); tk.Status = 1; db.ACCOUNTs.Add(tk); db.SaveChanges(); return(true); } else { return(false); } } else { return(false); } }
public bool editac(ACCOUNT kh) { bool chek = false; using (ContextEntites context = new ContextEntites()) { try { var s = context.ACCOUNTs.Single(x => x.ID == kh.ID); s.ID = kh.ID; s.PASS = kh.PASS; s.USERNAME = kh.USERNAME; if (context.SaveChanges() >= 0) { chek = true; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } return(chek); //change }
/// <summary> /// посчитать профит по открытым позам в валюте депозита /// </summary> private float CalculateAccountOpenProfit(TradeSharpConnection ctx, ACCOUNT account, Dictionary <string, CandleData> candles) { var profitOpen = 0f; foreach (var pos in ctx.POSITION.Where(p => p.AccountID == account.ID)) { // найти последнюю котировку CandleData candle; if (!candles.TryGetValue(pos.Symbol, out candle)) { Errors.Add("CalculateAccountOpenProfit - " + Resource.ErrorMessageNoExitPriceFor + " " + pos.Symbol); continue; } // получить профит по позиции var priceExit = pos.Side > 0 ? candle.close : DalSpot.Instance.GetAskPriceWithDefaultSpread(pos.Symbol, candle.close); var profitCounter = pos.Volume * pos.Side * (priceExit - (float)pos.PriceEnter); // перевести профит в валюту депо if (!ConvertBaseOrCounterDepo(false, pos.Symbol, account.Currency, candles, ref profitCounter)) { continue; } profitOpen += profitCounter; } return(profitOpen); }
public UserInfor(ACCOUNT acc) { _acc = acc; InitializeComponent(); this.Title += " [" + _acc.USERNAME + "]"; LoadData(); }
public ActionResult Login(ACCOUNT _account) { //if (!ModelState.IsValid) //{ //var f_password = GetMD5(_account.ACCOUNT_PASSWORD); //var check = db.ACCOUNTs.Where(s => s.EMAIL == _account.EMAIL && s.ACCOUNT_PASSWORD == f_password).FirstOrDefault(); var check = db.ACCOUNTs.Where(s => s.EMAIL == _account.EMAIL && s.ACCOUNT_PASSWORD == _account.ACCOUNT_PASSWORD).FirstOrDefault(); if (check != null) { if (check.ROLE.ROLE_NAME == "Admin") { return(RedirectToRoute(new { area = "Admin", controller = "ManageAccount", action = "ListAccount" })); } db.Configuration.ValidateOnSaveEnabled = false; //add session Session["FULLNAME"] = _account.ACCOUNT_FIRSTNAME + " " + _account.ACCOUNT_LASTNAME; Session["EMAIL"] = _account.EMAIL; Session["ACCOUNT_ID"] = _account.ACCOUNT_ID; // Lấy dữ liệu Account ACCOUNT accProfile = db.ACCOUNTs.FirstOrDefault(s => s.EMAIL == _account.EMAIL); Session["ACCOUNT"] = accProfile; return(RedirectToAction("Index", "Home")); } else { ViewBag.error = "Your email or password is not correct!"; return(View(_account)); } //} //return View(_account); }
public IHttpActionResult PostACCOUNT(ACCOUNT aCCOUNT) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ACCOUNTs.Add(aCCOUNT); try { db.SaveChanges(); } catch (DbUpdateException) { if (ACCOUNTExists(aCCOUNT.ACCOUNTID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = aCCOUNT.ACCOUNTID }, aCCOUNT)); }
private void bntChange_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtOldPassword.Text) || String.IsNullOrEmpty(txtNewPassword.Text) || String.IsNullOrEmpty(txtComfirm.Text)) { MessageBox.Show("Không được bỏ trống", "Thông báo"); } else if (txtOldPassword.Text.ToString() == txtNewPassword.Text.ToString()) { MessageBox.Show("Mật khẩu mới không được giống mật khẩu cũ", "Thông báo"); } else if (txtNewPassword.Text.ToString() != txtComfirm.Text.ToString()) { MessageBox.Show("Xác nhận không chính xác", "Thông báo"); } else { AccountController accountController = new AccountController(); ACCOUNT acc = new ACCOUNT(); acc.USERNAME = _Username; acc.PASSWORD = _Password; if (accountController.CheckPassword(acc, txtOldPassword.Text.ToString(), txtNewPassword.Text.ToString()) == 0) { MessageBox.Show("Mật khẩu cũ sai", "Thông báo"); } else { MessageBox.Show("Đổi mật khẩu thành công", "Thông báo"); } } }
public static void ResetPass(string userName, string newPass) { ACCOUNT obj = reps.GetByID(userName); obj.PASSWORD = newPass; reps.Update(obj); }
private void submit_Click(object sender, EventArgs e) { decimal amount; bool success = Decimal.TryParse(amount_pay.Text, out amount); if (success && amount > 0) { number.Text = ""; using (DataClasses1DataContext context = new DataClasses1DataContext()) { ACCOUNT user = context.ACCOUNTs.First(i => i.id == Home.UserID); user.balance -= amount; PAYMENT payment = new PAYMENT(); payment.amount = amount; payment.date = DateTime.Now; payment.account_id = user.id; context.PAYMENTs.InsertOnSubmit(payment); context.SubmitChanges(); } this.Close(); } }
public ActionResult Avatar(string ACCOUNT_Username, HttpPostedFileBase ACCOUNT_Avatar) { if (ModelState.IsValid) { ACCOUNT aCCOUNT = new ACCOUNT(); aCCOUNT.ACCOUNT_Username = ACCOUNT_Username; var dao = new LoginDAO().GetByUsername(ACCOUNT_Username); if (ACCOUNT_Avatar != null) { string fileName = new ArticleDAO().GetCode(dao.ACCOUNT_Name); string extension = Path.GetExtension(ACCOUNT_Avatar.FileName); fileName += extension; string Url = "/Content/dist/img/" + dao.ACCOUNT_Id + "/Avatar/" + fileName; fileName = Path.Combine(Server.MapPath("~/Content/dist/img/" + dao.ACCOUNT_Id + "/Avatar/"), fileName); if (!Directory.Exists(Server.MapPath("~/Content/dist/img/" + dao.ACCOUNT_Id + "/Avatar/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/dist/img/" + dao.ACCOUNT_Id + "/Avatar/")); } ACCOUNT_Avatar.SaveAs(fileName); aCCOUNT.ACCOUNT_Avatar = Url; if (new LoginDAO().Avatar(aCCOUNT)) { SetAlert("Profile has been changed successfully!", "success"); } } else { SetAlert("Profile change failed, please try again!", "warning"); } } return(RedirectToAction("Index")); }
public AssetsSaveData AddAssetsData(int accountId) { int existIndex = -1; for (int i = 0; i < assetsDataList.Count; i++) { if (assetsDataList[i].accountId == accountId) { existIndex = i; } } if (existIndex >= 0) { return(assetsDataList[existIndex]); } AssetsSaveData data = new AssetsSaveData(); data.transactionList = new List <TransactionSaveData>(); ACCOUNT staticData = StaticDataAccount.GetAccountById(accountId); if (staticData != null) { data.balance = staticData.money; } data.accountId = accountId; assetsDataList.Add(data); return(data); }
public AccountPresenter() { model = new AccountModel(); isUpdated = false; empList = new List <EMPLOYEE>(); acc = new ACCOUNT(); }
private void MakePayment_Load(object sender, EventArgs e) { using (DataClasses1DataContext context = new DataClasses1DataContext()) { ACCOUNT a = context.ACCOUNTs.First(i => i.id == Home.UserID); balance.Text = "$" + a.balance; } }
public wManager(ACCOUNT acc) { InitializeComponent(); this.AccountLogin = acc; LoadTable(); }
public FAccount(ACCOUNT ac) { a = ac; InitializeComponent(); txtmkcu.Enabled = false; txtmkmoi1.Enabled = false; txtmkm2.Enabled = false; }
public static bool Account(ref ACCOUNT account, string username, string password, string name, string address, string tel,string socialId, string email, int question, string answer) { bool flag = true; try { account.Username = username; account.Password = password; account.Name = name; account.Address = address; account.Tel = tel; account.SocialID = socialId; account.Email = email; account.Question = question; account.Answer = answer; } catch (Exception) { flag = false; throw; } return flag; }
public static bool Insert(String username, String password,String fullName, String address, String tel, String socialId, String email, int question, String answer, int idCity, int idDistrict) { //Khởi tạo một đối tượng ACCOUNT _db = new FoodStoreEntities(); try { ACCOUNT check = _db.ACCOUNTs.Single(p => p.Username == username); } catch (Exception) { var account = new ACCOUNT(); account.ID = GetMaxId(); account.Username = username; account.Password = SaltEncrypt.HashCodeSHA1(password); account.Name = fullName; account.Address = address; account.Tel = tel; account.SocialID = socialId; account.Email = email; account.QUESTION = QuestionController.GetById(question, _db); account.Answer = answer; account.CITY = CityController.GetById(idCity, _db); account.DISTRICT = DistrictController.GetById(idDistrict, _db); //Chèn đối tượng ACCOUNT vào CSDL bool flag = true; try { _db.AddToACCOUNTs(account); _db.SaveChanges(); } catch (Exception) { flag = false; throw; } return flag; } return false; }
private ObservableCollection<Account> GetAccountMapping(string account, ACCOUNT identifier) { lstAccount = new ObservableCollection<Account>(); using (SybaseConnection con = new SybaseConnection(model.Constants.SybaseConnection)) { using (SybaseCommand com = new SybaseCommand(model.Constants.SelectPortiaAccountMapping, con) { CommandType = CommandType.Text }) { if (identifier == ACCOUNT.PORTIA) { com.CommandText = model.Constants.SelectPortiaAccountMapping; SybaseParameter oCom = new SybaseParameter("@portiaAccountNumber", SybaseDbType.VarChar); oCom.Value = account; com.Parameters.Add(oCom); } if (identifier == ACCOUNT.DTC) { com.CommandText = model.Constants.SelectDtcAccountMapping; SybaseParameter oCom = new SybaseParameter("@dtcAccountNumber", SybaseDbType.VarChar); oCom.Value = account; com.Parameters.Add(oCom); } con.Open(); try { using (SybaseDataReader reader = com.ExecuteReader()) { while (reader.Read()) { lstAccount.Add(new Account(Convert.ToInt32(reader["id"].ToString()), reader["portiaAccountNumber"].ToString(), reader["dtcAccountNumber"].ToString(), Convert.ToDateTime(reader["modifiedDate"].ToString()), reader["modifiedBy"].ToString() )); } } } catch (Exception ex) { } } } return lstAccount; }