示例#1
0
文件: ThemLop.cs 项目: ndhuy2711/QLHS
 private void btn_XacNhan_Click(object sender, EventArgs e)
 {
     btn_XacNhan.Visible = false;
     btn_them.Visible    = true;
     try
     {
         QLHS_BUS  bus = new QLHS_BUS();
         DataTable dt  = bus.ThamSo();
         string    t   = txt_siso.Text.ToString();
         if ((0 < Int32.Parse(t) && Int32.Parse(t) < Int32.Parse(dt.Rows[0]["SiSo"].ToString())))
         {
             QLHS_DTO hs = new QLHS_DTO();
             hs.MaLop     = txt_malop.Text;
             hs.TenLop    = txt_tenlop.Text;
             hs.SiSo      = txt_siso.Text;
             hs.MaKhoiLop = cb_Khoi_LopHoc.Text;
             bus.ThemLop(hs);
             MessageBox.Show("Thêm thành công lớp " + txt_malop.Text + " !", "Thông báo");
             LoadData();
             btn_capnhatlop.Enabled = true;
             btn_xoalop.Enabled     = true;
             btn_xeplop.Enabled     = true;
             txt_malop.Enabled      = false;
             txt_siso.Enabled       = false;
             txt_tenlop.Enabled     = false;
             cb_Khoi_LopHoc.Enabled = false;
             txt_tenlop.DataBindings.Clear();
             txt_tenlop.DataBindings.Add("Text", dtgv_themlop.DataSource, "TenLop");
             txt_siso.DataBindings.Clear();
             txt_siso.DataBindings.Add("Text", dtgv_themlop.DataSource, "SiSo");
             txt_malop.DataBindings.Clear();
             txt_malop.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaLop");
             cb_Khoi_LopHoc.DataBindings.Clear();
             cb_Khoi_LopHoc.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaKhoiLop");
         }
         else
         {
             MessageBox.Show("Sỉ số lớp sai quy định");
         }
     }
     catch
     {
         MessageBox.Show("Mời nhập lại đúng quy định!");
     }
 }
示例#2
0
        private void btn_hoanthanh_Click(object sender, EventArgs e)
        {
            QLHS_BUS  bus = new QLHS_BUS();
            int       nam = int.Parse(DateTime.Now.Year.ToString());
            int       dtp = int.Parse(dt_ngaysinh.Value.Year.ToString());
            int       t   = nam - dtp;
            DataTable dt  = bus.ThamSo();

            //MessageBox.Show(dt.Rows[0]["TuoiToiThieu"].ToString());
            //MessageBox.Show(dt.Rows[0]["TuoiToiDa"].ToString());
            try
            {
                if (Int32.Parse(dt.Rows[0]["TuoiToiThieu"].ToString()) < t && t < Int32.Parse(dt.Rows[0]["TuoiToiDa"].ToString()))
                {
                    if ((txt_hovaten.Text != "") && (dt_ngaysinh.Value.ToString() != "") && (cb_gioitinh.Text != "") && (txt_diachi.Text != "") && (txt_email.Text != ""))
                    {
                        QLHS_DTO hs = new QLHS_DTO();
                        hs.MaHocSinh = txt_mahocsinh.Text;
                        hs.HoTen     = txt_hovaten.Text;
                        hs.NgaySinh  = dt_ngaysinh.Value.ToString();
                        hs.GioiTinh  = cb_gioitinh.Text;
                        hs.DiaChi    = txt_diachi.Text;
                        hs.Email     = txt_email.Text;
                        bus.ThemHocSinh(hs);
                        MessageBox.Show("Thêm thành công học sinh " + txt_hovaten.Text + " !", "Thông báo");
                        LoadData();
                        bus.ThemCTDSLOP(hs);
                        btn_hoanthanh.Visible      = false;
                        btn_ThemHS.Visible         = true;
                        btn_capnhathocsinh.Visible = true;
                        txt_mahocsinh.Enabled      = false;
                        txt_hovaten.Enabled        = false;
                        txt_email.Enabled          = false;
                        txt_diachi.Enabled         = false;
                        cb_gioitinh.Enabled        = false;
                        dt_ngaysinh.Enabled        = false;
                        txt_hovaten.DataBindings.Clear();
                        txt_hovaten.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "HoTen");
                        txt_mahocsinh.DataBindings.Clear();
                        txt_mahocsinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "MaHocSinh");
                        txt_email.DataBindings.Clear();
                        txt_email.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "Email");
                        txt_diachi.DataBindings.Clear();
                        txt_diachi.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "DiaChi");
                        cb_gioitinh.DataBindings.Clear();
                        cb_gioitinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "GioiTinh");
                        dt_ngaysinh.DataBindings.Clear();
                        dt_ngaysinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "NgaySinh");
                    }
                    else
                    {
                        MessageBox.Show("Bạn chưa nhập đủ thông tin! Mời nhập lại!", "Cảnh báo");
                    }
                }
                else
                {
                    MessageBox.Show("Tuổi của học sinh chưa đúng quy định! Không thêm thành công", "Cảnh báo");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Mời nhập lại theo đúng quy định!");
            }
        }