protected void Page_Load(object sender, EventArgs e) { if (Session["Manager"] != null) { registerUser.Style.Add("display", "inline"); manager.Style.Add("display", "inline"); loginProp.Style.Add("display", "none"); userProp.Style.Add("display", "block"); } else if (Session["Email"] != null) { registerUser.Style.Add("display", "inline"); loginProp.Style.Add("display", "none"); userProp.Style.Add("display", "block"); if (Session["Manager"] != null) { manager.Style.Add("display", "inline"); } else { ClientBL cBL = new ClientBL(); client = cBL.getClientByEmail(Session["Email"].ToString()); if (!client.contactName.Equals("")) { Name.InnerText = client.contactName; } else { Name.InnerText = client.name; } manager.Style.Add("display", "none"); } } else { loginProp.Style.Add("display", "inline"); userProp.Style.Add("display", "none"); registerUser.Style.Add("display", "none"); manager.Style.Add("display", "none"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["Email"] != null) { clientBL = new ClientBL(); cityBL = new CityBL(); client = clientBL.getClientByEmail(Session["Email"].ToString()); Email.Value = client.email; pass.Value = client.password; contactName.Value = client.contactName; NameC.Value = client.name; address.Value = client.address; city.Value = cityBL.getCityById(client.cityID); zipCode.Value = client.zipCode.ToString(); phone.Value = client.phone; contactPhone.Value = client.contactPhone; openTime.Value = client.openTime; status.Value = client.status.ToString(); } }
public Client getClientByEmail(string eMail) { con.Open(); string sqlString = "select * from Client c where Email='" + eMail + "';"; MySqlCommand com = new MySqlCommand(sqlString, con); Client client = null; using (MySqlDataReader rdr = com.ExecuteReader()) { while (rdr.Read()) { client = new Client(Convert.ToInt32(rdr["Id"]), rdr["Name"].ToString(), rdr["ContactName"].ToString(), rdr["Address"].ToString(), Convert.ToInt32(rdr["CityID"]), Convert.ToInt32(rdr["ZipCode"]), rdr["Phone"].ToString(), rdr["ContactPhone"].ToString(), rdr["OpenTime"].ToString(), Convert.ToInt32(rdr["LevelPrice"]), rdr["Email"].ToString(), rdr["Password"].ToString(), Convert.ToInt32(rdr["Status"])); break; } } con.Close(); return client; }