private void BtnSTsave_Click(object sender, EventArgs e)
        {
            int affectedRows = 0;

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                groupp.Id = db.Groups.Where(g => g.Name == cbgroups.Text).FirstOrDefault().Id;



                //db.Tasks.Where(t => t.GroupId == groupp.Id).FirstOrDefault();
                Modelss.Task grpTask = new Modelss.Task();

                grpTask.Name     = txtTask.Text;
                grpTask.Deadline = Convert.ToDateTime(tdedline.Text);
                grpTask.GroupId  = groupp.Id;
                grpTask.Status   = true;
                db.Tasks.Add(grpTask);

                affectedRows = db.SaveChanges();
                txtTask.Text = tdedline.Text = cbgroups.Text = "";
            }
            if (affectedRows > 0)
            {
                MessageBox.Show("Submitted");
                return;
            }
            else
            {
                MessageBox.Show("Not Submitted !!");
                return;
            }
        }
Esempio n. 2
0
        private bool UpdateStudent()
        {
            int affectedRows = 0;

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                studentFounded.Id = Convert.ToInt32(dvgstudent.CurrentRow.Cells[0].Value);
                List <Modelss.Group> gr  = db.Groups.Where(g => g.Status == true).ToList();
                int             selected = cbStudentGroups.SelectedIndex;
                int             grId     = gr[selected].Id;
                Modelss.Student student  = db.Students.Where(s => s.Id == studentFounded.Id).FirstOrDefault();
                student.Name    = txtSName.Text;
                student.Surname = txtSSurname.Text;
                student.Email   = txtSEmail.Text;
                student.GroupId = grId;
                student.Phone   = txtSPhone.Text;
                student.Fee     = Convert.ToDouble(TxtSFee.Text);
                student.Status  = true;

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        private bool UpdateTeacher()
        {
            int affectedRows = 0;

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                int spId = (db.Educations.Where(a => a.Name == cbSpc.SelectedItem.ToString())).FirstOrDefault().Id;

                T.Id = Convert.ToInt32(dvgTeacherss.CurrentRow.Cells[0].Value);
                Modelss.Teacher Teachers = db.Teachers.Where(g => g.Id == T.Id).FirstOrDefault();

                Teachers.Name         = txtName.Text;
                Teachers.Surname      = txtSurname.Text;
                Teachers.Email        = txtEmail.Text;
                Teachers.Phone        = txtPhone.Text;
                Teachers.SpecialityID = spId;

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void Btnwrite_Click(object sender, EventArgs e)
        {
            if (btnwrite.Text == "Update")
            {
                if (!UpdateMark())
                {
                    MessageBox.Show("Not Submitted");
                    cbg.Text = txtMark.Text = "";

                    return;
                }
                MessageBox.Show("Submitted");
                FilldvgMarks();

                FilldvgAverage();
                btnwrite.Text = "Submit";
                cbg.Text      = txtMark.Text = "";
                return;
            }

            string sname    = dvgstudent2.CurrentRow.Cells[1].Value.ToString();
            string ssurname = dvgstudent2.CurrentRow.Cells[2].Value.ToString();
            int    id       = Convert.ToInt32(dvgstudent2.CurrentRow.Cells[0].Value);

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                Modelss.StudentsMark sm = new Modelss.StudentsMark();
                int taskid = Convert.ToInt32(db.Tasks.Where(t => t.Name == cbg.Text).FirstOrDefault().Id);

                sm.Mark = Convert.ToInt32(txtMark.Text);

                sm.StudentId = id;
                sm.TaskId    = taskid;
                db.StudentsMarks.Add(sm);
                db.SaveChanges();
            }
            FilldvgMarks();

            FilldvgAverage();
            txtMark.Text = cbg.Text = " ";
        }
Esempio n. 5
0
        private bool DeleteStudent()
        {
            int affectedRows = 0;

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                studentFounded.Id = Convert.ToInt32(dvgstudent.CurrentRow.Cells[0].Value);
                Modelss.Student st = db.Students.Where(s => s.Id == studentFounded.Id).FirstOrDefault();
                db.Students.Remove(st);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void Btnmark2_Click(object sender, EventArgs e)
        {
            int affectedRows = 0;

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                smm.Id = (int)dvgsmark2.CurrentRow.Cells[0].Value;
                Modelss.StudentsMark SM = db.StudentsMarks.Where(s => s.StudentId == smm.Id).FirstOrDefault();

                //validation only numbers
                String patternnum = "^[0-9]+(,[0-9]+)*$";
                Regex  mark       = new Regex(patternnum);
                Match  numMatch   = mark.Match(txtmark.Text);
                if (!numMatch.Success)
                {
                    MessageBox.Show("Yalniz ededler daxil edin");
                    txtmark.Text = "";
                    return;
                }
                SM.Mark      = Convert.ToInt32(txtmark.Text);
                SM.StudentId = (int)dvgsmark2.CurrentRow.Cells[0].Value;
                SM.TaskId    = (int)dvgsmark2.CurrentRow.Cells[1].Value;
                affectedRows = db.SaveChanges();
                //dvgsmark2.CurrentRow.Cells[5].Value = txtmark.Text;
                btnmark2.Enabled = false;
                txtmark.Text     = "";
                GenerateTasks();
            }
            if (affectedRows > 0)
            {
                MessageBox.Show("success");
                return;
            }
            else
            {
                MessageBox.Show("error");
                return;
            }
        }
Esempio n. 7
0
        private void BtnSTsave_Click(object sender, EventArgs e)
        {
            if (btnSdelete.Enabled)
            {
                if (!UpdateStudent())
                {
                    MessageBox.Show(" Not Submited");
                    return;
                }
                MessageBox.Show("  Submited");
                Refresh();


                return;
            }
            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                Modelss.Student      students = new Modelss.Student();
                List <Modelss.Group> gr       = db.Groups.ToList();
                int selected    = cbStudentGroups.SelectedIndex;
                int StudentGrId = gr[selected].Id;
                List <Modelss.Student> studentss = db.Students.ToList();

                dvgstudent.Rows.Add(ID, txtSName.Text, txtSSurname.Text, txtSEmail.Text, txtSPhone.Text, cbStudentGroups.Text, TxtSFee.Text);

                students.Name    = txtSName.Text;
                students.Surname = txtSSurname.Text;
                students.Email   = txtSEmail.Text;
                students.GroupId = StudentGrId;
                students.Phone   = txtSPhone.Text;
                students.Fee     = Convert.ToDouble(TxtSFee.Text);
                students.Status  = true;


                txtSName.Text = txtSSurname.Text = txtSEmail.Text = cbStudentGroups.Text = TxtSFee.Text = txtSPhone.Text = " ";
                db.Students.Add(students);
                db.SaveChanges();
            }
        }
Esempio n. 8
0
        private bool DeleteTeacher()
        {
            int affectedRows = 0;

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                T.Id = Convert.ToInt32(dvgTeacherss.CurrentRow.Cells[0].Value);
                Modelss.Teacher Teachers = db.Teachers.Where(g => g.Id == T.Id).FirstOrDefault();

                db.Teachers.Remove(Teachers);

                affectedRows = db.SaveChanges();
            }

            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool UpdateMark()
        {
            int affectedRows = 0;

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                studentMark.StudentId = Convert.ToInt32(dvgMarks.CurrentRow.Cells[1].Value);
                Modelss.StudentsMark studenmarks = db.StudentsMarks.Where(m => m.StudentId == studentMark.StudentId).FirstOrDefault();
                int taskid = Convert.ToInt32(db.Tasks.Where(t => t.Name == cbg.Text).FirstOrDefault().Id);
                studenmarks.Mark      = Convert.ToInt32(txtMark.Text);
                studenmarks.TaskId    = taskid;
                studenmarks.StudentId = Convert.ToInt32(dvgMarks.CurrentRow.Cells[1].Value);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 10
0
        private void BtnTsave_Click(object sender, EventArgs e)
        {
            if (btnTdelete.Enabled)
            {
                if (!UpdateTeacher())
                {
                    MessageBox.Show("Not Submited");
                    return;
                }
                MessageBox.Show("Submited");
                Refresh();

                return;
            }

            int affectedRow = 0;

            using (Modelss.AKADEMIYAEntities2 db = new Modelss.AKADEMIYAEntities2())
            {
                List <Modelss.Education> spcs     = db.Educations.Where(a => a.Status == true).ToList();
                List <Modelss.Teacher>   teachers = db.Teachers.Where(t => t.Status == true).ToList();

                Modelss.Teacher tt = new Modelss.Teacher();


                //validation Name
                string onlyLetters = @"^[a-zA-Z]+$";
                Regex  tname       = new Regex(onlyLetters);
                Match  tnameMatch  = tname.Match(txtName.Text);
                if (!tnameMatch.Success)
                {
                    MessageBox.Show("Adi duzgun Daxil edin");
                    txtName.Text = "";
                    return;
                }

                //validation Surname
                Regex tsurname      = new Regex(onlyLetters);
                Match tsurnameMatch = tsurname.Match(txtSurname.Text);
                if (!tsurnameMatch.Success)
                {
                    MessageBox.Show("Soyadi duzgun Daxil edin");
                    txtSurname.Text = "";
                    return;
                }
                string emailPattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";

                //email validation
                Regex mail      = new Regex(emailPattern);
                Match mailMatch = mail.Match(txtEmail.Text);
                if (!mailMatch.Success)
                {
                    MessageBox.Show("Emaili duzgin daxil edin...");
                    txtEmail.Text = "";
                    return;
                }
                //validation only numbers
                String patternnum = "^[0-9]+(,[0-9]+)*$";
                Regex  salry      = new Regex(patternnum);
                Match  numMatch   = salry.Match(slry.Text);
                if (!numMatch.Success)
                {
                    MessageBox.Show("Yalniz ededler daxil edin");
                    slry.Text = "";
                    return;
                }

                dvgTeacherss.Rows.Add(ID, txtName.Text, txtSurname.Text, cbSpc.Text, txtEmail.Text, txtPhone.Text);


                tt.Name    = txtName.Text;
                tt.Surname = txtSurname.Text;

                int selected = cbSpc.SelectedIndex;
                List <Modelss.Education> educations = db.Educations.ToList();
                int catID = educations[selected].Id;

                tt.SpecialityID = catID;

                tt.Email = txtEmail.Text;

                tt.Phone  = txtPhone.Text;
                tt.Salary = Convert.ToDouble(slry.Text);
                tt.Status = true;
                db.Teachers.Add(tt);
                txtName.Text = txtSurname.Text = cbSpc.Text = txtEmail.Text = txtPhone.Text = slry.Text = "";
                affectedRow  = db.SaveChanges();
                if (affectedRow > 0)
                {
                    MessageBox.Show("Melumat qeyde alindi");
                }
                else
                {
                    MessageBox.Show("xeta!!");
                }
            }
        }