コード例 #1
0
        bool CustomAuthenticate(string username, string password)
        {
            DBDriver db = new DBDriver();
            string   q  = "select count(*) from softeng4.users where userName='******';";

            db.Query = q;
            int k = (int)db.scalar();

            if (k == 0)
            {
                //user does not exist in DB
                ErrorLabel.Text = "You have entered an unknown username.";
                return(false);
            }
            else
            {
                q        = "select count(*) from softeng4.users u where u.userName='******' and u.password='******'";
                db.Query = q;
                k        = (int)db.scalar();
                if (k == 0)
                {
                    //password incorrect
                    ErrorLabel.Text = "You have entered an incorrect password.";
                    return(false);
                }
                else
                {
                    //successful authentication
                    q        = "select u.security s, u.ID id, p.firstName fname, p.lastName lname from softeng4.users u, softeng4.person p where u.ID = p.ID and u.username='******'";
                    db.Query = q;
                    SqlDataReader dr = db.createReader();
                    dr.Read();

                    user = new User(dr["id"].ToString());

                    db.close();

                    // create the cookie
                    Response.Cookies["user"].Values.Add("role", user.Role);
                    Response.Cookies["user"].Values.Add("id", user.ID);
                    Response.Cookies["user"].Values.Add("name", user.UserName);
                    Response.Cookies["user"].Values.Add("fname", user.FirstName);
                    Response.Cookies["user"].Values.Add("lname", user.LastName);

                    return(true);
                }
            }
        }
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: jrummell/projmgt-net
        bool CustomAuthenticate(string username, string password)
        {
            DBDriver db = new DBDriver();
            string q="select count(*) from softeng4.users where userName='******';";
            db.Query = q;
            int k=(int)db.scalar();
            if(k==0)
            {
                //user does not exist in DB
                ErrorLabel.Text = "You have entered an unknown username.";
                return false;
            }
            else
            {
                q="select count(*) from softeng4.users u where u.userName='******' and u.password='******'";
                db.Query = q;
                k=(int)db.scalar();
                if(k==0)
                {
                    //password incorrect
                    ErrorLabel.Text = "You have entered an incorrect password.";
                    return false;
                }
                else
                {
                    //successful authentication
                    q="select u.security s, u.ID id, p.firstName fname, p.lastName lname from softeng4.users u, softeng4.person p where u.ID = p.ID and u.username='******'";
                    db.Query = q;
                    SqlDataReader dr=db.createReader();
                    dr.Read();

                    user = new User(dr["id"].ToString());

                    db.close();

                    // create the cookie
                    Response.Cookies["user"].Values.Add("role",  user.Role);
                    Response.Cookies["user"].Values.Add("id",    user.ID);
                    Response.Cookies["user"].Values.Add("name",  user.UserName);
                    Response.Cookies["user"].Values.Add("fname", user.FirstName);
                    Response.Cookies["user"].Values.Add("lname", user.LastName);

                    return true;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Create user from id
        /// </summary>
        /// <param name="id">User ID number</param>
        public User(string id)
        {
            // get user info from db
            this.id = id;
            DBDriver myDB = new DBDriver();

            myDB.Query = "select * from person p, users u where p.id=@id and u.id=p.id;";
            myDB.addParam("@id", this.id);
            SqlDataReader dr = myDB.createReader();

            dr.Read();
            this.userName  = dr["userName"].ToString();
            this.address   = dr["address"].ToString();
            this.city      = dr["city"].ToString();
            this.email     = dr["email"].ToString();
            this.firstName = dr["firstName"].ToString();
            this.lastName  = dr["lastName"].ToString();
            this.password  = dr["password"].ToString();
            this.phone     = dr["phoneNumber"].ToString();
            this.role      = dr["security"].ToString();
            this.state     = dr["state"].ToString();
            this.zip       = dr["zip"].ToString();
            myDB.close();
        }
コード例 #4
0
ファイル: User.cs プロジェクト: jrummell/projmgt-net
 /// <summary>
 /// Create user from id
 /// </summary>
 /// <param name="id">User ID number</param>
 public User(string id)
 {
     // get user info from db
     this.id=id;
     DBDriver myDB=new DBDriver();
     myDB.Query="select * from person p, users u where p.id=@id and u.id=p.id;";
     myDB.addParam("@id", this.id);
     SqlDataReader dr=myDB.createReader();
     dr.Read();
     this.userName=dr["userName"].ToString();
     this.address=dr["address"].ToString();
     this.city=dr["city"].ToString();
     this.email=dr["email"].ToString();
     this.firstName=dr["firstName"].ToString();
     this.lastName=dr["lastName"].ToString();
     this.password=dr["password"].ToString();
     this.phone=dr["phoneNumber"].ToString();
     this.role=dr["security"].ToString();
     this.state=dr["state"].ToString();
     this.zip=dr["zip"].ToString();
     myDB.close();
 }
コード例 #5
0
ファイル: Project.cs プロジェクト: jrummell/projmgt-net
        /// <summary>
        /// Assign a Developer
        /// </summary>
        /// <param name="dev"></param>
        public void assignDeveloper(string devID)
        {
            this.devID = devID;

            DBDriver db = new DBDriver();
            db.Query = "insert into assignments (taskID, devID, dateAss)\n"
                        + "values (@taskID, @devID, @date)";
            db.addParam("@taskID", this.id);
            db.addParam("@devID", devID);
            db.addParam("@date", Convert.ToString(DateTime.Now));
            db.nonQuery();

            db.Query = "update tasks set complete = @complete\n"
                     + "where ID = @taskID;";
            db.addParam("@complete", PMT.TaskStatus.INPROGRESS);
            db.addParam("@taskID", this.id);
            db.nonQuery();

            db.Query = "select competence from compLevels where ID = @devID";
            db.addParam("@devID", devID);
            SqlDataReader dr = db.createReader();
            dr.Read();
            string competence = dr["competence"].ToString();
            db.close();
            string length;

            if( complexity == "Low" )
              db.Query = "select lowComplexity as length from compmatrix where compLevel = @competence";
            else if ( complexity == "Medium" )
              db.Query = "select medComplexity as length from compmatrix where compLevel = @competence";
            else if ( complexity == "High" )
              db.Query = "select highComplexity as length from compmatrix where compLevel = @competence";

            db.addParam("@competence", competence);
            dr = db.createReader();
            dr.Read();
            length = dr["length"].ToString();
            db.close();

            //TimeSpan temp = new TimeSpan(Convert.ToInt32(length), 0, 0, 0);
            DateTime start = Convert.ToDateTime(this.startDate);
            double hours = Convert.ToDouble(length);
            double days = Math.Ceiling(hours/8);
            DateTime end = start.AddDays(days);
            this.expEndDate = end.ToShortDateString();

            db.Query = "update tasks set expEndDate = @expEndDate\n"
                + "where ID = @taskID;";
            db.addParam("@expEndDate", this.expEndDate);
            db.addParam("@taskID", this.id);
            db.nonQuery();
            //TODO
            //			modid = ||select moduleid from tasks where id = @taskid;
            //
            //maximum = max of ||select tasks.expenddate from tasks where tasks.moduleid = @modid
            //
            //update modules set expenddate = @maximum where id = @modid
            //
            //projid = ||select projectid from modules where id = @modid
            //
            //maximum = max of ||select expenddate from modules where projectid = @projid
            //
            //update project set expenddate = @maximum where id = @projid
        }
コード例 #6
0
        /// <summary>
        /// Assign a Developer
        /// </summary>
        /// <param name="dev"></param>
        public void assignDeveloper(string devID)
        {
            this.devID = devID;

            DBDriver db = new DBDriver();

            db.Query = "insert into assignments (taskID, devID, dateAss)\n"
                       + "values (@taskID, @devID, @date)";
            db.addParam("@taskID", this.id);
            db.addParam("@devID", devID);
            db.addParam("@date", Convert.ToString(DateTime.Now));
            db.nonQuery();

            db.Query = "update tasks set complete = @complete\n"
                       + "where ID = @taskID;";
            db.addParam("@complete", PMT.TaskStatus.INPROGRESS);
            db.addParam("@taskID", this.id);
            db.nonQuery();

            db.Query = "select competence from compLevels where ID = @devID";
            db.addParam("@devID", devID);
            SqlDataReader dr = db.createReader();

            dr.Read();
            string competence = dr["competence"].ToString();

            db.close();
            string length;

            if (complexity == "Low")
            {
                db.Query = "select lowComplexity as length from compmatrix where compLevel = @competence";
            }
            else if (complexity == "Medium")
            {
                db.Query = "select medComplexity as length from compmatrix where compLevel = @competence";
            }
            else if (complexity == "High")
            {
                db.Query = "select highComplexity as length from compmatrix where compLevel = @competence";
            }

            db.addParam("@competence", competence);
            dr = db.createReader();
            dr.Read();
            length = dr["length"].ToString();
            db.close();

            //TimeSpan temp = new TimeSpan(Convert.ToInt32(length), 0, 0, 0);
            DateTime start = Convert.ToDateTime(this.startDate);
            double   hours = Convert.ToDouble(length);
            double   days  = Math.Ceiling(hours / 8);
            DateTime end   = start.AddDays(days);

            this.expEndDate = end.ToShortDateString();

            db.Query = "update tasks set expEndDate = @expEndDate\n"
                       + "where ID = @taskID;";
            db.addParam("@expEndDate", this.expEndDate);
            db.addParam("@taskID", this.id);
            db.nonQuery();
//TODO
//			modid = ||select moduleid from tasks where id = @taskid;
//
//maximum = max of ||select tasks.expenddate from tasks where tasks.moduleid = @modid
//
//update modules set expenddate = @maximum where id = @modid
//
//projid = ||select projectid from modules where id = @modid
//
//maximum = max of ||select expenddate from modules where projectid = @projid
//
//update project set expenddate = @maximum where id = @projid
        }