コード例 #1
0
 public void LuuPhieu(PhieuThuBO phieuthuBO)
 {
     SqlConnection cnn = new SqlConnection(cnnstr);
     //Thêm phiếu mượn
     string query = "INSERT INTO PHIEUTHU(Manv,Tongtien,Ngaylap)";
     query += " VALUES(@manv,@tongtien,getdate())";
     SqlCommand cmd = new SqlCommand(query, cnn);
     cmd.Parameters.AddWithValue("@manv",phieuthuBO.MaNV);
     cmd.Parameters.AddWithValue("@tongtien",phieuthuBO.TongTien);
     cnn.Open();
     cmd.ExecuteNonQuery();
     cnn.Close();
     //Thêm chi tiết phiếu mượn
     query = "UPDATE CHITIETPHIEUMUON_TRA";
     query += " SET maphieuthu=(SELECT top 1 Maphieuthu FROM Phieuthu Order by Ngaylap desc) ";
     query+=", sotienphat=@sotienphat,lydophat=@lydophat WHERE maphieumuon=@maphieumuon AND masach=@masach";
     for (int i = 0; i <phieuthuBO.ChiTietPhieuThu.Count; i++)
     {
         SqlCommand chitietcmd = new SqlCommand(query, cnn);
         chitietcmd.Parameters.AddWithValue("@sotienphat",phieuthuBO.ChiTietPhieuThu.Index(i).SoTienPhat);
         chitietcmd.Parameters.AddWithValue("@lydophat",phieuthuBO.ChiTietPhieuThu.Index(i).LyDoPhat);
         chitietcmd.Parameters.AddWithValue("@maphieumuon",phieuthuBO.ChiTietPhieuThu.Index(i).MaPhieuMuon);
         chitietcmd.Parameters.AddWithValue("@masach", phieuthuBO.ChiTietPhieuThu.Index(i).MaSach);
         cnn.Open();
         chitietcmd.ExecuteNonQuery();
         cnn.Close();
     }
 }
コード例 #2
0
 public bool LuuPhieu(ChiTietPhieuMuon_TraCollection chitietphieuColl, string manv,decimal tongtien)
 {
     try
     {
         PhieuThuBO phieuthuBO = new PhieuThuBO();
         phieuthuBO.MaNV = manv;
         phieuthuBO.TongTien = tongtien;
         phieuthuBO.ChiTietPhieuThu = chitietphieuColl;
         phieuthuDAO.LuuPhieu(phieuthuBO);
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #3
0
 public void Add(PhieuThuBO phieuthuBO)
 {
     List.Add(phieuthuBO);
 }
コード例 #4
0
 public PhieuThuCollection TimPhieuThu(string madocgia)
 {
     PhieuThuCollection phieuthuColl = new PhieuThuCollection();
     SqlConnection cnn = new SqlConnection(cnnstr);
     string query="SELECT convert(nvarchar(10),ngaylap,103) NgayLap, * FROM Phieuthu a, ChiTietPhieuMuon_Tra b, Phieumuon c, luotvaothuvien d";
     query += " WHERE a.maphieuthu=b.maphieuthu AND c.maphieumuon=b.maphieumuon AND c.maluot=d.maluot";
     query += " AND madocgia=@madocgia";
     query += " Order by a.Ngaylap desc";
     SqlCommand cmd = new SqlCommand(query,cnn);
     cmd.Parameters.AddWithValue("@madocgia", madocgia);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         PhieuThuBO phieuthuBO = new PhieuThuBO();
         phieuthuBO.MaNV = dr["manv"].ToString();
         phieuthuBO.MaPhieuThu = dr["maphieuthu"].ToString();
         phieuthuBO.NgayLap=dr["Ngaylap"].ToString();
         phieuthuBO.TongTien=Convert.ToDecimal(dr["tongtien"].ToString());
         phieuthuColl.Add(phieuthuBO);
     }
     cnn.Close();
     return phieuthuColl;
 }