public static MReportSales ToMSales(this BoReportSales pBoSales) { return(new MReportSales() { LCode = pBoSales.LCode, LCreationDate = pBoSales.LCreationDate, LId = pBoSales.LId, LProduct = new MProduct() { LCdProduct = pBoSales.LProduct.LCdProduct, LIdProduct = pBoSales.LProduct.LIdProduct, LNameProduct = pBoSales.LProduct.LNameProduct } }); }
public List <BoReportSales> Dao_getSalesReport(DateTime pStartDate, DateTime pFinishDate) { SqlConnection lConex = new SqlConnection(); using (lConex = Dao_SqlConnection(lConex)) { var lListReport = new List <BoReportSales>(); try { var lCommand = new SqlCommand { CommandText = "spr_ReportSales", CommandTimeout = 30, CommandType = CommandType.StoredProcedure, Connection = lConex }; lCommand.Parameters.Add(new SqlParameter("startDate", pStartDate)); lCommand.Parameters.Add(new SqlParameter("finDate", pFinishDate)); var lReader = lCommand.ExecuteReader(); if (lReader.HasRows) { while (lReader.Read()) { var lReport = new BoReportSales(); lReport.LCode = lReader["Codes"].ToString(); lReport.LCreationDate = Convert.ToDateTime(lReader["CreationDate"].ToString()); lReport.LId = Convert.ToInt32(lReader["Id"].ToString()); lReport.LProduct = new BoProduct() { LIdProduct = Convert.ToInt32(lReader["IdProduct"].ToString()), LNameProduct = lReader["NameProduct"].ToString(), LCdProduct = lReader["CdProduct"].ToString(), LValueSupplier = Convert.ToDecimal(lReader["PriceSupplier"].ToString()) }; lReport.LQty = Convert.ToDecimal(lReader["Qty"].ToString()); lReport.LValuetotal = Convert.ToDecimal(lReader["valuetotal"].ToString()); lListReport.Add(lReport); } } Dao_CloseSqlconnection(lConex); return(lListReport); } catch (Exception e) { lListReport = new List <BoReportSales>(); var lReport = new BoReportSales { LException = e.Message, LMessageDao = BoErrors.MsgErrorGetSql }; if (e.InnerException != null) { lReport.LInnerException = e.InnerException.ToString(); } Dao_CloseSqlconnection(lConex); lListReport.Add(lReport); return(lListReport); } } }