Example #1
0
        public Student getStudent(String Conditions)
        {
            List <String> itemList = new List <String>();
            Student       _stud    = new Student();

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

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

            _stud.GENDER = (Gender)(Convert.ToInt32(itemList[7]));
            _stud.DEPT   = (Department)(Convert.ToInt32(itemList[8]));

            //-------------------------------------------------------------------------------------------//
            itemList = FetchList(TStudent, "*", "id = " + _stud.ID);
            //-------------------------------------------------------------------------------------------//
            _stud.AVERAGE = Convert.ToSingle(itemList[1]);
            _stud.STATE   = Convert.ToBoolean(itemList[2]);
            _stud.decrypt_books(itemList[3]);
            _stud.decrypt_courses(itemList[4]);
            _stud.decrypt_grades(itemList[5]);
            _stud.YEAR     = (Year)(Convert.ToInt32(itemList[6]));
            _stud.SEMESTER = (Semester)(Convert.ToInt32(itemList[7]));
            return(_stud);
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <String> bnums = new List <String>();
            Boolean       copies_flag = false, ownership_flag = false;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value) == true)
                {
                    if (Convert.ToInt32(dt.Rows[i].ItemArray[3].ToString()) > 0)
                    {
                        foreach (Book value in user.BOOKS)
                        {
                            if (value.BNUM == Convert.ToInt32(dt.Rows[i].ItemArray[0]))
                            {
                                ownership_flag = true;
                            }
                        }
                        bnums.Add(dt.Rows[i].ItemArray[0].ToString());
                    }
                    else
                    {
                        copies_flag = true;
                    }
                }
            }

            if (copies_flag == true)
            {
                MessageBox.Show("One or more of the selected books is not in stock!", "Message");
                return;
            }

            if (ownership_flag == true)
            {
                MessageBox.Show("You already have one or more of the selected books!", "Message");
                return;
            }


            int num;

            dataGridView1.Columns[4].ReadOnly = false;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (bnums.Contains(dt.Rows[i].ItemArray[0].ToString()))
                {
                    num = Convert.ToInt32(dt.Rows[i].ItemArray[3].ToString()) - 1;
                    dataGridView1.Rows[i].Cells[4].Value = num;
                    dt.Rows[i].ItemArray[3] = num;
                }
            }
            dataGridView1.Columns[4].ReadOnly = true;
            dt = db.UpdateTable(db.TLIBRARY, "Book_Number, Book_Count", "Department = 0 OR Department = " + (int)user.DEPT, dt);

            foreach (Book value in user.BOOKS)
            {
                bnums.Add(value.BNUM.ToString());
            }

            String book_code = user.encrypt_books(bnums);

            db.SimpleUpdate(db.TSTUDENT, "Books = '" + book_code + "'", "id = " + user.ID);
            user.decrypt_books(book_code);

            MessageBox.Show("You have successfully taken all the selected books!", "Message");

            foreach (DataGridViewRow value in dataGridView1.Rows)
            {
                DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)value.Cells[0];
                chk.Value = false;
            }
        }