Esempio n. 1
0
        public static void Insert(LopMonDTO lopMonDTO)
        {
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Insert into LopMON(MaLop, MaMon) values(?,?)";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@MaLop", OleDbType.Numeric);
            command.Parameters.Add("@MaMon", OleDbType.Numeric);

            command.Parameters["@MaLop"].Value = lopMonDTO.MaLop;
            command.Parameters["@MaMon"].Value = lopMonDTO.MaMon;

            command.ExecuteNonQuery();
            command.CommandText = "select @@IDENTITY";
            lopMonDTO.MaLopMon  = (int)command.ExecuteScalar();
            connection.Close();
        }
Esempio n. 2
0
        public static void UpdateRecord(LopMonDTO lopMonDTO)
        {
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Update LOPMON Set [MaLop] = ?, [MaMon] = ? Where [MaLopMon] = ?";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@MaLop", OleDbType.Integer);
            command.Parameters.Add("@MaMon", OleDbType.Integer);
            command.Parameters.Add("@MaLopMon", OleDbType.Integer);

            command.Parameters["@MaLop"].Value    = lopMonDTO.MaLop;
            command.Parameters["@MaMon"].Value    = lopMonDTO.MaMon;
            command.Parameters["@MaLopMon"].Value = lopMonDTO.MaLopMon;

            command.ExecuteNonQuery();
            connection.Close();
        }
Esempio n. 3
0
        public static IList GetList()
        {
            ArrayList arrList = new ArrayList();

            LopMonDTO lopMonDTO = null;

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

            while (reader.Read())
            {
                lopMonDTO = new LopMonDTO();

                lopMonDTO.MaLopMon = (int)reader["MaLopMon"];
                lopMonDTO.MaLop    = (int)reader["MaLop"];
                lopMonDTO.MaMon    = (int)reader["MaMon"];
                arrList.Add(lopMonDTO);
            }
            reader.Close();
            connection.Close();
            return(arrList);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
 public static void UpdateRecord(LopMonDTO lopMonDTO)
 {
     LopMonDAO.UpdateRecord(lopMonDTO);
 }
Esempio n. 6
0
 public static void Insert(LopMonDTO lopMonDTO)
 {
     LopMonDAO.Insert(lopMonDTO);
 }