public void RegistrarAsociacionDetalle(AsociacionDetalle ad)
 {
     using (BDHermesBancarizacionEntities db = new BDHermesBancarizacionEntities())
     {
         using (BancoDAO dbBanco = new BancoDAO())
         {
             db.AsociacionDetalle.Add(ad);
             db.SaveChanges();
         }
     }
 }
Beispiel #2
0
        public ClientResponse getObtenerChequeXId(int ID)
        {
            try
            {
                using (conexion = new SqlConnection(ConexionDAO.cnx))
                {
                    using (comando = new SqlCommand("usp_sel_cheque_x_id", conexion))
                    {
                        comando.CommandType = CommandType.StoredProcedure;
                        comando.Parameters.AddWithValue("@id", ID);
                        conexion.Open();
                        using (reader = comando.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                entidad = new Cheque();

                                entidad.ID         = (reader["ID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["ID"].ToString());
                                entidad.CampaniaID = (reader["CampaniaID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["CampaniaID"]);

                                using (CampañasDAO oCampDao = new CampañasDAO())
                                {
                                    entidad.listCampañas = oCampDao.ListarCampañas();
                                }
                                entidad.InstitucionEducativaID = (reader["InstitucionEducativaID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["InstitucionEducativaID"]);
                                using (InstitucionEducativaDAO db = new InstitucionEducativaDAO())
                                {
                                    entidad.listInstitucionEducativa = db.getLstByCampania(entidad.CampaniaID);
                                }
                                using (CiaSeguro_DAO db = new CiaSeguro_DAO())
                                {
                                    entidad.listCIASeguro = db.getLstbyInst(entidad.InstitucionEducativaID);
                                }
                                entidad.CIASeguroID = (reader["CIASeguroID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["CIASeguroID"]);

                                using (TipoSeguro_DAO db = new TipoSeguro_DAO())
                                {
                                    entidad.listProducto = db.getLstbyInstAseg(entidad.InstitucionEducativaID, entidad.CIASeguroID);
                                }
                                entidad.ProductoID = (reader["ProductoID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["ProductoID"]);
                                entidad.BancoID    = (reader["BancoID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["BancoID"]);
                                entidad.MonedaID   = (reader["MonedaID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["MonedaID"]);
                                using (BancoDAO db = new BancoDAO())
                                {
                                    entidad.listBanco = db.ListarBanco();
                                }
                                using (MonedaDAO db = new MonedaDAO())
                                {
                                    entidad.listMoneda = db.getLstbyInstAsegProd(entidad.InstitucionEducativaID, entidad.CIASeguroID, entidad.ProductoID);
                                }
                                entidad.Fecha     = Convert.ToDateTime(reader["Fecha"]);
                                entidad.NroCheque = (reader["NroCheque"] == DBNull.Value) ? "" : reader["NroCheque"].ToString();
                                entidad.Monto     = (reader["Monto"] == DBNull.Value) ? 0 : Convert.ToDecimal(reader["Monto"]);
                                entidad.Concepto  = (reader["Concepto"] == DBNull.Value) ? "" : reader["Concepto"].ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                clientResponse.Mensaje = ex.Message;
                clientResponse.Status  = "ERROR";
            }
            finally
            {
                conexion.Close();
                conexion.Dispose();
                comando.Dispose();
                reader.Dispose();
            }
            clientResponse.DataJson = JsonConvert.SerializeObject(entidad).ToString();
            return(clientResponse);
        }