예제 #1
0
        private void Add_mentor(object sender, EventArgs e)
        {
            if (this.Checking())
            {
                photo_name = DateTime.Now.ToString("ddMMyyyyssmmHH") + file_dialog.SafeFileName;
                int    gen_id = db.Genders.FirstOrDefault(g => g.gender_name == this.cmb_gender.Text).id;
                Mentor mentor = new Mentor();
                mentor.mentor_name      = txt_name.Text;
                mentor.mentor_surname   = txt_surname.Text;
                mentor.mentor_email     = txt_email.Text;
                mentor.mentor_info      = txt_info.Text;
                mentor.mentor_phone     = txt_phone.Text;
                mentor.mentor_photo     = photo_name;
                mentor.mentor_gender_id = gen_id;
                mentor.mentor_password  = Extentions.getHashCode(this.txt_password.Text);
                db.Mentors.Add(mentor);
                db.SaveChanges();
                this.Cleaner();

                WebClient webcilent = new WebClient();
                webcilent.DownloadFile(file_dialog.FileName, Extentions.uploads_path + photo_name);
                this.Cleaner();
            }
            else
            {
                this.lbl_error.Text = "Do not empty !!!";
            }
        }
예제 #2
0
        private void Add_student(object sender, EventArgs e)
        {
            string photo    = DateTime.Now.ToString("ddMMyyyyHHssmm") + file.SafeFileName;
            int    gen_id   = db.Genders.First(g => g.gender_name == this.cmb_gender.Text).id;
            int    group_id = db.Groups.First(g => g.group_name == this.cmb_group.Text).id;

            db.Students.Add(new Student()
            {
                student_name           = this.txt_name.Text,
                student_surname        = this.txt_surname.Text,
                student_email          = this.txt_email.Text,
                student_phone          = this.txt_phone.Text,
                student_github_account = this.txt_account.Text,
                student_info           = this.txt_info.Text,
                student_photo          = photo,
                student_cap_point      = this.txt_cap_point.Text == "" ? 0 : Convert.ToDouble(this.txt_cap_point.Text),
                student_group_id       = group_id,
                student_gender_id      = gen_id,
                student_password       = Extentions.getHashCode(this.txt_password.Text)
            });
            db.SaveChanges();
            this.CLeaner();

            WebClient webclient = new WebClient();

            webclient.DownloadFile(file.FileName, Extentions.uploads_path + photo);
        }
예제 #3
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            string  photo   = DateTime.Now.ToString("ddMMyyyyHHssmm") + file.SafeFileName;
            Teacher teacher = new Teacher();

            teacher.teacher_name    = txt_name.Text;
            teacher.teacher_surname = txt_surname.Text;
            teacher.teacher_phone   = txt_phone.Text;
            teacher.teacher_email   = textBox3.Text;
            teacher.teacher_info    = txt_info.Text;
            int gender_id = db.Genders.Where(t => t.gender_name == this.txt_gender.Text).First().id;

            teacher.teacher_gender_id = gender_id;
            teacher.teacher_password  = Extentions.getHashCode(txt_password.Text);
            teacher.teacher_photo     = photo;

            db.Teachers.Add(teacher);
            db.SaveChanges();
            fillTeacherData();
            cleareliyan();


            WebClient webclient = new WebClient();

            webclient.DownloadFile(file.FileName, Extentions.uploads_path + photo);
        }
예제 #4
0
        private void Settings(object sender, EventArgs e)
        {
            string password = Interaction.InputBox("Enter your password", "Confirem password");

            if (mentor != null)
            {
                Mentor mtr = db.Mentors.Find(mentor.id);
                if (mtr.mentor_password == Extentions.getHashCode(password))
                {
                    this.group.Visible     = true;
                    this.txt_mail.Text     = mtr.mentor_email;
                    this.txt_password.Text = password;
                    this.lbl_error.Text    = "";
                }
                else
                {
                    this.lbl_error.Text = "Password incorrect";
                }
            }
            else if (teacher != null)
            {
                Teacher tchr = db.Teachers.Find(teacher.id);
                if (tchr.teacher_password == Extentions.getHashCode(password))
                {
                    this.group.Visible     = true;
                    this.txt_mail.Text     = tchr.teacher_email;
                    this.txt_password.Text = password;
                    this.lbl_error.Text    = "";
                }
                else
                {
                    this.lbl_error.Text = "Password incorrect";
                }
            }
        }
        private void btn_export_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "Excel Documents (*.xls)|*.xls";
            sfd.FileName = "export.xls";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                Extentions.Export_data(this.dgw_student, sfd.FileName);
            }
        }
        private void btn_save_Click(object sender, EventArgs e)
        {
            Student stu = db.Students.Find(selectedStu.id);

            stu.student_email    = this.txt_email.Text;
            stu.student_password = Extentions.getHashCode(this.txt_password.Text);
            db.SaveChanges();
            this.lbl_email.Text        = stu.student_email;
            this.setting_group.Visible = false;
            this.txt_password.Text     = "";
            this.txt_email.Text        = "";
        }
        private void Update(object sender, EventArgs e)
        {
            Student stu = db.Students.Find(selectedStu.id);

            password = Interaction.InputBox("Enter your old password");

            if (stu.student_password == Extentions.getHashCode(password))
            {
                this.txt_email.Text        = stu.student_email;
                this.txt_password.Text     = password;
                this.lbl_error.Text        = "";
                this.setting_group.Visible = true;
            }
            else
            {
                this.lbl_error.Text = "Password incorrect";
            }
        }
예제 #8
0
 private void Update(object sender, EventArgs e)
 {
     if (mentor != null)
     {
         mentor.mentor_email    = this.txt_mail.Text;
         mentor.mentor_password = Extentions.getHashCode(this.txt_password.Text);
         db.SaveChanges();
         this.group.Visible  = false;
         mentor              = db.Mentors.Find(Convert.ToInt32(this.id));
         this.lbl_email.Text = mentor.mentor_email;
     }
     else if (teacher != null)
     {
         teacher.teacher_email    = this.txt_mail.Text;
         teacher.teacher_password = Extentions.getHashCode(this.txt_password.Text);
         db.SaveChanges();
         this.group.Visible  = false;
         teacher             = db.Teachers.Find(Convert.ToInt32(this.id));
         this.lbl_email.Text = teacher.teacher_email;
     }
 }
예제 #9
0
        private void Update(object sender, EventArgs e)
        {
            if (mentor != null)
            {
                Mentor mtr = db.Mentors.Find(mentor.id);

                mtr.mentor_email    = this.txt_mail.Text;
                mtr.mentor_password = Extentions.getHashCode(this.txt_password.Text);
                db.SaveChanges();
                this.group.Visible  = false;
                this.lbl_email.Text = mtr.mentor_email;
            }
            else if (teacher != null)
            {
                Teacher tchr = db.Teachers.Find(teacher.id);

                tchr.teacher_email    = this.txt_mail.Text;
                tchr.teacher_password = Extentions.getHashCode(this.txt_password.Text);
                db.SaveChanges();
                this.group.Visible  = false;
                this.lbl_email.Text = tchr.teacher_email;
            }
        }