예제 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DataGridViewRow dgvRow = dtgrvSachTV.CurrentRow;
            int             MaSach = (int)dgvRow.Cells[0].Value;
            SachBUS         sb     = new SachBUS();

            sb.UpdateRecord(MaSach, true);

            ChiTietMuonDTO ctmuon = new ChiTietMuonDTO();

            ctmuon.MaSach  = MaSach;
            ctmuon.NgayTra = dtNgTra.Value;

            ChiTietMuonBUS ctmBus = new ChiTietMuonBUS();

            ctmBus.Insert(ctmuon);

            PhieuMuonDTO phieuMuon = new PhieuMuonDTO();

            phieuMuon.MaDocGia = int.Parse(txtMaDG.Text);
            phieuMuon.NgayMuon = DateTime.Now;

            PhieuMuonBUS pmBus = new PhieuMuonBUS();

            pmBus.Insert(phieuMuon);

            btnChon_Click(sender, e);
        }
예제 #2
0
        public static ChiTietMuonDTO Search(int MaPhieuMuon)
        {
            ChiTietMuonDTO CTMuon = null;

            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "select * from CHITIETMUON where MaPhieuMuon = ?";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

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

            if (reader.Read())
            {
                CTMuon = new ChiTietMuonDTO();

                CTMuon.MaPhieuMuon = (int)reader["MaPhieuMuon"];
                CTMuon.MaSach      = (int)reader["MaSach"];
                CTMuon.NgayTra     = (DateTime)reader["NgayTra"];
            }

            reader.Close();
            connection.Close();
            return(CTMuon);
        }
예제 #3
0
        public static void Insert(ChiTietMuonDTO CTMuon)
        {
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Insert into CHITIETMUON(MaSach, NgayTra) values(?,?) ";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@MaSach", OleDbType.Integer);

            command.Parameters["@MaSach"].Value = CTMuon.MaSach;

            command.Parameters.Add("@NgayTra", OleDbType.Date);

            command.Parameters["@NgayTra"].Value = CTMuon.NgayTra;

            command.ExecuteNonQuery();
            command.CommandText = "Select @@IDENTITY";
            CTMuon.MaPhieuMuon  = (int)command.ExecuteScalar();
            // CTMuon.MaSach = (int)command.ExecuteScalar();
            connection.Close();
        }
예제 #4
0
        public static IList GetList()
        {
            ArrayList      arrCTMuon = new ArrayList();
            ChiTietMuonDTO CTMuon;

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

            while (reader.Read())
            {
                CTMuon             = new ChiTietMuonDTO();
                CTMuon.MaSach      = (int)reader["MaSach"];
                CTMuon.MaPhieuMuon = (int)reader["MaPhieuMuon"];
                CTMuon.NgayTra     = (DateTime)reader["NgayTra"];

                arrCTMuon.Add(CTMuon);
            }
            reader.Close();
            connection.Close();
            return(arrCTMuon);
        }
예제 #5
0
 public void Insert(ChiTietMuonDTO ctMuon)
 {
     ChiTietMuonDAO.Insert(ctMuon);
 }