Example #1
0
        void Edit(SV a)
        {
            DataGridViewRow row = dtgvSV.CurrentRow;
            SV i = new SV();

            i = CellClick(row);
            if (a.MSSV == i.MSSV && CSDL_OOP.Instance.AddNewSV(a, false))
            {
                dtgvSV.DataSource = null;
                dtgvSV.DataSource = ListSV;
                MessageBox.Show("Edit Successfully");
            }
            else
            {
                MessageBox.Show("Error Edit");
            }
        }
Example #2
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = dtgvSV.CurrentRow;

            if (row != null)
            {
                SV a = new SV();
                a = CellClick(row);
                DialogResult result = MessageBox.Show("Bạn có muốn xóa SV này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    dtgvSV.DataSource = null;
                    CSDL_OOP.Instance.DeleteSV(a);
                    dtgvSV.DataSource = ListSV;
                    MessageBox.Show("Delete Successfully");
                }
            }
        }
Example #3
0
        public SV GetSV(DataRow row)
        {
            SV        a  = new SV();
            DataTable dt = CSDL.Instance.DTSV;

            foreach (DataRow item in dt.Rows)
            {
                if (row == item)
                {
                    a.MSSV   = item["MSSV"].ToString();
                    a.NameSV = item["NameSV"].ToString();
                    a.Gender = Convert.ToBoolean(item["Gender"]);
                    a.NS     = Convert.ToDateTime(item["NS"]);
                    a.ID_Lop = (int)(item["ID_Lop"]);
                }
            }
            return(a);
        }
Example #4
0
 public bool AddNewSV(SV sv, bool isAdd)
 {
     if (isAdd)
     {
         if (checkMSSV(sv.MSSV))
         {
             CSDL.Instance.AddNewRow(sv);
             Instance.GetAllSV();
             return(true);
         }
         return(false);
     }
     else
     {
         CSDL.Instance.EditRow(sv);
         Instance.GetAllSV();
         return(true);
     }
 }
Example #5
0
        public List <SV> GetListSV(int ID_Lop)
        {
            List <SV> s  = new List <SV>();
            DataTable dt = CSDL.Instance.DTSV;

            foreach (DataRow item in dt.Rows)
            {
                if ((int)item["ID_Lop"] == ID_Lop)
                {
                    SV a = new SV();
                    a.MSSV   = item["MSSV"].ToString();
                    a.NameSV = item["NameSV"].ToString();
                    a.Gender = Convert.ToBoolean(item["Gender"]);
                    a.NS     = Convert.ToDateTime(item["NS"]);
                    a.ID_Lop = (int)(item["ID_Lop"]);
                    s.Add(a);
                }
            }
            return(s);
        }
Example #6
0
 public List <SV> GetAllSV()
 {
     if (ListSV != null)
     {
         ListSV.Clear();
     }
     else
     {
         ListSV = new List <SV>();
     }
     foreach (DataRow item in CSDL.Instance.DTSV.Rows)
     {
         SV s = new SV();
         s.MSSV   = item["MSSV"].ToString();
         s.NameSV = item["NameSV"].ToString();
         s.NS     = Convert.ToDateTime(item["NS"]);
         s.Gender = Convert.ToBoolean(item["Gender"]);
         s.ID_Lop = (int)(item["ID_Lop"]);
         ListSV.Add(s);
     }
     return(ListSV);
 }
Example #7
0
 public void DeleteSV(SV sv)
 {
     CSDL.Instance.DeleteRow(sv);
     Instance.GetAllSV();
 }