Пример #1
0
        public void Insert(FechamentoEntity fechamento)
        {
			try
			{
				OpenConnection();
				using (cmd = new SqlCommand("", con))
				{
					cmd.CommandText = "UP_FECHAMENTO_CADASTRAR";
					cmd.CommandType = CommandType.StoredProcedure;
					cmd.Parameters.Add(new SqlParameter("@DATA_FECHAMENTO", SqlDbType.SmallDateTime)).Value = fechamento.DataFechamento;
					cmd.Parameters.Add(new SqlParameter("@REMESSA", SqlDbType.Bit)).Value = fechamento.Remessa;
					cmd.Parameters.Add(new SqlParameter("@DOLAR_REMESSA", SqlDbType.Money)).Value = fechamento.DolarRemessa;
					cmd.Parameters.Add(new SqlParameter("@EMISSOR_ID", SqlDbType.Int)).Value = fechamento.Emissor.Id;
					cmd.ExecuteNonQuery();
				}
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
			finally
			{
				CloseConnection();
			}
        }
Пример #2
0
		public FechamentoEntity GetById(int id)
		{
			try
			{
				OpenConnection();
				using (cmd = new SqlCommand("", con))
				{
					cmd.CommandText = "UP_FECHAMENTO_BUSCAR";
					cmd.CommandType = CommandType.StoredProcedure;
					cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = id;
					dr = cmd.ExecuteReader();
					FechamentoEntity fechamento = null;
					if (dr.HasRows)
					{
						while (dr.Read())
						{
							fechamento = new FechamentoEntity()
							{
								Id = Convert.ToInt32(dr["ID"]),
								DataFechamento = Convert.ToDateTime(dr["DATA_FECHAMENTO"]),
								Remessa = Convert.ToBoolean(dr["REMESSA"]),
								DolarRemessa = Convert.ToDecimal(dr["DOLAR_REMESSA"]),
								Emissor = new Entity.EmissorEntity() { Id = Convert.ToInt32(dr["ID"]) }
							};
						}
					}
					return fechamento;
				}
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
			finally
			{
				CloseConnection();
			}
		}
Пример #3
0
 public void Update(FechamentoEntity fechamento) => new FechamentoRepository().Update(fechamento);
Пример #4
0
 public void Insert(FechamentoEntity fechamento) => new FechamentoRepository().Insert(fechamento);