Esempio n. 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            int mssv;

            // add new SV
            if (MSSV == -1)
            {
                mssv = CSDL_OOP.GenAutoId();
            }
            else
            {
                // edit SV
                mssv = this.MSSV;
            }

            string   ten      = this.txtTen.Text.Trim();
            bool     gioiTinh = this.rbNam.Checked;
            DateTime ngaySinh = this.dtpNgaySinh.Value;
            int      idLop    = Convert.ToInt32(((MapCbbTenLopSH)this.cbbLopSH.SelectedItem).idLopSH);

            // validate
            if (ten == "" || ten == null)
            {
                MessageBox.Show("Ten khong duoc de trong");
                return;
            }

            // create new instance
            SV sv = new SV(mssv, ten, gioiTinh, ngaySinh, idLop);

            // save or update
            CSDL_OOP.Instance.SaveSV(sv);

            // reload form 1
            this.ReloadForm1();

            this.Dispose();
        }
Esempio n. 2
0
        private void Show(int idLopSH, string searchText = "", int sortBy = -1)
        {
            List <SV> tmpList = CSDL_OOP.Instance.FindSVsByLopSHId(idLopSH);
            List <SV> result  = new List <SV>();

            foreach (SV sv in tmpList)
            {
                if (sv.Ten.StartsWith(searchText))
                {
                    result.Add(sv);
                }
            }

            if (sortBy == 0)
            {
                result = CSDL_OOP.SortBy(CSDL_OOP.CompareMSSVDESC, result);
            }
            else if (sortBy == 1)
            {
                result = CSDL_OOP.SortBy(CSDL_OOP.CompareTenDESC, result);
            }

            this.dgvDSSV.DataSource = result;
        }