public static MTaxe GetTaxeXProduct(this BoTaxe pTaxe, int pIdProduct) { var lTaxe = new MTaxe { LObject = new MObject { LIdObject = pTaxe.LObject.LIdObject, LNameObject = pTaxe.LObject.LNameObject }, LStatus = new MStatus { LIdStatus = pTaxe.LStatus.LIdStatus, LDsEstado = pTaxe.LStatus.LDsEstado }, LCreationDate = pTaxe.LCreationDate, LIdProduct = pIdProduct, LIdTaxe = pTaxe.LIdTaxe, LIsPercent = pTaxe.LIsPercent, LMessageException = pTaxe.LMessageDao, LNameTaxe = pTaxe.LNameTaxe, LValueTaxe = pTaxe.LValueTaxe }; return(lTaxe); }
public BoTaxe Dao_getTaxeById(int pIdTaxe) { SqlConnection lConex = new SqlConnection(); using (lConex = Dao_SqlConnection(lConex)) { var lTaxe = new BoTaxe(); try { var lCommand = new SqlCommand { CommandText = "spr_GetTaxeById", CommandTimeout = 30, CommandType = CommandType.StoredProcedure, Connection = lConex }; lCommand.Parameters.Add(new SqlParameter("IdTaxe", pIdTaxe)); var lReader = lCommand.ExecuteReader(); if (lReader.HasRows) { while (lReader.Read()) { lTaxe.LIdTaxe = Convert.ToInt32(lReader["IdTax"].ToString()); lTaxe.LNameTaxe = lReader["NameTax"].ToString(); lTaxe.LCreationDate = Convert.ToDateTime(lReader["CreationDate"].ToString()); lTaxe.LValueTaxe = Convert.ToDecimal(lReader["ValueTax"].ToString()); lTaxe.LIsPercent = Convert.ToBoolean(lReader["IsPercent"].ToString()); lTaxe.LStatus = new BoStatus { LIdStatus = lReader["IdStatus"].ToString() }; lTaxe.LObject = new BoObject { LIdObject = Convert.ToInt32(lReader["IdObject"].ToString()) }; } } Dao_CloseSqlconnection(lConex); return(lTaxe); } catch (Exception e) { lTaxe = new BoTaxe { LException = e.Message, LMessageDao = BoErrors.MsgErrorGetSql }; if (e.InnerException != null) { lTaxe.LInnerException = e.InnerException.ToString(); } Dao_CloseSqlconnection(lConex); return(lTaxe); } } }
public List <BoTaxe> Dao_getLisAllTaxesXProduct(int idProduct) { SqlConnection lConex = new SqlConnection(); using (lConex = Dao_SqlConnection(lConex)) { var lListTaxe = new List <BoTaxe>(); try { var lCommand = new SqlCommand { CommandText = "spr_GetListAllTaxesXProduct", CommandTimeout = 30, CommandType = CommandType.StoredProcedure, Connection = lConex }; lCommand.Parameters.Add("idProduct", SqlDbType.Int).Value = idProduct; var lReader = lCommand.ExecuteReader(); if (lReader.HasRows) { while (lReader.Read()) { var lTaxe = new BoTaxe { LStatus = new BoStatus { LIdStatus = lReader["IdStatus"].ToString(), LDsEstado = lReader["DsEstado"].ToString() }, LObject = new BoObject { LIdObject = Convert.ToInt32(lReader["IdObject"].ToString()), LNameObject = lReader["NameObject"].ToString() }, LIdTaxe = Convert.ToInt32(lReader["IdTax"].ToString()), LNameTaxe = lReader["NameTax"].ToString(), LIsPercent = Convert.ToBoolean(lReader["IsPercent"].ToString()), LCreationDate = Convert.ToDateTime(lReader["CreationDate"].ToString()), LValueTaxe = Convert.ToDecimal(lReader["ValueTax"].ToString()) }; lListTaxe.Add(lTaxe); } } Dao_CloseSqlconnection(lConex); return(lListTaxe); } catch (Exception e) { lListTaxe = new List <BoTaxe>(); var lTaxe = new BoTaxe { LException = e.Message, LMessageDao = BoErrors.MsgErrorGetSql }; if (e.InnerException != null) { lTaxe.LInnerException = e.InnerException.ToString(); } Dao_CloseSqlconnection(lConex); lListTaxe.Add(lTaxe); return(lListTaxe); } } }