コード例 #1
0
        private void Btn_Update_Click(object sender, EventArgs e)
        {
            if (txt_Search.Text == "" | txt_Name_Initial.Text == "" | txt_Full_Name.Text == "" | txt_Address.Text == "" | txt_School.Text == "" | txt_Contact_No.Text == "" | Dropdown_Gender.SelectedIndex == 0 | Dropdown_Grade.SelectedIndex == 0 | Dropdown_Medium.SelectedIndex == 0)
            {
                MessageBox.Show("Please Enter Required Details");
            }
            else
            {
                CLASS_STUDENT Student = new CLASS_STUDENT();

                int ID = Convert.ToInt32(txt_Search.Text);
                Student.Name_Intial = txt_Name_Initial.Text;
                Student.Full_Name   = txt_Full_Name.Text;
                Student.Address     = txt_Address.Text;
                Student.School      = txt_School.Text;
                Student.Contact_No  = txt_Contact_No.Text;
                Student.Email       = txt_Email.Text;
                Student.Gender      = Dropdown_Gender.Text;
                Student.Grade       = Dropdown_Grade.Text;
                Student.Medium      = Dropdown_Medium.Text;

                Student.Update(ID); // Update Method Method
                ClearFields();      // to clear fields
            }
        }
コード例 #2
0
        public bool Class_student(int id_student, int id_class)
        {
            if (Exit_idstudent(id_student))
            {
                for (int i = 1; i <= 12; i++)
                {
                    CLASS_STUDENT add_class = new CLASS_STUDENT();
                    add_class.IDClass   = id_class;
                    add_class.IDStudent = id_student;
                    add_class.Session   = i;
                    add_class.Day       = null;
                    add_class.State     = 0;
                    db.CLASS_STUDENT.Add(add_class);
                    db.SaveChanges();

                    var bien = db.CLASSes.Find(id_class);
                    if (bien != null)
                    {
                        bien.Number = bien.Number + 1;
                        db.SaveChanges();
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public bool Delete_Student(int id)
        {
            var bien = db.STUDENTs.Find(id);

            if (bien != null)
            {
                CLASS_STUDENT bien1 = db.CLASS_STUDENT.Where(x => x.IDStudent == id).SingleOrDefault();
                if (bien1 != null)
                {
                    db.CLASS_STUDENT.Remove(bien1);
                    db.SaveChanges();
                    db.STUDENTs.Remove(bien);
                    db.SaveChanges();
                    return(true);
                }
                else
                {
                    db.STUDENTs.Remove(bien);
                    db.SaveChanges();
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
 public ActionResult Update(CLASS_STUDENT model)
 {
     if (dao1.Update(model))
     {
         TempData["msg"] = "<script>alert('Update thành công');</script>";
     }
     else
     {
         TempData["msg"] = "<script>alert('Update không thành công');</script>";
     }
     return(Xem_Diemdanh(model.IDClass));
 }
コード例 #5
0
ファイル: DAO_Class_Student.cs プロジェクト: Ngothihong/Veso1
        public bool Update(CLASS_STUDENT model)
        {
            var bien = (from a in db.CLASS_STUDENT
                        where a.IDClass == model.IDClass && a.IDStudent == model.IDStudent && a.Session == model.Session
                        select a).SingleOrDefault();

            if (bien != null)
            {
                bien.State = model.State;
                db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
        private void Btn_Search_Click(object sender, EventArgs e)
        {
            try
            {
                int ID = Convert.ToInt32(txt_Search.Text);

                CLASS_STUDENT Student = new CLASS_STUDENT();
                Student.Search(ID);

                txt_Name_Initial.Text = Student.Name_Intial;
                txt_Full_Name.Text    = Student.Full_Name;
                txt_Address.Text      = Student.Address;
                txt_School.Text       = Student.School;
                txt_Contact_No.Text   = Student.Contact_No;
                txt_Email.Text        = Student.Email;
                Dropdown_Gender.Text  = Student.Gender;
                Dropdown_Grade.Text   = Student.Grade;
                Dropdown_Medium.Text  = Student.Medium;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #7
0
        private void Btn_Remove_Click(object sender, EventArgs e)
        {
            if (txt_Search.Text == "")
            {
                MessageBox.Show("Please Enter Student Id");
            }
            else
            {
                DialogResult dr = MessageBox.Show("Do you want to Remove this User?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (dr == DialogResult.Yes)
                {
                    int ID = Convert.ToInt32(txt_Search.Text);

                    CLASS_STUDENT Student = new CLASS_STUDENT();
                    Student.Delete(ID); // Update Method Method
                    ClearFields();      // to clear fields
                }
                else
                {
                    ClearFields();
                }
            }
        }