Beispiel #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (dataGridViewX1.Rows.Count > 0)
            {
                for (int i = 0; i < dataGridViewX1.Rows.Count; i++)
                {
                    string makhoa, machuongtrinhhoc, magv, maphonghoc, mangayhoc, maca;
                    makhoa           = new KhoaHocBUS().GetMa_TheoTen(dataGridViewX1.Rows[i].Cells[2].Value.ToString());
                    machuongtrinhhoc = new ChuongTrinhHocBUS().GetMa_TheoTen(dataGridViewX1.Rows[i].Cells[3].Value.ToString());
                    magv             = new GiangVienBUS().GetMa_TheoTen(dataGridViewX1.Rows[i].Cells[10].Value.ToString());
                    maphonghoc       = new PhongHocBUS().GetMa_TheoTen_PhongHoc(dataGridViewX1.Rows[i].Cells[11].Value.ToString());
                    mangayhoc        = new NgayHocBUS().GetMa_TheoTen(dataGridViewX1.Rows[i].Cells[6].Value.ToString());
                    maca             = new CaHocBUS().GetMa_TheoTen(dataGridViewX1.Rows[i].Cells[7].Value.ToString());
                    _objlop          = new Lop(
                        _objlopbus.Lop_NextID(),
                        dataGridViewX1.Rows[i].Cells[1].Value.ToString(),
                        makhoa,
                        machuongtrinhhoc,
                        DateTime.Parse(dataGridViewX1.Rows[i].Cells[4].Value.ToString()),
                        DateTime.Parse(dataGridViewX1.Rows[i].Cells[5].Value.ToString()),
                        maca,
                        mangayhoc,
                        magv,
                        maphonghoc);

                    if (_objlopbus.AddLop(_objlop))
                    {
                        dataGridViewX1.Rows.Remove(dataGridViewX1.Rows[i]);
                        i--;
                        LoadData();
                    }
                    else
                    {
                        string a = dataGridViewX1.Rows[i].Cells[0].Value.ToString();
                        MessageBox.Show("Lưu dòng " + a + " thất bại");
                    }
                }


                if (dataGridViewX1.Rows.Count == 0)
                {
                    MessageBox.Show("Lưu thành công");
                }

                dtipNgayBatDau.Text  = "";
                dtipNgayKetThuc.Text = "";
            }
            else
            {
                MessageBox.Show("Không có dữ liệu để lưu ! ", "Thống báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #2
0
        private void cbKhoaHoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            ChuongTrinhHocBUS _objchuongtrinhhocbus = new ChuongTrinhHocBUS();
            DataTable         _dtcth = _objchuongtrinhhocbus.GetMaTen_TheoKhoa(cbKhoaHoc.SelectedValue.ToString());

            if (_dtcth.Rows.Count != 0)
            {
                cbChuongTrinhHoc.DataSource    = _dtcth;
                cbChuongTrinhHoc.ValueMember   = "MaChuongTrinhHoc";
                cbChuongTrinhHoc.DisplayMember = "TenChuongTrinhHoc";
            }
            else
            {
                cbChuongTrinhHoc.DataSource = null;
            }
        }
Beispiel #3
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            string makhoa, machuongtrinhhoc, magv, maphonghoc, mangayhoc, maca;

            makhoa           = new KhoaHocBUS().GetMa_TheoTen(cbKhoaHoc.Text);
            machuongtrinhhoc = new ChuongTrinhHocBUS().GetMa_TheoTen(cbChuongTrinhHoc.Text);
            magv             = new GiangVienBUS().GetMa_TheoTen(cbGiangVien.Text);
            maphonghoc       = new PhongHocBUS().GetMa_TheoTen_PhongHoc(cbPhongHoc.Text);
            mangayhoc        = new NgayHocBUS().GetMa_TheoTen(cbNgayHoc.Text);
            maca             = new CaHocBUS().GetMa_TheoTen(cbCaHoc.Text);
            _objlop          = new Lop(
                dataGridViewX1.CurrentRow.Cells[0].Value.ToString(),
                txtTenLop.Text,
                makhoa,
                machuongtrinhhoc,
                DateTime.Parse(dtipNgayBatDau.Value.ToShortDateString()),
                DateTime.Parse(dtipNgayBatDau.Value.ToShortDateString()),
                maca,
                mangayhoc,
                magv,
                maphonghoc);
            //MessageBox.Show(dataGridViewX1.CurrentRow.Cells[0].Value.ToString() +
            //    txtTenLop.Text+
            //    makhoa+
            //    machuongtrinhhoc+
            //    DateTime.Parse(dtipNgayBatDau.Value.ToShortDateString())+
            //    DateTime.Parse(dtipNgayBatDau.Value.ToShortDateString())+
            //    maca+
            //    mangayhoc+
            //    magv+
            //    maphonghoc);

            if (_objlopbus.EditLop(_objlop))
            {
                MessageBox.Show("Cập nhật thành công ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadData();
                resettextbox();
            }
            else
            {
                MessageBox.Show("Cập Nhật thất bại", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }