Exemplo n.º 1
0
        public static Boolean Create(int type, String values, String id)
        {
            db.AddToTable(db.TPERSON, values);

            Employee _user;

            switch (type)
            {
            case 0:                                         //student
                values = id + ", 0.0, 1, '', '', '', 1, 1"; //default student values
                db.AddToTable(db.TSTUDENT, values);
                break;

            case 1:                                                       //secretary
                _user  = new Secretary();
                values = id + ", " + _user.SALARY + ", null, 0, " + type; //default secretary values
                db.AddToTable(db.TEMPLOYEE, values);
                break;

            case 2:                                                       //tutor
                _user  = new Tutor();
                values = id + ", " + _user.SALARY + ", null, 1, " + type; //default tutor values
                db.AddToTable(db.TEMPLOYEE, values);
                db.AddToTable(db.TRECEPTION, id + ", '1', '2015-05-26 00:00:00.000', '2015-05-26 00:00:00.000'");
                break;

            case 3:                                                       //lecturer
                _user  = new Lecturer();
                values = id + ", " + _user.SALARY + ", null, 2, " + type; //default lecturer values
                db.AddToTable(db.TEMPLOYEE, values);
                db.AddToTable(db.TRECEPTION, id + ", '1', '2015-05-26 00:00:00.000', '2015-05-26 00:00:00.000'");
                break;

            case 4:                                                       //department head
                _user  = new HeadDept();
                values = id + ", " + _user.SALARY + ", null, 2, " + type; //default head dept values
                db.AddToTable(db.TEMPLOYEE, values);
                break;
            }

            return(db.checkExistance(db.TPERSON, "id = " + id));
        }
Exemplo n.º 2
0
        public Employee getEmployee(String Conditions)
        {
            Employee      _emp     = null;
            List <String> itemList = new List <String>();

            itemList = FetchList(TPerson, "*", Conditions);

            switch (Convert.ToInt32(itemList[9]))
            {
            case 1:     //secretary
                Secretary _sec = new Secretary();

                _sec.USERNAME  = itemList[0];
                _sec.PASSWORD  = itemList[1];
                _sec.ID        = itemList[2];
                _sec.FIRSTNAME = itemList[3];
                _sec.LASTNAME  = itemList[4];
                _sec.MAIL      = itemList[5];
                _sec.PHONE     = itemList[6];

                _sec.GENDER = (Gender)(Convert.ToInt32(itemList[7]));
                _sec.DEPT   = (Department)(Convert.ToInt32(itemList[8]));
                //-------------------------------------------------------------------------------------------//
                itemList = FetchList(TEmployee, "*", "id = " + _sec.ID);
                //-------------------------------------------------------------------------------------------//
                _sec.SALARY = Convert.ToSingle(itemList[1]);
                _sec.DEGREE = (Degree)(Convert.ToInt32(itemList[3]));
                _sec.JOB    = (Job)(Convert.ToInt32(itemList[4]));

                _emp = _sec;
                break;

            case 2:     //tutor
                Tutor _tut = new Tutor();

                _tut.USERNAME  = itemList[0];
                _tut.PASSWORD  = itemList[1];
                _tut.ID        = itemList[2];
                _tut.FIRSTNAME = itemList[3];
                _tut.LASTNAME  = itemList[4];
                _tut.MAIL      = itemList[5];
                _tut.PHONE     = itemList[6];

                _tut.GENDER = (Gender)(Convert.ToInt32(itemList[7]));
                _tut.DEPT   = (Department)(Convert.ToInt32(itemList[8]));
                //-------------------------------------------------------------------------------------------//
                itemList = FetchList(TEmployee, "*", "id = " + _tut.ID);
                //-------------------------------------------------------------------------------------------//
                _tut.SALARY = Convert.ToSingle(itemList[1]);
                _tut.decrypt_courses(itemList[2]);
                _tut.DEGREE = (Degree)(Convert.ToInt32(itemList[3]));
                _tut.JOB    = (Job)(Convert.ToInt32(itemList[4]));

                _emp = _tut;
                break;

            case 3:     //lecturer
                Lecturer _lect = new Lecturer();

                _lect.USERNAME  = itemList[0];
                _lect.PASSWORD  = itemList[1];
                _lect.ID        = itemList[2];
                _lect.FIRSTNAME = itemList[3];
                _lect.LASTNAME  = itemList[4];
                _lect.MAIL      = itemList[5];
                _lect.PHONE     = itemList[6];

                _lect.GENDER = (Gender)(Convert.ToInt32(itemList[7]));
                _lect.DEPT   = (Department)(Convert.ToInt32(itemList[8]));
                //-------------------------------------------------------------------------------------------//
                itemList = FetchList(TEmployee, "*", "id = " + _lect.ID);
                //-------------------------------------------------------------------------------------------//
                _lect.SALARY = Convert.ToSingle(itemList[1]);
                _lect.decrypt_courses(itemList[2]);
                _lect.DEGREE = (Degree)(Convert.ToInt32(itemList[3]));
                _lect.JOB    = (Job)(Convert.ToInt32(itemList[4]));

                _emp = _lect;
                break;

            case 4:     //dept head
                HeadDept _hoad = new HeadDept();

                _hoad.USERNAME  = itemList[0];
                _hoad.PASSWORD  = itemList[1];
                _hoad.ID        = itemList[2];
                _hoad.FIRSTNAME = itemList[3];
                _hoad.LASTNAME  = itemList[4];
                _hoad.MAIL      = itemList[5];
                _hoad.PHONE     = itemList[6];

                _hoad.GENDER = (Gender)(Convert.ToInt32(itemList[7]));
                _hoad.DEPT   = (Department)(Convert.ToInt32(itemList[8]));
                //-------------------------------------------------------------------------------------------//
                itemList = FetchList(TEmployee, "*", "id = " + _hoad.ID);
                //-------------------------------------------------------------------------------------------//
                _hoad.SALARY = Convert.ToSingle(itemList[1]);
                _hoad.DEGREE = (Degree)(Convert.ToInt32(itemList[3]));
                _hoad.JOB    = (Job)(Convert.ToInt32(itemList[4]));

                _emp = _hoad;
                break;
            }

            return(_emp);
        }