public ActionResult Login(userForReg newUser) { using (myDB db = new myDB()) { var loginSuccessful = false; try { ModelState.Clear(); var usr = db.userRegi.Single(u => u.UserName == newUser.UserName && u.Password == newUser.Password); if (usr != null) { Session["UserID"] = newUser.UserID.ToString(); Session["UserName"] = newUser.UserName.ToString(); //ViewBag.Message = Session["UserName"] + " successfully logged in"; loginSuccessful = true; ModelState.Clear(); return(RedirectToAction("LoggedIn")); } } catch (InvalidOperationException) { } if (!loginSuccessful) { ModelState.AddModelError("", "Incorrect Combination"); // } } return(View()); }
// Start is called before the first frame update void Start() { doneLoading = false; prevSize = GameObject.Find("Video Player").GetComponent <RectTransform>().rect.width; DontDestroyOnLoad(GameObject.Find("Audio")); if (!GameObject.Find("Audio").GetComponent <AudioSource>().isPlaying) { GameObject.Find("Audio").GetComponent <AudioSource>().Play(); } var loading = GameObject.Find("Loading"); isLoading = loading.GetComponent("LoadingIndicator") as LoadingIndicator; GameObject.Find("Video Player").GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0); GameObject.Find("Video Player").GetComponent <YoutubePlayer.YoutubePlayer>().YoutubeVideoStarting += Loaded; myDB db = GameObject.Find("Scripts").GetComponent <myDB>(); wordslist = db.WordLottery(); correctWord = wordslist[0]; PlayerPrefs.SetString("LastCorrect", correctWord); PlayerPrefs.Save(); Debug.Log("correctWord is: " + correctWord); //add correct word again for better chance at winning, and also 5 wrong duplicates to prevent cheesing wordslist.AddRange(wordslist.Take(6)); shuffleList(wordslist); TextObjInGame = wordslist.Count; }
// ************************************************************ // METHODS -- SELECT // ************************************************************ #region SELECT /// <summary> /// Select an entire table and returns a list of the (T) line objects. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="tableName"></param> /// <returns></returns> public List <T> SelectAll <T>(myDB table) { string SelectUndlDataEOD = "SELECT * from " + table.ToString(); using (var connection = new MySqlConnection(connectionString)) { var res = connection.Query <T>(SelectUndlDataEOD); return((List <T>)res); } }
public void EraseTable(myDB argTable) { // Get string with table name string table = argTable.ToString(); // Build mySQL Delete command string string mySQLDeleteCommand = "DELETE FROM " + table + ";"; // Execute the command using (var connection = new MySqlConnection(connectionString)) { connection.Execute(mySQLDeleteCommand); } }
/// <summary> /// Delete an entire line from a table. The keys to identify the line are passed in a DB line (subclass of GenericDatabaseLine). /// </summary> /// <param name="argTable"></param> /// <param name="myLine"></param> public void EraseColumn(myDB argTable, string argField) { // Get string with table name string table = argTable.ToString(); // Build mySQL Delete command string string mySQLDeleteCommand = "UPDATE " + table + " SET " + argField + " = null;"; // Execute the command using (var connection = new MySqlConnection(connectionString)) { connection.Execute(mySQLDeleteCommand); } }
/// <summary> /// Produces a list of all distinct elements from a table for a given column (field). /// </summary> /// <typeparam name="T"></typeparam> /// <param name="tableName"></param> /// <param name="field"></param> /// <returns></returns> public List <T> ListAllFromField <T>(myDB table, string field) { // Initialize List <T> resultsList = new List <T>(); // Build command string string select_field = "select DISTINCT " + field; string select_table = "from " + table.ToString(); string order_criteria = "order by " + field; string sqlCommand = String.Join(" ", new List <string>() { select_field, select_table, order_criteria }); // Connect and retreive data using (var connection = new MySqlConnection(connectionString)) { resultsList = (List <T>)connection.Query <T>(sqlCommand); } return(resultsList); }
public FormModel(myDB myDB, Iconfiguration myConfiguration) { }
private void btnDangNhap_Click(object sender, EventArgs e) { myDB mydb = new myDB(); if (rdoSinhVien.Checked) { SqlCommand command = new SqlCommand("select * from sinhvien where tentaikhoansv = @tk and matkhausv = @mk", mydb.getConnection); command.Parameters.Add("@tk", SqlDbType.VarChar).Value = TextBox_Username.Text; command.Parameters.Add("@mk", SqlDbType.VarChar).Value = TextBox_Password.Text; SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable dt = new DataTable(); adapter.Fill(dt); if (dt.Rows.Count > 0) { mainFrmSinhVien mainSV = new mainFrmSinhVien(dt.Rows[0][0].ToString()); Visible = false; mainSV.ShowDialog(); } else { MessageBox.Show("Sai Tài khoản hoặc Mật khẩu", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (rdoGiaoVien.Checked) { SqlCommand command = new SqlCommand("select * from giaovien where tentaikhoangv = @tk and matkhaugv = @mk", mydb.getConnection); command.Parameters.Add("@tk", SqlDbType.VarChar).Value = TextBox_Username.Text; command.Parameters.Add("@mk", SqlDbType.VarChar).Value = TextBox_Password.Text; SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable dt = new DataTable(); adapter.Fill(dt); if (dt.Rows.Count > 0) { MainFormGiaoVien mainGV = new MainFormGiaoVien(dt.Rows[0][0].ToString()); Visible = false; mainGV.ShowDialog(); } else { MessageBox.Show("Sai Tài khoản hoặc Mật khẩu", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { SqlCommand command = new SqlCommand("select * from admin where tentaikhoanad = @tk and matkhauad = @mk", mydb.getConnection); command.Parameters.Add("@tk", SqlDbType.VarChar).Value = TextBox_Username.Text; command.Parameters.Add("@mk", SqlDbType.VarChar).Value = TextBox_Password.Text; SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable dt = new DataTable(); adapter.Fill(dt); if (dt.Rows.Count > 0) { mainFormAdmin mainAD = new mainFormAdmin(dt.Rows[0][0].ToString()); Visible = false; mainAD.ShowDialog(); } else { MessageBox.Show("Sai Tài khoản hoặc Mật khẩu", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }