public void Init(userClass curUser) { this.curUser = curUser; switch (curUser.accessLevel) { case 1: lbContentBing(lbLevel, "userOp"); LevelIcon.SelectedIndex = 1; cbLevel.SelectedIndex = 0; break; case 2: lbContentBing(lbLevel, "userMt"); LevelIcon.SelectedIndex = 2; cbLevel.SelectedIndex = 1; break; case 3: lbContentBing(lbLevel, "userMgr"); LevelIcon.SelectedIndex = 3; lbContentBing(lbLevel2, "userMgr"); break; case 4: lbContentBing(lbLevel, "userSer"); LevelIcon.SelectedIndex = 4; lbContentBing(lbLevel2, "userSer"); break; case 5: lbContentBing(lbLevel, "userRoot"); LevelIcon.SelectedIndex = 5; lbContentBing(lbLevel2, "userRoot"); break; default: lbLevel.Content = "unDefined"; LevelIcon.SelectedIndex = 0; lbContentBing(lbLevel2, "unDefined"); break; } if (curUser.accessLevel > 2) { btnDelete.IsEnabled = false; cbLevel.IsEnabled = false; lbLevel2.Visibility = Visibility.Visible; } else { btnDelete.IsEnabled = true; cbLevel.IsEnabled = true; lbLevel2.Visibility = Visibility.Hidden; } lbUsername.Content = curUser.name; lbError.Visibility = Visibility.Hidden; Password = PassowrdConfirm = curUser.password; lbPassword.Content = getPasswordStr(Password.Length); lbPasswordConfirm.Content = getPasswordStr(Password.Length); }
public Main(userClass usr) { InitializeComponent(); User = usr; statusStrip1.Enabled = false; login formLogin = new login(); formLogin.MdiParent = this; formLogin.TopMost = true; formLogin.Show(); }
public bool AddUser(userClass user) { //SEt Return Value and set its default value to false bool isSuccess = false; //Step 1: Databse Connection SqlConnection conn = new SqlConnection(myconnstr); try { //STep 2: Writing T-SQL string sql = "INSERT INTO tbl_user (full_name,username,email,password,added_date) VALUES (@full_name,@username,@email,@password,@added_date)"; //STep 3: SQL Command using sql and conn SqlCommand cmd = new SqlCommand(sql, conn); //Step 4: Pass value to parameters cmd.Parameters.AddWithValue("@full_name", user.full_name); cmd.Parameters.AddWithValue("@username", user.username); cmd.Parameters.AddWithValue("@email", user.email); cmd.Parameters.AddWithValue("@password", user.password); cmd.Parameters.AddWithValue("@added_date", user.addeddate); //Step 5: Open Connection conn.Open(); //Step 6: Execute Query int rows = cmd.ExecuteNonQuery(); //If the user is added then the value of rows will be greater than 1 else the value of rows will be less than 1 if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { } finally { //Step 7: Close Connection conn.Close(); } return(isSuccess); }
public void generateReport() { DataTable DT = currentProject.getProjectPermissions(); lit_ProjectSum.Text = "Total Members on Project: " + DT.Rows.Count; lit_ProjectDetails.Text = "<ul>"; foreach (DataRow DR in DT.Rows) { userClass usr = new userClass(int.Parse(DR["user_GivenTo"].ToString())); lit_ProjectDetails.Text += "<li>" + usr.getDisplayName() + " - " + DR["projectTitle"].ToString() + "</li>"; } lit_ProjectDetails.Text += "</ul>"; }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ID"] != null) { currentProject = new Project(int.Parse(Request.QueryString["ID"].ToString())); string IP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? Request.ServerVariables["REMOTE_ADDR"]; currentUser = new userClass(userClass.getUserIDByIP(IP)); lbl_ProjectDescription.Text = currentProject.getTaskDescription(); lbl_ProjectName.Text = currentProject.getTaskName(); generateReport(); } else { Response.Redirect("Home.aspx"); } }
static void Main(string[] args) { Console.WriteLine("Hola Usuario. La leyenda (key) del horario es: \n" + "0. SALON DISPONIBLE EN DICHA HORA\n" + "1. SALON RESERVADO A ESA HORA\n" + "2. SALON EN MANTENIMIENTO Y SIN RESERVA A ESA HORA\n" + "3. SALON EN MANTENIMIENTO Y CON RESERVA A ESA HORA\n\n" + "Para acceder como administrador, ingresar 'user1' como nombre y 'pass1' como contraseña.\n" + "Para acceder como estudiante, ingresar 'user2' como nombre y 'pass2' como contraseña\n\n"); ValidarUser objValidar = new ValidarUser(); Salon objSalon = new Salon(); //Instancias de clases userClass objUsuario = new userClass(); int horaSistema = 7; //HORA GLOBAL bool estadoAdmin = objValidar.Login(); //Para verificar si el usuario es admin o estudiante Console.WriteLine("Bienvenido al sistema de salones"); List <List <int> > horariosSalones = objSalon.inicializarSalones(); //Crea la matriz de [salones] [hora] List <Salon> estadoSalones = objSalon.inicializarEstados(); //Crea la lista de objetos (salones) int choice = 0; string opcMenu; while (choice != -1) { if (estadoAdmin == true) { objValidar.MenuAdmin(); //ADMIN MENU Console.WriteLine("Digite la opcion: "); opcMenu = Console.ReadLine(); choice = Convert.ToInt32(opcMenu); switch (choice) { case 1: //1. Reservar Salon horariosSalones = objUsuario.ReservarSalon(horariosSalones); Console.WriteLine(); break; case 2: //Consultar Disponibilidad Salon objUsuario.ConsultarSalon(horariosSalones); Console.WriteLine(); break; case 3: //Ver estado salon (aire, abierto?, luz). En la hora que fija el admin objSalon.EstadoSalon(horariosSalones, estadoSalones, horaSistema); Console.WriteLine(); break; case 4: //Modificar temperatura salon (propositos de la modelacion) estadoSalones = objSalon.modificarTemp(estadoSalones); break; case 5: //Modificar hora (para ver estado (case 3)) horaSistema = objUsuario.modificarHora(); Console.WriteLine("La nueva hora es: " + horaSistema); break; case 6: //Poner salon en mantenimiento horariosSalones = objUsuario.ponerEnMantenimiento(horariosSalones); Console.WriteLine(); break; case 7: //Finalizar mantenimiento horariosSalones = objUsuario.finalizarMantenimiento(horariosSalones); Console.WriteLine(); break; default: Console.WriteLine(); break; } } else { objValidar.MenuGeneral(); Console.WriteLine("Digite la opcion: "); opcMenu = Console.ReadLine(); choice = Convert.ToInt32(opcMenu); switch (choice) { case 1: //1. Reservar Salon horariosSalones = objUsuario.ReservarSalon(horariosSalones); Console.WriteLine(); break; case 2: //Consultar Disponibilidad Salon objUsuario.ConsultarSalon(horariosSalones); break; case 3: //Ver estado salon (aire, abierto?, luz). En la hora que fija el admin objSalon.EstadoSalon(horariosSalones, estadoSalones, horaSistema); Console.WriteLine(); break; default: Console.WriteLine(); break; } } } }
public bool Login() { List <userClass> users = new List <userClass>(); userClass myObj1 = new userClass(); myObj1.name = "user1"; myObj1.pass = "******"; myObj1.EsAdmin = true; users.Add(myObj1); myObj1 = new userClass(); myObj1.name = "Jeff"; myObj1.pass = "******"; myObj1.EsAdmin = true; users.Add(myObj1); //Usuarios pre-definidos myObj1 = new userClass(); myObj1.name = "user2"; myObj1.pass = "******"; myObj1.EsAdmin = false; users.Add(myObj1); myObj1 = new userClass(); myObj1.name = "Gustavo"; myObj1.pass = "******"; myObj1.EsAdmin = false; users.Add(myObj1); /*for(int i=0; i<users.Count; i++){ * Console.WriteLine(users[i].name + "\n" + users[i].pass + "\n" + users[i].EsAdmin +"\n"); //Display de usuarios y contraseñas * }*/ bool javeriano = false; string inpName; string inpPass; bool admin = false; while (javeriano == false) { Console.WriteLine("Digite su usuario: "); inpName = Console.ReadLine(); Console.WriteLine("Contraseña: "); inpPass = Console.ReadLine(); for (int i = 0; i < users.Count; i++) { if (String.Compare(users[i].name, inpName) == 0 && String.Compare(users[i].pass, inpPass) == 0) { if (users[i].EsAdmin == true) { if (admin == true) { } admin = true; javeriano = true; Console.WriteLine("Usuario admin verificado. Bienvenido Sr. " + users[i].name); break; } else { Console.WriteLine("Usuario de estudiante verificado. Ingresando..."); javeriano = true; break; } } } if (javeriano == true) { break; } Console.WriteLine("Que asco, un estudiante de icesi. Coga seriedad\n"); } return(admin); }
private void btnLogin_Click(object sender, EventArgs e) { userClass loginuser = new userClass(); //Added by Liana: Following code provide login for default user: Admin/password in case Author: Liana //Registration and Exit buttons are available for Admin if (txtUsername.Text == "admin" & txtPassword.Text == "password") { Main frm = (Main)this.MdiParent; //store username and the time of login in loginuser loginuser.userDOB = DateTime.Now; loginuser.userName = txtUsername.Text; Panel pnl = (Panel)frm.Controls["pnlMainBtn"]; pnl.Visible = true; StatusStrip SS = (StatusStrip)frm.Controls["StatusStrip1"]; SS.Items["tSSLUsername"].Text = txtUsername.Text; SS.Enabled = true; loginuser.userRole = userClass.userRoles.Admin; pnl.Controls["btnReg"].Enabled = Enabled; pnl.Controls["btnTimesheet"].Enabled = false; frm.setlogin(loginuser); this.Hide(); } // If user is not Admin then login and password are verified with db else { string connStr = ConfigurationManager.ConnectionStrings["myConnection"].ConnectionString; using (var con = new SqlConnection(connStr)) { //check username and password SqlCommand cmd = new SqlCommand("select id, name, surname, role_id from employee where [role_id]<>'' and [login]=@username and [password]=@password and isActive ='True' ", con); cmd.Parameters.AddWithValue("@username", txtUsername.Text); cmd.Parameters.AddWithValue("@password", txtPassword.Text); cmd.Connection.Open(); SqlDataReader rdr = cmd.ExecuteReader(); rdr.Read(); if (rdr.HasRows) { //user password is right so show controls Main frm = (Main)this.MdiParent; //store username and the time of login in loginuser loginuser.userDOB = DateTime.Now; loginuser.userName = txtUsername.Text; loginuser.userfullname = rdr["name"].ToString() + " " + rdr["surname"].ToString(); loginuser.userID = (int)rdr["id"]; Panel pnl = (Panel)frm.Controls["pnlMainBtn"]; pnl.Visible = true; StatusStrip SS = (StatusStrip)frm.Controls["StatusStrip1"]; SS.Items["tSSLUsername"].Text = txtUsername.Text; SS.Enabled = true; //findout the role of user and store in loginuser obj and enable right buttons switch ((int)rdr["role_id"]) { case 1: loginuser.userRole = userClass.userRoles.Admin; pnl.Controls["btnReg"].Enabled = Enabled; pnl.Controls["btnTimesheet"].Enabled = false; break; case 3: loginuser.userRole = userClass.userRoles.SiteManager; pnl.Controls["btnReg"].Enabled = false; pnl.Controls["btnTimesheet"].Enabled = Enabled; break; case 2: loginuser.userRole = userClass.userRoles.ProjectManager; pnl.Controls["btnTimesheet"].Enabled = Enabled; pnl.Controls["btnReg"].Enabled = false; break; default: loginuser.userRole = userClass.userRoles.Worker; pnl.Controls["btnTimesheet"].Enabled = false; pnl.Controls["btnReg"].Enabled = false; break; } frm.setlogin(loginuser); this.Hide(); } else { //Do to deal with failure…… MessageBox.Show("Username or password is wrong!"); } cmd.Connection.Close(); } } }
private void setProjectOwner(userClass u) { projectOwner = u; }
public void setlogin(userClass usr) { User = usr; }
protected void Page_Load(object sender, EventArgs e) { MaintainScrollPositionOnPostBack = true; if (Request.QueryString["ID"] != null) { updateProjectPercent(); ID = Request.QueryString["ID"].ToString(); string IP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? Request.ServerVariables["REMOTE_ADDR"]; currentProject = new Project(int.Parse(ID)); //DataTable DT = theCake.getTask(Int32.Parse(ID), theCake.getActiveUserName(IP)); if (!currentProject.isValid) { Response.Redirect("Home.aspx"); } //string ownerAlias = userClass.getUserAlias(Int32.Parse(DT.Rows[0]["ownerID"].ToString())); userClass projOwner = new userClass(currentProject.getOwnerID()); if (theCake.getActiveUserName(IP) != projOwner.getOwnerAlias()) { int userID = theCake.getUserID(theCake.getActiveUserName(IP)); DataTable permissionChecker = theCake.getUserProjectPermissions(userID, Int32.Parse(ID)); if (permissionChecker.Rows[0]["permission_Project_Write"].ToString() == "0") { ProjectWrite = false; } if (permissionChecker.Rows[0]["permission_Board_Write"].ToString() == "0") { BoardWrite = false; } } if (!ProjectWrite) { pnl_EditOperations.Visible = false; pnl_SpecialOptions.Visible = false; } if (!BoardWrite) { btn_AddComment.Visible = false; } lbl_TaskName.Text = currentProject.getTaskName(); //DT.Rows[0]["taskName"].ToString(); lbl_Description.Text = currentProject.getTaskDescription(); //DT.Rows[0]["taskDescription"].ToString(); lbl_projectOwner.Text = "<a href=\"UserProfile.aspx?userID=" + currentProject.getOwnerID() + "\">" + projOwner.getDisplayName(); btn_ViewProjectReport.PostBackUrl = "printProjectReport.aspx?ID=" + Request.QueryString["ID"].ToString(); btn_ViewMemberReport.PostBackUrl = "printMemberReport.aspx?ID=" + Request.QueryString["ID"].ToString(); if (!IsPostBack) { txt_Edit_TaskName.Text = currentProject.getTaskName(); txt_Edit_TaskDescription.Text = currentProject.getTaskDescription(); //DT.Rows[0]["taskDescription"].ToString(); } lbl_ExpectedStart.Text = currentProject.getExpectedStart().ToShortDateString(); lbl_ExpectedStop.Text = currentProject.getExpectedStop().ToShortDateString(); if (currentProject.getActualStart() == DateTime.MinValue) { lbl_ActualStart.Text = "Not Yet Started"; } else { lbl_ActualStart.Text = currentProject.getActualStart().ToShortDateString(); } if (currentProject.getActualStop() == DateTime.MinValue) { lbl_ActualStop.Text = "Not Yet Completed"; } else { lbl_ActualStop.Text = currentProject.getActualStop().ToShortDateString(); } if (currentProject.getDoneFlag()) { btn_markDone.Visible = false; btn_markWip.Visible = true; btn_UpgradeSize.Visible = false; AddComments.Visible = false; FillMilestones(); getallBoards(); } else { if (Request.QueryString["feat"] != null) { if (!IsPostBack) { Feature ftr = new Feature(int.Parse(Request.QueryString["feat"].ToString())); lbl_remChildFeature_Name.Text = ftr.getFeatureName(); lbl_remChildFeature_Description.Text = ftr.getFeatureDescription(); lbl_remChildFeature_PercentComplete.Text = ftr.getPercentComplete().ToString() + "%"; btnRemFeature.CommandArgument = ftr.getID().ToString(); txt_editChildFeature_Name.Text = ftr.getFeatureName(); txt_editChildFeature_Description.Text = ftr.getFeatureDescription(); for (int i = 0; i <= 100; i++) { ddl_editChildFeature_PercentComplete.Items.Add(i.ToString()); } for (int i = 1; i <= 5; i++) { ddl_editChildFeature_Weight.Items.Add(i.ToString()); ddl_addChildFeature_Weight.Items.Add(i.ToString()); } ddl_editChildFeature_PercentComplete.SelectedIndex = ftr.getPercentComplete(); ddl_editChildFeature_Weight.SelectedIndex = ftr.getWeight() - 1; if (ftr.hasChildren) { ddl_editChildFeature_PercentComplete.Enabled = false; } else { ddl_editChildFeature_PercentComplete.Enabled = true; } lbl_quickComplete_Name.Text = ftr.getFeatureName(); lbl_quickComplete_Description.Text = ftr.getFeatureDescription(); lbl_quickComplete_PercentComplete.Text = ftr.getPercentComplete().ToString(); } } if (currentProject.getActualStart() == DateTime.MinValue) { btn_markDone.Visible = false; btn_markWip.Visible = false; AddComments.Visible = false; btn_startTask.Visible = true; } FillMilestones(); getallBoards(); } } else { Response.Redirect("Home.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { MaintainScrollPositionOnPostBack = true; if (Request.QueryString["ID"] != null) { updateProjectPercent(); ID = Request.QueryString["ID"].ToString(); string IP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? Request.ServerVariables["REMOTE_ADDR"]; currentProject = new Project(int.Parse(ID)); //DataTable DT = theCake.getTask(Int32.Parse(ID), theCake.getActiveUserName(IP)); if (!currentProject.isValid) { Response.Redirect("Home.aspx"); } //string ownerAlias = userClass.getUserAlias(Int32.Parse(DT.Rows[0]["ownerID"].ToString())); userClass projOwner = new userClass(currentProject.getOwnerID()); if (theCake.getActiveUserName(IP) != projOwner.getOwnerAlias()) { int userID = theCake.getUserID(theCake.getActiveUserName(IP)); DataTable permissionChecker = theCake.getUserProjectPermissions(userID, Int32.Parse(ID)); if (permissionChecker.Rows[0]["permission_Project_Write"].ToString() == "0") ProjectWrite = false; if (permissionChecker.Rows[0]["permission_Board_Write"].ToString() == "0") BoardWrite = false; } if (!ProjectWrite) { pnl_EditOperations.Visible = false; pnl_SpecialOptions.Visible = false; } if (!BoardWrite) { btn_AddComment.Visible = false; } lbl_TaskName.Text = currentProject.getTaskName(); //DT.Rows[0]["taskName"].ToString(); lbl_Description.Text = currentProject.getTaskDescription(); //DT.Rows[0]["taskDescription"].ToString(); lbl_projectOwner.Text = "<a href=\"UserProfile.aspx?userID=" + currentProject.getOwnerID() + "\">" + projOwner.getDisplayName(); btn_ViewProjectReport.PostBackUrl = "printProjectReport.aspx?ID=" + Request.QueryString["ID"].ToString(); btn_ViewMemberReport.PostBackUrl = "printMemberReport.aspx?ID=" + Request.QueryString["ID"].ToString(); if (!IsPostBack) { txt_Edit_TaskName.Text = currentProject.getTaskName(); txt_Edit_TaskDescription.Text = currentProject.getTaskDescription(); //DT.Rows[0]["taskDescription"].ToString(); } lbl_ExpectedStart.Text = currentProject.getExpectedStart().ToShortDateString(); lbl_ExpectedStop.Text = currentProject.getExpectedStop().ToShortDateString(); if (currentProject.getActualStart() == DateTime.MinValue) lbl_ActualStart.Text = "Not Yet Started"; else lbl_ActualStart.Text = currentProject.getActualStart().ToShortDateString(); if (currentProject.getActualStop() == DateTime.MinValue) lbl_ActualStop.Text = "Not Yet Completed"; else lbl_ActualStop.Text = currentProject.getActualStop().ToShortDateString(); if (currentProject.getDoneFlag()) { btn_markDone.Visible = false; btn_markWip.Visible = true; btn_UpgradeSize.Visible = false; AddComments.Visible = false; FillMilestones(); getallBoards(); } else { if (Request.QueryString["feat"] != null) { if (!IsPostBack) { Feature ftr = new Feature(int.Parse(Request.QueryString["feat"].ToString())); lbl_remChildFeature_Name.Text = ftr.getFeatureName(); lbl_remChildFeature_Description.Text = ftr.getFeatureDescription(); lbl_remChildFeature_PercentComplete.Text = ftr.getPercentComplete().ToString() + "%"; btnRemFeature.CommandArgument = ftr.getID().ToString(); txt_editChildFeature_Name.Text = ftr.getFeatureName(); txt_editChildFeature_Description.Text = ftr.getFeatureDescription(); for (int i = 0; i <= 100; i++) { ddl_editChildFeature_PercentComplete.Items.Add(i.ToString()); } for (int i = 1; i <= 5; i++) { ddl_editChildFeature_Weight.Items.Add(i.ToString()); ddl_addChildFeature_Weight.Items.Add(i.ToString()); } ddl_editChildFeature_PercentComplete.SelectedIndex = ftr.getPercentComplete(); ddl_editChildFeature_Weight.SelectedIndex = ftr.getWeight() - 1; if (ftr.hasChildren) { ddl_editChildFeature_PercentComplete.Enabled = false; } else { ddl_editChildFeature_PercentComplete.Enabled = true; } lbl_quickComplete_Name.Text = ftr.getFeatureName(); lbl_quickComplete_Description.Text = ftr.getFeatureDescription(); lbl_quickComplete_PercentComplete.Text = ftr.getPercentComplete().ToString(); } } if (currentProject.getActualStart() == DateTime.MinValue) { btn_markDone.Visible = false; btn_markWip.Visible = false; AddComments.Visible = false; btn_startTask.Visible = true; } FillMilestones(); getallBoards(); } } else { Response.Redirect("Home.aspx"); } }