Exemple #1
0
        public void Hienthi()
        {
            lstHS = HocSinhController.getAllDataHS();
            DataTable dt = ViewHelper.ToDataTable <HocSinh>(lstHS);

            dtgHocSinh.DataSource = dt;
            dtgHocSinh.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dt.Columns["MaHS"].ColumnName             = "Mã HS";
            dt.Columns["HoTen"].ColumnName            = "Họ Tên";
            dt.Columns["NgaySinh"].ColumnName         = "Ngày Sinh";
            dt.Columns["DiaChi"].ColumnName           = "Địa Chỉ";
            dt.Columns["GioiTinh"].ColumnName         = "Giới Tính (Nữ/nam ✓)";
            dt.Columns["Sdt"].ColumnName         = "SĐT";
            dt.Columns["TenPhuHuynh"].ColumnName = "Tên Phụ Huynh";
            dt.Columns["SDTphuHuynh"].ColumnName = "SDT Phụ Huynh";
            dt.Columns["TenLop"].ColumnName      = "Mã Lớp";
            int i = 0;

            foreach (DataGridViewColumn col in dtgHocSinh.Columns)
            {
                col.HeaderCell.Style.Alignment     = DataGridViewContentAlignment.MiddleCenter;
                col.HeaderCell.Style.Font          = new Font("Arial", 12F, FontStyle.Bold, GraphicsUnit.Pixel);
                dtgHocSinh.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                i++;
            }
            try { dtgHocSinh.CurrentCell = dtgHocSinh[CurCl, CurR]; } catch { }
            dtgHocSinh.Refresh();
        }
Exemple #2
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (IDmember != null)
     {
         if (IDmember == "HSDEL")
         {
             MessageBox.Show("Không thể xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         if (MessageBox.Show("Bạn có muốn xóa dữ liệu đã chọn", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             if (HocSinhController.XoaHS(IDmember))
             {
                 MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Hienthi();
                 IDmember = null;
             }
             else
             {
                 MessageBox.Show("Xóa Không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Vui lòng chọn 1 Bản ghi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #3
0
        public frmHocSinh()
        {
            InitializeComponent();
            var dg = new HocSinhController();

            loadcbb();
            ShowView(dg.DetailView());
            IsAdmin(ConstantCommon.QUYEN);
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtFind.Text.Length > 0)
            {
                HocSinhController drc = new HocSinhController();
                var li = drc.FindByNameView(txtFind.Text);
                if (li.Count <= 0)
                {
                    MessageBox.Show("Không tìm thấy.");
                    return;
                }

                ShowView(li);
            }
        }
Exemple #5
0
        public frmThaoTacHS(string _MaHS, string _HoTen, string _DiaChi, bool _GioiTinh, string _Sdt, DateTime _NgaySinh, string _TenPhuHuynh, string _SDTphuHuynh, string _TenLop, int state)
        {
            InitializeComponent();
            _state = state;
            lstHS  = HocSinhController.getAllDataHS();
            if (state == 2)
            {
                txtID.Enabled = false;
            }
            txtID.Text     = _MaHS;
            txtTen.Text    = _HoTen;
            txtDiaChi.Text = _DiaChi;
            if (_GioiTinh)
            {
                radNam.Checked = true;
            }
            else
            {
                radNu.Checked = true;
            }
            dateNgaySinh.Value  = _NgaySinh;
            txtSDT.Text         = _Sdt;
            txtTenPhuHuynh.Text = _TenPhuHuynh;
            txtSDTphuHuynh.Text = _SDTphuHuynh;

            ///Thao tac ma lop
            ///1. Get all ma lop
            ///
            using (var db = setupConection.ConnectionFactory())
            {
                if (db.State == ConnectionState.Closed)
                {
                    db.Open();
                }
                List <Lop> list = db.Query <Lop>("SELECT MaLop,TenLop FROM dbo.Lop").ToList();
                for (int i = 0; i < list.Count; i++)
                {
                    ComboboxItem item = new ComboboxItem();
                    item.Text  = list[i].TenLop.ToString();
                    item.Value = list[i].MaLop.ToString();
                    cbClass.Items.Add(item);
                    if (_TenLop == list[i].TenLop)
                    {
                        cbClass.SelectedIndex = i;
                    }
                }
            }
        }
Exemple #6
0
        private void btnDelDoctor_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Chắc chắn muốn bản ghi không?", "Xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                long id     = Convert.ToInt64(txtIDHocSinh.Text);
                var  entity = new HocSinhController();
                if (entity.Del(id))
                {
                    ShowView(entity.DetailView());
                }
                else
                {
                    MessageBox.Show("Lỗi");
                }
            }
        }
Exemple #7
0
        private void btnSaveDoctor_Click(object sender, EventArgs e)
        {
            if (Them_bool == true && Sua_bool == false)
            {
                var entity = new HocSinh();
                entity.TenHS    = txtTenHocSinh.Text;
                entity.GioiTinh = cbbGenderHocSinh.Text == "Nam" ? true : false;
                entity.NgaySinh = dtpDateHocSinh.Value;
                entity.Lophc    = Convert.ToInt64(cbbLopHocSinh.SelectedValue);

                var  dg  = new HocSinhController();
                long ijk = dg.Add(entity);
                if (ijk > 0)
                {
                    ShowView(dg.DetailView());
                }
                else
                {
                    MessageBox.Show("Thêm bản ghi không thành công");
                }
                add(false);
            }
            ///sua hoc sinh
            if (Them_bool == false && Sua_bool == true)
            {
                var entity = new HocSinh();
                entity.ID       = Convert.ToInt32(txtIDHocSinh.Text);
                entity.TenHS    = txtTenHocSinh.Text;
                entity.GioiTinh = cbbGenderHocSinh.Text == "Nam" ? true : false;
                entity.NgaySinh = dtpDateHocSinh.Value;
                entity.Lophc    = Convert.ToInt64(cbbLopHocSinh.SelectedValue);
                var dg = new HocSinhController();
                if (dg.Edit(entity))
                {
                    ShowView(dg.DetailView());
                }
                else
                {
                    MessageBox.Show("Sửa bản ghi không thành công");
                }
            }
            btn_enable(false);
        }
Exemple #8
0
        private void bbiSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ComboboxItem item = new ComboboxItem();

            item = (ComboboxItem)cbClass.SelectedItem;
            bool gt = true;

            if (radNam.Checked == true)
            {
                gt = true;
            }
            else
            {
                gt = false;
            }

            if (_state == 1)
            {
                if (HocSinhController.ThemHS(txtID.Text.Trim().ToUpper(), txtTen.Text.Trim(), txtDiaChi.Text.Trim(), gt, dateNgaySinh.Value, txtSDT.Text.Trim(), txtTenPhuHuynh.Text.Trim(), txtSDTphuHuynh.Text.Trim(), item.Value.ToString()))
                {
                    MessageBox.Show("Thành Công", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Lỗi", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (_state == 2)
            {
                if (HocSinhController.SuaHS(txtID.Text.Trim().ToUpper(), txtTen.Text.Trim(), txtDiaChi.Text.Trim(), gt, dateNgaySinh.Value, txtSDT.Text.Trim(), txtTenPhuHuynh.Text.Trim(), txtSDTphuHuynh.Text.Trim(), item.Value.ToString()))
                {
                    MessageBox.Show("Thành Công", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Lỗi", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #9
0
        private void button2_Click(object sender, EventArgs e)
        {
            HocSinhController dtc = new HocSinhController();

            ShowView(dtc.DetailView());
        }