protected void btnLogin_Click(object sender, EventArgs e) { string userLoginQuery = "select Type from tblUsers where ID = '" + txtID.Text + "' and Password = '******'"; DBCon dbConnection = new DBCon(); dbConnection.ConOpen(); SqlDataReader typeReader = dbConnection.ExecuteReader(userLoginQuery); if (typeReader.Read()) { Session["UserId"] = txtID.Text; string userType = typeReader.GetString(0); dbConnection.ConClose(); switch (userType) { case "TEACHER": Response.Redirect("~/Teacher/TeacherHome.aspx"); break; case "STUDENT": Response.Redirect("~/Student/StudentHome.aspx"); break; case "ADMIN": Response.Redirect("~/Admin/AdminHome.aspx"); break; } } else { lblLoginStatus.Text = "Invalid Username/ Password"; } }
public Dictionary <string, string> GetImages(Core.Data.Geocache gc) { Dictionary <string, string> result = new Dictionary <string, string>(); try { DbDataReader dr = _dbcon.ExecuteReader(string.Format("select org_url, local_file from images where gccode = '{0}'", gc.Code.Replace("'", "''"))); while (dr.Read()) { result.Add(dr["org_url"] as string, System.IO.Path.Combine(new string[] { _imageFolder, IMG_SUBFOLDER, dr["local_file"] as string })); } } catch (Exception e) { Core.ApplicationData.Instance.Logger.AddLog(this, e); } return(result); }
private void deleteImagesThreadMethod() { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_DELETING_GRABBED_IMAGES, STR_DELETING_IMAGES, _gcList.Count, 0, true)) { try { int block = 0; string fnp = System.IO.Path.Combine(PluginSettings.Instance.ActiveDataPath, IMG_SUBFOLDER); for (int i = 0; i < _gcList.Count; i++) { DbDataReader dr = _dbcon.ExecuteReader(string.Format("select local_file from images where gccode='{0}'", _gcList[i].Code.Replace("'", "''"))); while (dr.Read()) { string fn = System.IO.Path.Combine(fnp, dr.GetString(0)); try { if (System.IO.File.Exists(fn)) { System.IO.File.Delete(fn); } } catch { } } _dbcon.ExecuteNonQuery(string.Format("delete from images where gccode='{0}'", _gcList[i].Code.Replace("'", "''"))); block++; if (block > 10) { block = 0; if (!progress.UpdateProgress(STR_DELETING_GRABBED_IMAGES, STR_DELETING_IMAGES, _gcList.Count, i)) { break; } } } } catch { } } }