Exemple #1
0
        public static void Insert(ChiTietMonDTO chiTietMonDTO)
        {
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Insert into CHITIETMON(MaLopMon, MaNamHoc, ThoiGianHoc, GioHoc, GiangDuong, GiangVien, NgayThiLan1, GioThiLan1, GiangDuongThiLan1, CanBoCoiThiLan1, SoBaiThiLan1, NgayThiLan2, GioThiLan2, GiangDuongThiLan2, CanBoCoiThiLan2, SoBaiThiLan2, GhiChu) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@MaLopMon", OleDbType.Numeric);
            command.Parameters.Add("@MaNamHoc", OleDbType.Numeric);
            command.Parameters.Add("@ThoiGianHoc", OleDbType.WChar);
            command.Parameters.Add("@GioHoc", OleDbType.WChar);
            command.Parameters.Add("@GiangDuong", OleDbType.WChar);
            command.Parameters.Add("@GiangVien", OleDbType.WChar);
            command.Parameters.Add("@NgayThiLan1", OleDbType.WChar);
            command.Parameters.Add("@GioThiLan1", OleDbType.WChar);
            command.Parameters.Add("@GiangDuongThiLan1", OleDbType.WChar);
            command.Parameters.Add("@CanBoCoiThiLan1", OleDbType.WChar);
            command.Parameters.Add("@SoBaiThiLan1", OleDbType.Numeric);
            command.Parameters.Add("@NgayThiLan2", OleDbType.WChar);
            command.Parameters.Add("@GioThiLan2", OleDbType.WChar);
            command.Parameters.Add("@GiangDuongThiLan2", OleDbType.WChar);
            command.Parameters.Add("@CanBoCoiThiLan2", OleDbType.WChar);
            command.Parameters.Add("@SoBaiThiLan2", OleDbType.Numeric);
            command.Parameters.Add("@GhiChu", OleDbType.WChar);
            command.Parameters.Add("@MaChiTietMon", OleDbType.Numeric);

            command.Parameters["@MaLopMon"].Value          = chiTietMonDTO.MaLopMon;
            command.Parameters["@MaNamHoc"].Value          = chiTietMonDTO.MaNamHoc;
            command.Parameters["@ThoiGianHoc"].Value       = chiTietMonDTO.ThoiGianHoc;
            command.Parameters["@GioHoc"].Value            = chiTietMonDTO.GioHoc;
            command.Parameters["@GiangDuong"].Value        = chiTietMonDTO.GiangDuong;
            command.Parameters["@GiangVien"].Value         = chiTietMonDTO.GiangVien;
            command.Parameters["@NgayThiLan1"].Value       = chiTietMonDTO.NgayThiLan1;
            command.Parameters["@GioThiLan1"].Value        = chiTietMonDTO.GioThiLan1;
            command.Parameters["@GiangDuongThiLan1"].Value = chiTietMonDTO.GiangDuongThiLan1;
            command.Parameters["@CanBoCoiThiLan1"].Value   = chiTietMonDTO.CanBoCoiThiLan1;
            command.Parameters["@SoBaiThiLan1"].Value      = chiTietMonDTO.SoBaiThiLan1;
            command.Parameters["@NgayThiLan2"].Value       = chiTietMonDTO.NgayThiLan2;
            command.Parameters["@GioThiLan2"].Value        = chiTietMonDTO.GioThiLan2;
            command.Parameters["@GiangDuongThiLan2"].Value = chiTietMonDTO.GiangDuongThiLan2;
            command.Parameters["@CanBoCoiThiLan2"].Value   = chiTietMonDTO.CanBoCoiThiLan2;
            command.Parameters["@SoBaiThiLan2"].Value      = chiTietMonDTO.SoBaiThiLan2;
            command.Parameters["@GhiChu"].Value            = chiTietMonDTO.GhiChu;
            command.Parameters["@MaChiTietMon"].Value      = chiTietMonDTO.MaChiTietMon;

            command.ExecuteNonQuery();
            command.CommandText        = "select @@IDENTITY";
            chiTietMonDTO.MaChiTietMon = (int)command.ExecuteScalar();
            connection.Close();
        }
Exemple #2
0
        public static void UpdateCanBoCoiThiLan2(ChiTietMonDTO chiTietMonDTO)
        {
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Update CHITIETMON Set [CanBoCoiThiLan2] = ? Where [MaChiTietMon] = ?";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@CanBoCoiThiLan2", OleDbType.WChar);
            command.Parameters.Add("@MaChiTietMon", OleDbType.Numeric);

            command.Parameters["@CanBoCoiThiLan2"].Value = chiTietMonDTO.CanBoCoiThiLan2;
            command.Parameters["@MaChiTietMon"].Value    = chiTietMonDTO.MaChiTietMon;

            command.ExecuteNonQuery();
            connection.Close();
        }
Exemple #3
0
        public static void UpdateRecord(ChiTietMonDTO chiTietMonDTO)
        {
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Update CHITIETMON Set [MaNamHoc] = ?, [ThoiGianHoc] = ?, [GioHoc] = ?, [GiangDuong] = ?, [NgayThiLan1] = ?, [GioThiLan1] = ?, [GiangDuongThiLan1] = ?, [SoBaiThiLan1] = ?, [NgayThiLan2] = ?, [GioThiLan2] = ?, [GiangDuongThiLan2] = ?, [SoBaiThiLan2] = ?, [GhiChu] = ? Where [MaChiTietMon] = ?";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@MaNamHoc", OleDbType.Integer);
            command.Parameters.Add("@ThoiGianHoc", OleDbType.WChar);
            command.Parameters.Add("@GioHoc", OleDbType.WChar);
            command.Parameters.Add("@GiangDuong", OleDbType.WChar);
            //command.Parameters.Add("@GiangVien", OleDbType.WChar);
            command.Parameters.Add("@NgayThiLan1", OleDbType.WChar);
            command.Parameters.Add("@GioThiLan1", OleDbType.WChar);
            command.Parameters.Add("@GiangDuongThiLan1", OleDbType.WChar);
            //command.Parameters.Add("@CanBoCoiThiLan1", OleDbType.WChar);
            command.Parameters.Add("@SoBaiThiLan1", OleDbType.Numeric);
            command.Parameters.Add("@NgayThiLan2", OleDbType.WChar);
            command.Parameters.Add("@GioThiLan2", OleDbType.WChar);
            command.Parameters.Add("@GiangDuongThiLan2", OleDbType.WChar);
            //command.Parameters.Add("@CanBoCoiThiLan2", OleDbType.WChar);
            command.Parameters.Add("@SoBaiThiLan2", OleDbType.Numeric);
            command.Parameters.Add("@GhiChu", OleDbType.WChar);
            command.Parameters.Add("@MaChiTietMon", OleDbType.Numeric);

            command.Parameters["@MaNamHoc"].Value    = chiTietMonDTO.MaNamHoc;
            command.Parameters["@ThoiGianHoc"].Value = chiTietMonDTO.ThoiGianHoc;
            command.Parameters["@GioHoc"].Value      = chiTietMonDTO.GioHoc;
            command.Parameters["@GiangDuong"].Value  = chiTietMonDTO.GiangDuong;
            //command.Parameters["@GiangVien"].Value = chiTietMonDTO.GiangVien;
            command.Parameters["@NgayThiLan1"].Value       = chiTietMonDTO.NgayThiLan1;
            command.Parameters["@GioThiLan1"].Value        = chiTietMonDTO.GioThiLan1;
            command.Parameters["@GiangDuongThiLan1"].Value = chiTietMonDTO.GiangDuongThiLan1;
            //command.Parameters["@CanBoCoiThiLan1"].Value = chiTietMonDTO.CanBoCoiThiLan1;
            command.Parameters["@SoBaiThiLan1"].Value      = chiTietMonDTO.SoBaiThiLan1;
            command.Parameters["@NgayThiLan2"].Value       = chiTietMonDTO.NgayThiLan2;
            command.Parameters["@GioThiLan2"].Value        = chiTietMonDTO.GioThiLan2;
            command.Parameters["@GiangDuongThiLan2"].Value = chiTietMonDTO.GiangDuongThiLan2;
            //command.Parameters["@CanBoCoiThiLan2"].Value = chiTietMonDTO.CanBoCoiThiLan2;
            command.Parameters["@SoBaiThiLan2"].Value = chiTietMonDTO.SoBaiThiLan2;
            command.Parameters["@GhiChu"].Value       = chiTietMonDTO.GhiChu;
            command.Parameters["@MaChiTietMon"].Value = chiTietMonDTO.MaChiTietMon;

            command.ExecuteNonQuery();
            connection.Close();
        }
Exemple #4
0
        private void btnCapNhatChiTietMon_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show("Bạn có chắc muốn cập nhật chi tiết môn học cho lớp này không?",
                                                      "Question",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    foreach (DataGridViewRow row in dtgvChiTietMon.Rows)
                    {
                        ChiTietMonDTO chiTietMonDTO = new ChiTietMonDTO();

                        chiTietMonDTO.MaChiTietMon = Int32.Parse(row.Cells["MaChiTietMon"].Value.ToString());
                        chiTietMonDTO.ThoiGianHoc  = row.Cells["ThoiGianHoc"].Value.ToString();
                        chiTietMonDTO.GioHoc       = row.Cells["GioHoc"].Value.ToString();
                        chiTietMonDTO.GiangDuong   = row.Cells["GiangDuong"].Value.ToString();
                        //chiTietMonDTO.GiangVien = row.Cells["GiangVien"].Value.ToString();
                        chiTietMonDTO.NgayThiLan1       = row.Cells["NgayThiLan1"].Value.ToString();
                        chiTietMonDTO.GioThiLan1        = row.Cells["GioThiLan1"].Value.ToString();
                        chiTietMonDTO.GiangDuongThiLan1 = row.Cells["GiangDuongThiLan1"].Value.ToString();
                        chiTietMonDTO.CanBoCoiThiLan1   = row.Cells["CanBoCoiThiLan1"].Value.ToString();
                        chiTietMonDTO.SoBaiThiLan1      = Int32.Parse(row.Cells["SoBaiThiLan1"].Value.ToString());
                        chiTietMonDTO.NgayThiLan2       = row.Cells["NgayThiLan2"].Value.ToString();
                        chiTietMonDTO.GioThiLan2        = row.Cells["GioThiLan2"].Value.ToString();
                        chiTietMonDTO.GiangDuongThiLan2 = row.Cells["GiangDuongThiLan2"].Value.ToString();
                        chiTietMonDTO.CanBoCoiThiLan2   = row.Cells["CanBoCoiThiLan2"].Value.ToString();
                        chiTietMonDTO.SoBaiThiLan2      = Int32.Parse(row.Cells["SoBaiThiLan2"].Value.ToString());
                        chiTietMonDTO.GhiChu            = row.Cells["GhiChu"].Value.ToString();

                        ChiTietMonBUS.UpdateRecord(chiTietMonDTO);
                    }

                    MessageBox.Show("Cập nhật chi tiết môn thành công");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #5
0
        public static ChiTietMonDTO TimTheoMaChiTietMon(int maCTM)
        {
            ArrayList arrList = new ArrayList();

            ChiTietMonDTO chiTietMon = new ChiTietMonDTO();

            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Select * from CHITIETMON where MaChiTietMon = ?";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@MaChiTietMon", OleDbType.Integer);
            command.Parameters["@MaChiTietMon"].Value = maCTM;
            OleDbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                chiTietMon.MaChiTietMon      = (int)reader["MaChiTietMon"];
                chiTietMon.MaLopMon          = (int)reader["MaLopMon"];
                chiTietMon.MaNamHoc          = (int)reader["MaNamHoc"];
                chiTietMon.ThoiGianHoc       = (string)reader["ThoiGianHoc"];
                chiTietMon.GioHoc            = (string)reader["GioHoc"];
                chiTietMon.GiangDuong        = (string)reader["GiangDuong"];
                chiTietMon.GiangVien         = (string)reader["GiangVien"];
                chiTietMon.NgayThiLan1       = (string)reader["NgayThiLan1"];
                chiTietMon.GioThiLan1        = (string)reader["GioThiLan1"];
                chiTietMon.GiangDuongThiLan1 = (string)reader["GiangDuongThiLan1"];
                chiTietMon.CanBoCoiThiLan1   = (string)reader["CanBoCoiThiLan1"];
                chiTietMon.SoBaiThiLan1      = (int)reader["SoBaiThiLan1"];
                chiTietMon.NgayThiLan2       = (string)reader["NgayThiLan2"];
                chiTietMon.GioThiLan2        = (string)reader["GioThiLan2"];
                chiTietMon.GiangDuongThiLan2 = (string)reader["GiangDuongThiLan2"];
                chiTietMon.CanBoCoiThiLan2   = (string)reader["CanBoCoiThiLan2"];
                chiTietMon.SoBaiThiLan2      = (int)reader["SoBaiThiLan2"];
                chiTietMon.GhiChu            = (string)reader["GhiChu"];
                arrList.Add(chiTietMon);
            }
            reader.Close();
            connection.Close();
            return(chiTietMon);
        }
Exemple #6
0
        public static IList GetList()
        {
            ArrayList arrList = new ArrayList();

            ChiTietMonDTO chiTietMon = null;

            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Select * from CHITIETMON";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);
            OleDbDataReader reader     = command.ExecuteReader();

            while (reader.Read())
            {
                chiTietMon = new ChiTietMonDTO();

                chiTietMon.MaChiTietMon      = (int)reader["MaChiTietMon"];
                chiTietMon.MaLopMon          = (int)reader["MaLopMon"];
                chiTietMon.MaNamHoc          = (int)reader["MaNamHoc"];
                chiTietMon.ThoiGianHoc       = (string)reader["ThoiGianHoc"];
                chiTietMon.GioHoc            = (string)reader["GioHoc"];
                chiTietMon.GiangDuong        = (string)reader["GiangDuong"];
                chiTietMon.GiangVien         = (string)reader["GiangVien"];
                chiTietMon.NgayThiLan1       = (string)reader["NgayThiLan1"];
                chiTietMon.GioThiLan1        = (string)reader["GioThiLan1"];
                chiTietMon.GiangDuongThiLan1 = (string)reader["GiangDuongThiLan1"];
                chiTietMon.CanBoCoiThiLan1   = (string)reader["CanBoCoiThiLan1"];
                chiTietMon.SoBaiThiLan1      = (int)reader["SoBaiThiLan1"];
                chiTietMon.NgayThiLan2       = (string)reader["NgayThiLan2"];
                chiTietMon.GioThiLan2        = (string)reader["GioThiLan2"];
                chiTietMon.GiangDuongThiLan2 = (string)reader["GiangDuongThiLan2"];
                chiTietMon.CanBoCoiThiLan2   = (string)reader["CanBoCoiThiLan2"];
                chiTietMon.SoBaiThiLan2      = (int)reader["SoBaiThiLan2"];
                chiTietMon.GhiChu            = (string)reader["GhiChu"];
                arrList.Add(chiTietMon);
            }
            reader.Close();
            connection.Close();
            return(arrList);
        }
Exemple #7
0
 public static void UpdateCanBoCoiThiLan2(ChiTietMonDTO chiTietMonDTO)
 {
     ChiTietMonDAO.UpdateCanBoCoiThiLan2(chiTietMonDTO);
 }
Exemple #8
0
 public static void UpdateGiangVien(ChiTietMonDTO chiTietMonDTO)
 {
     ChiTietMonDAO.UpdateGiangVien(chiTietMonDTO);
 }
Exemple #9
0
 public static void UpdateRecord(ChiTietMonDTO chiTietMonDTO)
 {
     ChiTietMonDAO.UpdateRecord(chiTietMonDTO);
 }
Exemple #10
0
 public static void Insert(ChiTietMonDTO chiTietMonDTO)
 {
     ChiTietMonDAO.Insert(chiTietMonDTO);
 }
Exemple #11
0
        private void btnThemLop_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtTenLop.Text == "")
                {
                    MessageBox.Show("Phải nhập tên lớp");
                    return;
                }
                if (countSelectedRow() == 0)
                {
                    MessageBox.Show("Phải chọn ít nhất 1 môn học");
                    return;
                }

                DialogResult result = MessageBox.Show("Bạn có chắc muốn thêm lớp này không?",
                                                      "Question",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    lopDTO.TenLop = txtTenLop.Text;

                    if (txtSoLuongSinhVien.Text == "")
                    {
                        lopDTO.SoLuongSinhVien = 0;
                    }
                    else
                    {
                        lopDTO.SoLuongSinhVien = Int32.Parse(txtSoLuongSinhVien.Text);
                    }

                    if (txtSoLuongTrongNganSach.Text == "")
                    {
                        lopDTO.SoLuongTrongNganSach = 0;
                    }
                    else
                    {
                        lopDTO.SoLuongTrongNganSach = Int32.Parse(txtSoLuongTrongNganSach.Text);
                    }

                    if (txtSoLuongNgoaiNganSach.Text == "")
                    {
                        lopDTO.SoLuongNgoaiNganSach = 0;
                    }
                    else
                    {
                        lopDTO.SoLuongNgoaiNganSach = Int32.Parse(txtSoLuongNgoaiNganSach.Text);
                    }

                    //lopDTO.MaNamHoc = (cmbNamHoc.SelectedItem as NamHocDTO).MaNamHoc;
                    LopBUS.Insert(lopDTO);

                    foreach (DataGridViewRow row in dtgvDSMon.Rows)
                    {
                        if (row.Cells[0].Value != null)
                        {
                            LopMonDTO lopMonDTO = new LopMonDTO();
                            lopMonDTO.MaLop = lopDTO.MaLop;
                            lopMonDTO.MaMon = Int32.Parse(row.Cells["MaMon"].Value.ToString());
                            LopMonBUS.Insert(lopMonDTO);

                            ChiTietMonDTO chiTietMonDTO = new ChiTietMonDTO();
                            chiTietMonDTO.MaLopMon = lopMonDTO.MaLopMon;
                            ChiTietMonBUS.Insert(chiTietMonDTO);
                        }
                    }

                    MessageBox.Show("Thêm lớp thành công");

                    LayDanhSachChiTietMon();

                    btnCapNhatChiTietMon.Visible = true;
                    dtgvChiTietMon.Visible       = true;
                    btnThemLop.Enabled           = false;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }