private void frmDSHocSinh_Lop_Load(object sender, EventArgs e)
        {
            if (this.KhoiLopController == null)
            {
                this.KhoiLopController = new KhoiLopController();
            }

            if (this.LopController == null)
            {
                this.LopController = new LopController();
            }

            if (this.NamHocController == null)
            {
                this.NamHocController = new NamHocController();
            }

            if (this.PhanLopController == null)
            {
                this.PhanLopController = new PhanLopController();
            }

            this.KhoiLopController.HienThiCombobox(this.cmbKhoiLop);
            this.NamHocController.HienThiCombobox(this.cmbChonNam);
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmbHocKy_SelectedIndexChanged(object sender, EventArgs e)
 {
     if ((this.cmbHocKy.SelectedIndex != -1) && (this.lvDSLopHoc.SelectedItems.Count > 0))
     {
         PhanLopInfo phanLop = new PhanLopController().LayTuMa(((DataRow)((object[])this.lvDSLopHoc.SelectedItems[0].Tag)[1])["MaHocSinhLop"].ToString());
         MonHocInfo  monHoc  = new MonHocController().LayTuMa(((DataRowView)this.cmbMonHoc.SelectedItem).Row.ItemArray[2].ToString());
         HocKyInfo   hocKy   = new HocKyController().LayTuMa(((DataRowView)this.cmbHocKy.SelectedItem).Row.ItemArray[0].ToString());
         this.DiemController.HienThiDS(this.dgvDSDiem, this.bnDSDiem, phanLop, monHoc, hocKy);
     }
     else
     {
         this.DiemController.Data.DataService.Clear();
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btLuu_Click(object sender, EventArgs e)
        {
            //Dua con tro de bindingNavigatorPositionItem
            this.bindingNavigatorPositionItem.Focus();
            //Bind de dong cuoi de cap nhat thong tin tren DataGridView
            this.bnDS.BindingSource.Position = int.Parse(this.bindingNavigatorPositionItem.Text);
            //Neu luu thanh cong
            if (!this.Controller.Update())
            {
                if (MessageBox.Show("Không thể lưu!\nBạn cần nhập đầy đủ thông tin trước khi lưu lại!\nBạn có muốn tiếp tục không?", "Lưu Học sinh", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
                {
                    this.Controller.Data.LayDS();

                    this.btThemMoi.Enabled = true;
                    this.btXoa.Enabled     = true;
                    this.btBoQua.Enabled   = false;
                    this.btLuu.Enabled     = false;

                    this.itThemMoi.Enabled = true;
                    this.itXoa.Enabled     = true;
                    this.itBoQua.Enabled   = false;
                    this.itLuu.Enabled     = false;
                }
            }
            else
            {
                //Neu trang thai la Them, them hoc sinh vao phan lop.
                if (this.IsThem)
                {
                    //Luu Hoc sinh vao phan lop
                    PhanLopController phanLopCtrl = new PhanLopController();
                    PhanLopInfo       phanLopInfo = new PhanLopInfo();
                    phanLopInfo.MaHocSinhLop = PhanLopController.PhatSinhMa(this.LopInfo.MaLop);
                    phanLopInfo.MaLop        = this.LopInfo.MaLop;
                    phanLopInfo.MaHocSinh    = ((DataRowView)this.bnDS.BindingSource.Current)["MaHocSinh"].ToString();
                    phanLopCtrl.ThemPhanLop(phanLopInfo);
                    this.IsThem = false;
                }

                this.btThemMoi.Enabled = true;
                this.btXoa.Enabled     = true;
                this.btBoQua.Enabled   = false;
                this.btLuu.Enabled     = false;

                this.itThemMoi.Enabled = true;
                this.itXoa.Enabled     = true;
                this.itBoQua.Enabled   = false;
                this.itLuu.Enabled     = false;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public String PhatSinhMa()
        {
            PhanLopController phanLopCtrl = new PhanLopController();
            string            lastID      = "";
            int    numOfLastID;
            string id    = "H";
            string maLop = ((DataRowView)this.cmbLopCu.SelectedItem).Row.ItemArray[0].ToString();

            if (this.PhanLopControllerMoi.Data.DataService.Rows.Count > 0)
            {
                lastID = this.PhanLopControllerMoi.Data.DataService.Rows[this.PhanLopControllerMoi.Data.DataService.Rows.Count - 1]["MaHocSinhLop"].ToString();
            }
            else
            {
                lastID = this.PhanLopControllerMoi.LayMaCuoi(maLop);
            }

            if (lastID == "")
            {
                numOfLastID = 1;
                id          = id + maLop.Substring(1, maLop.Length - 1);
                int n = 13 - id.Length - 2;
                for (int i = 0; i < n; i++)
                {
                    id += "0";
                }
                id = id + (100 + numOfLastID).ToString().Substring(1, 2);
                return(id);
            }
            else
            {
                numOfLastID = int.Parse(lastID.Substring(11, 2));
                numOfLastID++;
                id = id + maLop.Substring(1, maLop.Length - 1);
                int n = lastID.Length - id.Length - 2;
                for (int i = 0; i < n; i++)
                {
                    id += "0";
                }
                id = id + (100 + numOfLastID).ToString().Substring(1, 2);
                return(id);
            }
        }