//============================================================================================ private void getRowsNumber(string sqlWhere) { int r = 0; r = Convert.ToInt32(DBFc.doSqlWithResultReturn("SELECT count(*) FROM Users " + sqlWhere, Glob.cnn)); lblRows.Text = r.ToString(); rowsTotal = r; }
//======================================================== public string Update() { string sql = "dbo.Users_Update @u_id=" + this.id.ToString() + ", @u_Name = N'" + this.uName.Replace("'", "''") + "', @u_Login = N'" + this.uLogin.Replace("'", "''") + "', @u_Password = N'" + this.uPassword.Replace("'", "''") + "'"; return(DBFc.doSqlWithResultReturn(sql, Glob.cnn)); }
private void readDataBase() { string result = ""; string sql = "SELECT TOP 1000 r_Rate FROM dbo.Rate"; DataTable DT = DBFc.getDataTable(sql, Glob.cnn, out result); hXList.Value = DT.Rows.Count.ToString(); for (int i = 0; i < 1000; i++) { hXList.Value += ',' + DT.Rows[i]["r_Rate"].ToString(); } }
//======================================================== // This is for User Login public usr(string Login, string Psw) { Hashtable HT = DBFc.getDataHashtable("dbo.Users_getByLoginAndPassword@uLogin='******', @u_Password='******', @u_Flags", Glob.cnn); if (HT != null) { this.id = Convert.ToInt32(HT["id"]); this.uFlag = Convert.ToInt32(HT["u_flags"]); this.uName = HT["u_Name"].ToString(); this.uLogin = HT["u_Login"].ToString(); this.uEmail = HT["u_Email"].ToString(); this.uPassword = Psw; } }
//======================================================== not used private void getUserData() { string sql = ""; sql = sql + "SELECT * FROM Users WHERE"; if (uLogin != "") { sql += "u_Login = '******'"; } else if (uEmail != "") { sql += "u_Email = '" + uEmail + "'"; } Hashtable HT = DBFc.getDataHashtable(sql, Glob.cnn); }
//======================================================== public usr(int id) { if (id == 0) { init(); } else { Hashtable HT = DBFc.getDataHashtable( "SELECT * FROM dbo.Users WHERE u_ID='" + id.ToString() + "'", Glob.cnn); this.id = id; this.uFlag = Convert.ToInt32(HT["u_flags"]); this.uName = HT["u_Name"].ToString(); this.uLogin = HT["u_Login"].ToString(); this.uPassword = HT["u_Password"].ToString(); } }
//======================================================== public string SaveNew() { string sql = "dbo.Users_AddNew @uName = N'" + this.uName + "', @uLogin = N'" + this.uLogin + "', @uPassword = N'" + this.uPassword + "', @uEmail = N'" + this.uEmail + "', @uAddress = N'No address provided', @uIP = N'0.0.0.0'"; string r = DBFc.doSqlWithResultReturn(sql, Glob.cnn); if (r == "Fail") { r = "Error on creating a new DataBase record."; } else { this.id = Convert.ToInt32(r); r = ""; } return(r); }
protected void btnLogin_Click(object sender, EventArgs e) { string login = tblogin.Text; string pass = tbPass.Value; string sql = "SELECT * FROM Users WHERE u_Login = '******' AND u_Password = '******'"; Hashtable HT = DBFc.getDataHashtable(sql, Glob.cnn); if (HT != null) { usr U = new usr(); U.uLogin = HT["u_Login"].ToString(); U.uEmail = HT["u_Email"].ToString(); U.id = Convert.ToInt32(HT["u_ID"]); Session["usr"] = U; lblMessage.Text = "Logged in"; huName.Value = HT["u_Name"].ToString(); } else { lblMessage.Text = "Wrong login or password."; } }