Exemplo n.º 1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_username">用户名</param>
        /// <param name="_userid">用户学号</param>
        /// <param name="_password">用户密码</param>
        /// <param name="_school">用户学院,可以为空</param>
        /// <param name="_usertype">用户类别,默认Guest</param>
        internal ClassUser(string _username, string _userid, string _password, string _school, USERTYPE _usertype)
        {
            Username = _username;
            Userid   = _userid;
            Password = _password;
            School   = _school;
            Usertype = _usertype;
            Credit   = 100;
            Currentborrowedamount = 0;
            Currentscheduleamount = 0;


            registerDate = ClassTime.systemTime;
            if (usertype == USERTYPE.Guest)
            {
                Currentmaxborrowableamount = Maxborrowableamount = 0;
            }
            else if (usertype == USERTYPE.Student)
            {
                Currentmaxborrowableamount = Maxborrowableamount = 10;
            }
            else if (usertype == USERTYPE.Lecturer)
            {
                Currentmaxborrowableamount = Maxborrowableamount = 20;
            }

            if (!File.Exists(ClassBackEnd.UserCerditDictory + Userid + @".cre"))
            {
                (File.Create(ClassBackEnd.UserCerditDictory + Userid + @".cre")).Close();
            }
        }
Exemplo n.º 2
0
        private void RegistButton_Click(object sender, EventArgs e)
        {
            if (IDAlertLabel.Visible == true || PWD1AlertLabel.Visible == true || PWD2AlertLabel.Visible == true)
            {
                MessageBox ib = new MessageBox(10);
                ib.ShowDialog();
                ib.Dispose();
                return;
            }
            USERTYPE type = USERTYPE.Guest;

            if (StudentCheckBox.Checked == true)
            {
                type = USERTYPE.Student;
            }
            else if (TeacherCheckBox.Checked == true)
            {
                type = USERTYPE.Lecturer;
            }

            if (type == USERTYPE.Guest)
            {
                MessageBox ib = new MessageBox(6);
                ib.ShowDialog();
                ib.Dispose();
                return;
            }
            var v = ClassBackEnd.Register(IDTextBox.Text, UserTextBox.Text, PasswordTextBox1.Text, type, AcademicTextBox.Text);

            if (v == 1)//success
            {
                MessageBox ib = new MessageBox(4);
                ib.ShowDialog();
                ib.Dispose();
                Close();
            }
            else if (v == 2)//id error
            {
                MessageBox ib = new MessageBox(7);
                ib.ShowDialog();
                ib.Dispose();
            }
            else if (v == 3)//username error
            {
                MessageBox ib = new MessageBox(8);
                ib.ShowDialog();
                ib.Dispose();
            }
            else if (v == 4)//unknown error
            {
                MessageBox ib = new MessageBox(9);
                ib.ShowDialog();
                ib.Dispose();
            }
        }
        public IHttpActionResult GetAddUserTypeById(string AddUserTypeID)
        {
            db.Configuration.ProxyCreationEnabled = false;

            USERTYPE objEmp = new USERTYPE();
            int      ID     = Convert.ToInt32(AddUserTypeID);

            try
            {
                objEmp = db.USERTYPEs.Find(ID);
                if (objEmp == null)
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(Ok(objEmp));
        }
Exemplo n.º 4
0
        public IHttpActionResult DeleteOwner(int id)
        {
            INF370Entities db = new INF370Entities();

            db.Configuration.ProxyCreationEnabled = false;

            try
            {
                USERTYPE employeeTypeDetails = db.USERTYPEs.Find(id);
                if (employeeTypeDetails == null)
                {
                    return(NotFound());
                }

                db.USERTYPEs.Remove(employeeTypeDetails);
                db.SaveChanges();
                return(Ok(employeeTypeDetails));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        public IHttpActionResult PutOwnerMaster(USERTYPE AddUserType)
        {
            db.Configuration.ProxyCreationEnabled = false;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                USERTYPE objEmp = new USERTYPE();
                objEmp = db.USERTYPEs.Find(AddUserType.USERTYPEID);
                if (objEmp != null)
                {
                    objEmp.USERTYPEDESCRIPTION = AddUserType.USERTYPEDESCRIPTION;
                }
                int i = this.db.SaveChanges();
            }
            catch (Exception)
            {
                return(null);
            }
            return(Ok(AddUserType));
        }
Exemplo n.º 6
0
        public IHttpActionResult PostOwner(USERTYPE data)
        {
            INF370Entities db = new INF370Entities();

            db.Configuration.ProxyCreationEnabled = false;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                db.USERTYPEs.Add(data);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(null);
            }



            return(Ok(data));
        }