protected void AdminUserGrid_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = (GridViewRow)AdminUserGrid.Rows[e.RowIndex]; Label LabelID = (Label)row.FindControl("LabelEditID"); TextBox TxtName = (TextBox)row.FindControl("TextBoxEditName"); TextBox TxtSurname = (TextBox)row.FindControl("TextBoxEditSurname"); TextBox TxtTelephone = (TextBox)row.FindControl("TextBoxEditTelephone"); TextBox TxtEmail = (TextBox)row.FindControl("TextBoxEditEmail"); TextBox TxtPass = (TextBox)row.FindControl("TextBoxEditPassword"); TextBox TxtAddr = (TextBox)row.FindControl("TextBoxEditAddress"); CheckBox ChxAdmin = (CheckBox)row.FindControl("CheckBoxEditIsAdmin"); BLLClient.UpdateClient(new EClient { id = Convert.ToInt32(LabelID.Text.ToString()), name = TxtName.Text.ToString(), surname = TxtSurname.Text.ToString(), telephone = TxtTelephone.Text.ToString(), email = TxtEmail.Text.ToString(), password = TxtPass.Text.ToString(), address = TxtAddr.Text.ToString(), isAdmin = ChxAdmin.Checked }); using (System.IO.StreamWriter file = new System.IO.StreamWriter(submittedFilePath, true)) { file.WriteLine("[" + DateTime.Now + "] DB CLIENT UPDATED"); } AdminUserGrid.EditIndex = -1; FillClientView(); feedbackUser.Text = "Records Updated Succesfully !!!"; feedbackUser.Visible = true; }
public void LogIn(object sender, EventArgs e) { EClient usr = BLLClient.GetUser(Email.Text.ToString(), Password.Text.ToString()); using (System.IO.StreamWriter file = new System.IO.StreamWriter(submittedFilePath, true)) { file.WriteLine("[" + DateTime.Now + "] DB CLIENT VALIDATION"); } if (usr != null) { Session["user"] = usr; if (usr.isAdmin) { Response.Redirect("~/AdminPage.aspx"); } else { Response.Redirect("~/Default.aspx"); } } else { emailpassError.Visible = true; Email.Text = ""; Password.Text = ""; } }
protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e) { BLLClient client = new BLLClient(); //demande d'authentification d'un client e.Authenticated = client.UserConnect(LoginUser.UserName, LoginUser.Password); }
protected void FillClientView() { AdminUserGrid.DataSource = BLLClient.GetClients(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(submittedFilePath, true)) { file.WriteLine("[" + DateTime.Now + "] DB CLIENT DATA PULLED"); } AdminUserGrid.DataBind(); }
/** * Ajout d'un nouvel utilisateur à la base de donnée + connexion */ protected void RegisterUser_CreatedUser(object sender, EventArgs e) { // Récupération des informations de l'utilisateur TextBox firstName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("FirstName"); TextBox name = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Name"); TextBox userName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserName"); TextBox passWord = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Password"); DropDownList droit = (DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Activity"); //vérification de l'unicité de l'utilisateur //#TODO: faire appel à du linq BLLClient client = new BLLClient(); utilisateur[] users = client.GetUsers(); // Parcourt des clients existant // TODO: pas top comme systéme int newId = 0; foreach (utilisateur temp in users) { // Si le pseudo existe if (temp.Pseudo.Equals(userName.Text)) return; newId = temp.id + 1; } //création du nouvel utilisateur utilisateur newUser = new utilisateur(); newUser.id = newId; newUser.Prenom = firstName.Text; newUser.Nom = name.Text; newUser.Pseudo = userName.Text; newUser.Password = passWord.Text; newUser.Status = true; client.Insertuser(newUser); client.CommitData(); // Role de l'utilisateur String role = droit.SelectedValue; if (droit.SelectedValue.Equals("Editeur")) Roles.AddUserToRole(newUser.Pseudo, "Editeur"); FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false); // Redirection string url = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(url)) url = "~/"; Response.Redirect(url); }
protected void AdminUserGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = (GridViewRow)AdminUserGrid.Rows[e.RowIndex]; Label LabelID = (Label)row.FindControl("LabelID"); BLLClient.DeleteClient(Convert.ToInt32(LabelID.Text)); using (System.IO.StreamWriter file = new System.IO.StreamWriter(submittedFilePath, true)) { file.WriteLine("[" + DateTime.Now + "] DB CLIENT DELETED"); } FillClientView(); feedbackUser.Text = "Row Deleted Successfully !!!"; feedbackUser.Visible = true; }
/** * ajout d'un nouvel utilisateur à la base de donnée + connexion */ protected void RegisterUser_CreatedUser(object sender, EventArgs e) { /*récupération des informations de l'utilisateur*/ TextBox firstName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("FirstName"); TextBox name = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Name"); TextBox userName =(TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserName"); TextBox passWord = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Password"); //création du nouvel utilisateur utilisateur user = new utilisateur(); user.Prenom = firstName.Text; user.Nom = name.Text; user.Pseudo = userName.Text; user.Password = passWord.Text; user.Status = true; //vérification de l'unicité de l'utilisateur //#TODO: faire appel à du linq BLLClient client = new BLLClient(); utilisateur[] users = client.GetUsers(); int newId = -1; //parcour des clients existant foreach (utilisateur temp in users) { //si le pseudo existe if(temp.Pseudo.Equals(user.Pseudo)){ user.id = -1; break; } newId = temp.id+1; } if( user.id != -1){ //Ajout à la bd le nouvel utilisateur user.id = newId; client.Insertuser(user); client.CommitData(); //création de la session http FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { continueUrl = "~/"; } Response.Redirect(continueUrl); } }
protected void InsertUser_Click(object sender, EventArgs e) { string name = ((TextBox)AdminUserGrid.FooterRow.FindControl("TextBoxInsertName")).Text.ToString(); string surname = ((TextBox)AdminUserGrid.FooterRow.FindControl("TextBoxInsertSurname")).Text.ToString(); string telephone = ((TextBox)AdminUserGrid.FooterRow.FindControl("TextBoxInsertTelephone")).Text.ToString(); string email = ((TextBox)AdminUserGrid.FooterRow.FindControl("TextBoxInsertEmail")).Text.ToString(); string pass = ((TextBox)AdminUserGrid.FooterRow.FindControl("TextBoxInsertPassword")).Text.ToString(); string addr = ((TextBox)AdminUserGrid.FooterRow.FindControl("TextBoxInsertAddress")).Text.ToString(); bool admin = ((CheckBox)AdminUserGrid.FooterRow.FindControl("CheckBoxInsertIsAdmin")).Checked; BLLClient.CreateClient(name, surname, telephone, email, pass, addr, admin); using (System.IO.StreamWriter file = new System.IO.StreamWriter(submittedFilePath, true)) { file.WriteLine("[" + DateTime.Now + "] DB CLIENT INSERTED"); } FillClientView(); feedbackUser.Text = "Record Added !!!"; feedbackUser.Visible = true; }
/** * Ajout d'un nouvel utilisateur à la base de donnée + connexion */ protected void RegisterUser_CreatedUser(object sender, EventArgs e) { // Récupération des informations de l'utilisateur TextBox firstName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("FirstName"); TextBox name = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Name"); TextBox userName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserName"); TextBox passWord = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Password"); DropDownList droit = (DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Activity"); //vérification de l'unicité de l'utilisateur //#TODO: faire appel à du linq BLLClient client = new BLLClient(); utilisateur[] users = client.GetUsers(); // Parcourt des clients existant // TODO: pas top comme systéme int newId = 0; foreach (utilisateur temp in users) { // Si le pseudo existe if (temp.Pseudo.Equals(userName.Text)) { return; } newId = temp.id + 1; } //création du nouvel utilisateur utilisateur newUser = new utilisateur(); newUser.id = newId; newUser.Prenom = firstName.Text; newUser.Nom = name.Text; newUser.Pseudo = userName.Text; newUser.Password = passWord.Text; newUser.Status = true; client.Insertuser(newUser); client.CommitData(); // Role de l'utilisateur String role = droit.SelectedValue; if (droit.SelectedValue.Equals("Editeur")) { Roles.AddUserToRole(newUser.Pseudo, "Editeur"); } FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false); // Redirection string url = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(url)) { url = "~/"; } Response.Redirect(url); }