/// <summary> /// Gets the list of data for use by the jqgrid plug-in /// </summary> public IActionResult OnGetGridData(string sidx, string sord, int _page, int rows, bool isforJqGrid = true) { int totalRecords = LoginTable.GetRecordCount(); int startRowIndex = ((_page * rows) - rows); List <LoginTable> objLoginTableCol = LoginTable.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); if (objLoginTableCol is null) { return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }")); } var jsonData = new { total = totalPages, _page, records = totalRecords, rows = ( from objLoginTable in objLoginTableCol select new { id = objLoginTable.Adminid, cell = new string[] { objLoginTable.Adminid.ToString(), objLoginTable.Password } }).ToArray() }; return(new JsonResult(jsonData)); }
/// <summary> /// Used when adding or updating a record. /// </summary> internal static void AddOrEdit(LoginTable model, CrudOperation operation, bool isForListInline = false) { LoginTable objLoginTable; LoginTable objLoginTableOld = new LoginTable(); decimal id = 0; if (operation == CrudOperation.Add) { objLoginTable = new LoginTable(); } else { objLoginTable = LoginTable.SelectByPrimaryKey(model.Adminid); objLoginTableOld = objLoginTable.ShallowCopy(); } objLoginTable.Adminid = model.Adminid; objLoginTable.Password = model.Password; if (operation == CrudOperation.Add) { id = objLoginTable.Insert(); } else { objLoginTable.Update(); } }
public ActionResult Slet(int?id) { //slår en bruger op på ID LoginTable bruger = db.LoginTable.Find(id); return(View(bruger)); }
public ActionResult Ret(int?id) { //slår en bruger op baseret på det ID der søges LoginTable bruger = db.LoginTable.Find(id); return(View(bruger)); }
public async Task RegisterCommandHandler() { try { if (Password == ConfirmPassword) { string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); var db = new SQLiteConnection(dpPath); db.CreateTable <LoginTable>(); LoginTable tbl = new LoginTable(); tbl.username = Username; tbl.password = Password; tbl.email = Email; db.Insert(tbl); await CoreMethods.DisplayAlert("Registration", "Username sucessfully created", "OK"); await CoreMethods.PushPageModel <HomePageModel>(); } else { await CoreMethods.DisplayAlert("Registration", "Entered Password does not match", "Try again"); } } catch (Exception ex) { await CoreMethods.DisplayAlert("Registration", ex.ToString(), "OK"); } }
public ActionResult AddInfo(LoginTable login) { db.LoginTable.Add(login); int i = db.SaveChanges(); return(i > 0 ? Content("true") : Content("false")); }
public void GetData(string sidx, string sord, int?_page) { int rows = Functions.GetGridNumberOfRows(); int numberOfPagesToShow = Functions.GetGridNumberOfPagesToShow(); int currentPage = _page is null ? 1 : Convert.ToInt32(_page); int startRowIndex = ((currentPage * rows) - rows); int totalRecords = LoginTable.GetRecordCount(); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); List <LoginTable> objLoginTableCol = LoginTable.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord); // fields and titles string[,] fieldNames = new string[, ] { { "Adminid", "Adminid" }, { "Password", "Password" } }; // assign properties LoginTableData = objLoginTableCol; LoginTableFieldNames = fieldNames; TotalPages = totalPages; CurrentPage = currentPage; FieldToSort = String.IsNullOrEmpty(sidx) ? "Adminid" : sidx; FieldSortOrder = String.IsNullOrEmpty(sord) ? "asc" : sord; FieldToSortWithOrder = String.IsNullOrEmpty(sidx) ? "Adminid" : (sidx + " " + sord).Trim(); NumberOfPagesToShow = numberOfPagesToShow; StartPage = Functions.GetPagerStartPage(currentPage, numberOfPagesToShow, totalPages); EndPage = Functions.GetPagerEndPage(StartPage, currentPage, numberOfPagesToShow, totalPages); }
/// <summary> /// Handler, updates a record. /// </summary> public IActionResult OnGetUpdate(string serializedData) { LoginTable objLoginTable = JsonConvert.DeserializeObject <LoginTable>(serializedData); LoginTableFunctions.AddOrEdit(objLoginTable, CrudOperation.Update, true); return(new JsonResult(true)); }
public void Registreerimine(string Login, string Password) { using (LoginDbContext _context = new LoginDbContext()) { LoginTable loginTable = new LoginTable() { Name = Login }; if (!string.IsNullOrEmpty(Login) || !string.IsNullOrEmpty(Password)) { string _salt = CreateSalt(10); loginTable.Salt = _salt; loginTable.Hash = GenerateSHA256Hash(Password, _salt); try { _context.LoginTable.Add(loginTable); _context.SaveChanges(); _service.MessageInfo("Registreeritud", "Info"); } catch (Exception ex) { _service.MessageError(ex.Message, "Viga"); } } else { _service.MessageExclamation("Sisestage andmed!", "Sõnum"); } } }
private void Button_Click(object sender, RoutedEventArgs e) { ObservableCollection <LoginTable> db = new ObservableCollection <LoginTable>(); ReadAllLoginItem dbLogin = new ReadAllLoginItem(); //db = dbLogin.GetAllLoginItems();//Get all DB Login string user = txtUsername.Text.Trim(); string pass = passwordBx.Password.Trim(); LoginTable loginObj = new LoginTable(); loginObj = dbLogin.GetExistUserLogin(user, pass); bool isLoginSuccess = this.validateLoginUser(user, pass); if (isLoginSuccess) { NavigationService.Navigate(new Uri("/Views/ReadContactList.xaml", UriKind.Relative)); } /*if (loginObj != null) * { * NavigationService.Navigate(new Uri("/Views/ReadContactList.xaml", UriKind.Relative)); * } * else * { * MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu"); * }*/ }
private void BtnCreateAcc_Click(object sender, System.EventArgs e) { try { string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); var db = new SQLiteConnection(dpPath); db.CreateTable <LoginTable>(); LoginTable tbl = new LoginTable(); tbl.email = txtEmail.Text; tbl.username = txtUsername.Text; tbl.password = txtPassword.Text; if (txtPassword.Text == txtConfirmPassword.Text) { db.Insert(tbl); Toast.MakeText(this, "Record Added Successfully...,", ToastLength.Short).Show(); Intent nextActivity = new Intent(this, typeof(HomeActivity)); StartActivity(nextActivity); } else { Toast.MakeText(this, "Passwords do not match", ToastLength.Short).Show(); } } catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show(); } }
public ActionResult UpdateById(LoginTable login) { login = db.LoginTable.FirstOrDefault(o => o.LoginId == login.LoginId); UpdateModel(login); db.SaveChanges(); return(Content("true")); }
private LoginTable CreatePatchModel(LoginTable partialModel, LoginTable modelToBeUpdate) { modelToBeUpdate.EmailId = partialModel.EmailId ?? modelToBeUpdate.EmailId; modelToBeUpdate.Password = partialModel.Password ?? modelToBeUpdate.Password; modelToBeUpdate.IsLogIn = partialModel.IsLogIn ? modelToBeUpdate.IsLogIn : partialModel.IsLogIn; return(modelToBeUpdate); }
public UsersTable UseLogin(LoginTable login) { // String pass = "******"; //String email ="*****@*****.**"; SqlConn(); conn.Open(); Response response = new Response(); SqlCommand cmd = new SqlCommand("Select * From UsersTable Where Email=@UEmail And Password=@UPass ", conn); cmd.Parameters.AddWithValue("@UEmail", login.Email); cmd.Parameters.AddWithValue("@UPass", login.Password); SqlDataReader rdr = cmd.ExecuteReader(); UsersTable NewUser = new UsersTable(); if (rdr.Read()) { NewUser.Id = Convert.ToInt32(rdr["Id"]); NewUser.Name = rdr["Name"].ToString(); NewUser.Surname = rdr["Surname"].ToString(); NewUser.Address = rdr["Address"].ToString(); NewUser.Email = rdr["Email"].ToString(); NewUser.Mobile = rdr["Mobile"].ToString(); NewUser.Password = rdr["Password"].ToString(); return(NewUser); conn.Close(); } else { } conn.Close(); return(NewUser); }
/// <summary> /// Gets the list of data for use by the jqgrid plug-in /// </summary> public IActionResult OnGetGridDataWithFilters(string sidx, string sord, int _page, int rows, string filters) { int? adminid = null; string password = String.Empty; if (!String.IsNullOrEmpty(filters)) { // deserialize json and get values being searched var jsonResult = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(filters); foreach (var rule in jsonResult["rules"]) { if (rule["field"].Value.ToLower() == "adminid") { adminid = Convert.ToInt32(rule["data"].Value); } if (rule["field"].Value.ToLower() == "password") { password = rule["data"].Value; } } // sometimes jqgrid assigns a -1 to numeric fields when no value is assigned // instead of assigning a null, we'll correct this here if (adminid == -1) { adminid = null; } } int totalRecords = LoginTable.GetRecordCountDynamicWhere(adminid, password); int startRowIndex = ((_page * rows) - rows); List <LoginTable> objLoginTableCol = LoginTable.SelectSkipAndTakeDynamicWhere(adminid, password, rows, startRowIndex, sidx + " " + sord); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); if (objLoginTableCol is null) { return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }")); } var jsonData = new { total = totalPages, _page, records = totalRecords, rows = ( from objLoginTable in objLoginTableCol select new { id = objLoginTable.Adminid, cell = new string[] { objLoginTable.Adminid.ToString(), objLoginTable.Password } }).ToArray() }; return(new JsonResult(jsonData)); }
public async Task <IActionResult> PutLoginTable([FromRoute] int id, [FromBody] LoginTable loginTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != loginTable.Id) { return(BadRequest()); } _context.Entry(loginTable).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoginTableExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// The example below shows how to Select the Adminid and Password columns for use with a with a Drop Down List, Combo Box, Checked Box List, List View, List Box, etc /// </summary> private void SelectLoginTableDropDownListData() { List <LoginTable> objLoginTableCol = LoginTable.SelectLoginTableDropDownListData(); // Example 1: directly bind to a drop down list - for ASP.NET Web Forms // DropDownList ddl1 = new DropDownList(); // ddl1.DataValueField = "Adminid"; // ddl1.DataTextField = "Password"; // ddl1.DataSource = objLoginTableCol; // ddl1.DataBind(); // Example 2: add each item through a loop - for ASP.NET Web Forms // DropDownList ddl2 = new DropDownList(); // foreach (LoginTable objLoginTable in objLoginTableCol) // { // ddl2.Items.Add(new ListItem(objLoginTable.Password, objLoginTable.Adminid.ToString())); // } // Example 3: bind to a combo box. for Windows Forms (WinForms) // ComboBox cbx1 = new ComboBox(); // foreach (LoginTable objLoginTable in objLoginTableCol) // { // cbx1.Items.Add(new ListItem(objLoginTable.Password, objLoginTable.Adminid.ToString())); // } }
private void BtnFollow_Click(object sender, EventArgs e) { string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); var db = new SQLiteConnection(dpPath); db.CreateTable <Friendship>(); Friendship newFriendship = new Friendship(); newFriendship.friendFrom = currentUser.username; newFriendship.friendTo = selectedUser.username; newFriendship.friendSince = DateTime.Now; db.Insert(newFriendship); LoginTable tbl = currentUser; tbl.noOfFollowers++; db.Update(tbl); LoginTable sTbl = selectedUser; if (sTbl.noOfFollowing.Equals(null)) { sTbl.noOfFollowing = 1; } else { sTbl.noOfFollowing++; } db.Update(sTbl); Toast.MakeText(this, "Successfully Followed", ToastLength.Short).Show(); }
/// <summary> /// Handler, deletes a record. /// </summary> public IActionResult OnGetRemove(int id) { LoginTable LoginTable = LoginTable.SelectByPrimaryKey(id); LoginTable.Delete(id); return(new JsonResult(true)); }
/// <summary> /// Shows how to Select all records sorted by column name in either ascending or descending order. /// </summary> private void SelectAllWithSortExpression() { // select all records sorted by Adminid in ascending order string sortBy = "Adminid"; // ascending order //string sortBy = "Adminid desc"; // descending order List <LoginTable> objLoginTableCol = LoginTable.SelectAll(sortBy); }
public ActionResult Slet(int id) { LoginTable bruger = db.LoginTable.Find(id); db.LoginTable.Remove(bruger); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteById(int id) { LoginTable obj = db.LoginTable.FirstOrDefault(o => o.LoginId == id); db.LoginTable.Remove(obj); db.SaveChanges(); return(Content("true")); }
public ActionResult DeleteConfirmed(int id) { LoginTable logins = db.LoginTable.Find(id); db.LoginTable.Remove(logins); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Index(ASP_MVC_Skabelon.Models.LoginTable LogIndBruger) { //hvis modellen er udfyldt med fejl/mangler- send bruger tilbage til viwet ( her er samme side ) if (!ModelState.IsValid) { return(View(db.LoginTable.ToList())); } // Find ud af om der er match LoginTable BrugerMatch = new LoginTable(); //find brugeren baseret på brugernavn LoginTable BrugerNavnet = new LoginTable(); //Brugernavnet slåes op i tabellen BrugerNavnet = db.LoginTable.Where(b => b.username == LogIndBruger.username).FirstOrDefault(); //Hvis brugernavnet findes i tabellen if (BrugerNavnet != null) { // string passwordOgSalt = HashSalt.HashPassword(LogIndBruger.password, BrugerNavnet.salt); BrugerMatch = db.LoginTable.Where(b => b.username == LogIndBruger.username && b.password == passwordOgSalt).FirstOrDefault(); if (BrugerMatch != null) { // der blev fundet et match =login = session //der blev lavet en session - som er den vi "måler" på, om brugen skal have adgang til admin Session["BrugerSession"] = BrugerMatch.username; return(RedirectToAction("Index", "Admin")); // bruger sendes til startsiden på ADMIN } else { // brugermatch == null .....der var ikke noget match // her er mere sikerhed for logind da vi sletter sission hvis der noget forkert..... Session.Remove("BrugerSession"); ViewBag.Besked = "UPS! forkert brugernavn og/eller Password Prøv igen"; return(View(db.LoginTable.ToList())); // retun samme side med beskden. } } else { // brugermatch == null .....der var ikke noget match // her er mere sikerhed for logind da vi sletter sission hvis der noget forkert..... Session.Remove("BrugerSession"); ViewBag.Besked = "UPS! forkert brugernavn og/eller Password Prøv igen"; return(View(db.LoginTable.ToList())); // retun samme side med beskden. } }
public Response UseLogin(LoginTable login) { // String pass = "******"; // String email ="*****@*****.**"; /* SqlConn(); * conn.Open(); * Response response = new Response(); * SqlCommand cmd = new SqlCommand("Select Id From UsersTable Where Email=@UEmail And Password=@UPass", conn); * cmd.Parameters.AddWithValue("@UEmail", login.Email); * cmd.Parameters.AddWithValue("@UPass", login.Password); */ // SqlDataReader rdr = cmd.ExecuteReader(); // UsersTable NewUser = new UsersTable(); // if (rdr.Read()) //{ // rdr.Read(); // NewUser.Id = Convert.ToInt32(rdr["Id"]); // NewUser.Name = rdr["Name"].ToString(); // NewUser.Surname = rdr["Surname"].ToString(); // NewUser.Address = rdr["Address"].ToString(); // NewUser.Email = rdr["Email"].ToString();v // NewUser.Mobile = rdr["Mobile"].ToString(); // NewUser.Password = rdr["Password"].ToString(); // rdr.Close(); // return NewUser; // conn.Close(); // } Response response = new Response(); try { SqlConn(); conn.Open(); SqlCommand cmd = new SqlCommand("Select Id From UsersTable Where Email=@UEmail And Password=@UPass", conn); cmd.Parameters.AddWithValue("@UEmail", login.Email); cmd.Parameters.AddWithValue("@UPass", login.Password); SqlDataReader rdr = cmd.ExecuteReader(); rdr.Read(); response.Id = Convert.ToInt32(rdr["Id"]); rdr.Close(); conn.Close(); response.Message = "Başarıyla Giriş Yapıldı"; response.Status = 1; return(response); } catch (Exception ex) { response.Message = ex.Message; response.Status = 0; return(response); } }
public ActionResult Edit([Bind(Include = "Id,BrugerNavn,Kodeord")] LoginTable logins) { if (ModelState.IsValid) { db.Entry(logins).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(logins)); }
public IActionResult CadastroCliente([FromBody] CadastroCliente cadastroCliente) { var db = new AcademiaContext(); //Cria cliente ou atualiza se ja existir var cliente = db.ClienteTable.Where(c => c.cpf == cadastroCliente.Cpf).FirstOrDefault(); if (cliente == null) { cliente = new ClienteTable(cadastroCliente); db.ClienteTable.Add(cliente); } else { var clienteId = cliente.cliente_id; cliente.nome = cadastroCliente.Nome; cliente.cpf = cadastroCliente.Cpf; cliente.identidade = cadastroCliente.Identidade; cliente.data_nascimento = cadastroCliente.DataNascimento; cliente.cartao = cadastroCliente.Cartao; cliente.titular_cartao = cadastroCliente.TitularCartao; db.ClienteTable.Update(cliente); } db.SaveChanges(); cliente = db.ClienteTable.Where(c => c.cpf == cadastroCliente.Cpf).FirstOrDefault(); //cadastra login do cliente - ou atualiza se ja existir var login = db.LoginTable.Where(c => c.cliente_id == cliente.cliente_id).FirstOrDefault(); if (login == null) { login = new LoginTable(cadastroCliente, cliente.cliente_id); db.LoginTable.Add(login); } else { login.usuario = cadastroCliente.Usuario; login.senha = cadastroCliente.Senha; db.LoginTable.Update(login); } db.SaveChanges(); return(Ok()); }
public void LoadPage(int id, string returnUrl) { // select a record by primary key(s) StudentEnquiryAPI.BusinessObject.LoginTable objLoginTable = LoginTable.SelectByPrimaryKey(id); // assign values to this page's bound property LoginTable = objLoginTable; // assign the return url ReturnUrl = returnUrl; }
public LoginTable GetExistUser(string userName, string password) { LoginTable user = null; using (var dbConn = new SQLiteConnection(App.DB_PATH)) { var existingUser = dbConn.Query <LoginTable>("select * from LoginTable where username ='******' and password ='******'").FirstOrDefault(); user = (LoginTable)existingUser; } return(user); }
private void Login_Click(object sender, EventArgs e) { String connectionString = "mongodb://localhost"; MongoClient client = new MongoClient(connectionString); MongoServer server = client.GetServer(); MongoDatabase database = server.GetDatabase("Login-Details"); MongoCollection collection = database.GetCollection <LoginTable>("LoginTable"); LoginTable t = new LoginTable(); t.username = TextBox1.Text; t.password = TextBox2.Text; var query = Query.And( Query.EQ("username", t.username), Query.EQ("password", t.password) ); var result = collection.FindAs <LoginTable>(query).Count(); if (String.IsNullOrEmpty(TextBox1.Text) || String.IsNullOrEmpty(TextBox2.Text)) { MessageBox.Show("Fields cannot be blank"); } else { if (result > 0) { Transition t2 = new Transition(new TransitionType_Acceleration(1000)); t2.add(pictureBox2, "Left", 000); t2.add(pictureBox2, "Top", 550); t2.run(); if (TextBox1.Text == "Staff") { Form3 f3 = new Form3("Logged in as Staff"); Delayed(650, () => f3.Show()); } else { Form1 f1 = new Form1("Logged in as Manager"); Delayed(650, () => f1.Show()); } Delayed(650, () => this.Hide()); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; } else { MessageBox.Show("Invalid username or password"); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; this.WindowState = FormWindowState.Maximized; this.Show(); } } }