private void Add_bt_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Add_Students add       = new Add_Students();
            Students     student   = new Students();
            int          Id        = Convert.ToInt32(ID_student.Text);
            string       firstname = this.Firstname.Text;
            string       lastname  = this.Lastname.Text;
            DateTime     birthday  = Birthday_picker.DateTime;
            string       phone     = this.Phone_student.Text;
            string       address   = this.Address_student.Text;
            string       gender    = "Female";

            if (Check_male.Checked == true)
            {
                Check_female.Checked = false;
                gender = "Male";
            }

            MemoryStream pic = new MemoryStream();

            //int born_year = Convert.ToInt32(Birthday_picker.ToString());
            //int this_year = DateTime.Now.Year;
            //if (this_year - born_year < 10 || this_year - born_year > 100)
            //{
            //    MessageBox.Show("The student age must be 10 to 100 year", "Invalid Birthday", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            if (!add.Check())
            {
                Picture_Student.Image.Save(pic, Picture_Student.Image.RawFormat);
                if (student.AddStudent(Id, firstname, lastname, birthday, gender, address, phone, pic))
                {
                    MessageBox.Show("New student added", "Add student", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Error", "Add student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Empty fields", "Add student", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 2
0
        private void M010401_ItemClick(object sender, ItemClickEventArgs e)
        {
            Add_Students add = new Add_Students();

            add.Show();
        }