public int agregarSeguro(CIASeguro seguro)
 {
     using (BDHermesBancarizacionEntities db = new BDHermesBancarizacionEntities())
     {
         var ed = db.CIASeguro.Find(seguro.ID);
         if (ed != null)
         {
             return(0);
         }
         else
         {
             db.CIASeguro.Add(seguro);
             return(db.SaveChanges());
         }
     }
 }
Esempio n. 2
0
        protected void btnGuardarCiaSeguro_Click(object sender, EventArgs e)
        {
            using (CiaSeguro_DAO db = new CiaSeguro_DAO())
            {
                CIASeguro ciaseg = new CIASeguro();
                ciaseg.ID           = Convert.ToInt32(Session["idCiaSeguro"]);
                ciaseg.Nombre       = txtRazonSocial.Text;
                ciaseg.RUC          = txtRuc.Text;
                ciaseg.Direccion    = txtDireccion.Text;
                ciaseg.CodigoUbigeo = DDLDepartamento.SelectedValue.Substring(0, 2) + DDLProvincia.SelectedValue.Substring(2, 2) + DDLDistrito.SelectedValue.Substring(4, 2);
                //ciaseg.NombreAdj = lblArchivo.Text;
                ciaseg.TipoContenidoAdj = "";
                ciaseg.TamanioAdj       = 444;
                ciaseg.DatoAdj          = null;

                if (chkEmpRecaudadora.Checked == true)
                {
                    ciaseg.IsEmpresaRecaudadora = true;
                }
                else
                {
                    ciaseg.IsEmpresaRecaudadora = false;
                }

                ciaseg.Estado = true;
                ciaseg.Codigo = null;
                ciaseg.TerminosCondiciones  = null;
                ciaseg.UsuarioCreacion      = null;
                ciaseg.FechaCreacion        = DateTime.Now;
                ciaseg.UsuarioActualizacion = "";
                ciaseg.FechaActualizacion   = DateTime.Now;

                db.agregarSeguro(ciaseg);
                //  string jss = "openModal()";
                // ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", jss, true);
            }
        }
Esempio n. 3
0
        public ClientResponse listarReporte(int CampaniaID, int ProductoID, int InstitucionEducativaID, DateTime?FechaInicial, DateTime?FechaFinal, int paginaActual, int RegistroXPagina)
        {
            int recordCount = 0;

            try
            {
                using (conexion = new SqlConnection(ConexionDAO.cnx))
                {
                    using (comando = new SqlCommand("usp_cheque_getLst", conexion))
                    {
                        comando.CommandType = CommandType.StoredProcedure;
                        comando.Parameters.AddWithValue("@CampaniaID", CampaniaID);
                        comando.Parameters.AddWithValue("@ProductoID", ProductoID);
                        comando.Parameters.AddWithValue("@InstitucionEducativaID", InstitucionEducativaID);
                        comando.Parameters.AddWithValue("@StartDate", FechaInicial);
                        comando.Parameters.AddWithValue("@EndDate", FechaFinal);
                        comando.Parameters.AddWithValue("@vi_Pagina", paginaActual);
                        comando.Parameters.AddWithValue("@vi_RegistrosporPagina", RegistroXPagina);
                        comando.Parameters.Add("@vi_RecordCount", SqlDbType.Int).Direction = ParameterDirection.Output;
                        conexion.Open();
                        using (reader = comando.ExecuteReader())
                        {
                            while (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"]);

                                Campania oCamp = new Campania();
                                oCamp.Nombre     = (reader["CampaniaNm"] == DBNull.Value) ? "" : reader["CampaniaNm"].ToString();
                                entidad.Campania = oCamp;
                                entidad.InstitucionEducativaID = (reader["InstitucionEducativaID"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["InstitucionEducativaID"]);

                                InstitucionEducativa oInst = new InstitucionEducativa();
                                oInst.Nombre = (reader["InstitucionEducativaNm"] == DBNull.Value) ? "" : reader["InstitucionEducativaNm"].ToString();
                                entidad.InstitucionEducativa = oInst;

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

                                CIASeguro oCia = new CIASeguro();
                                oCia.Nombre       = (reader["CIASeguroNm"] == DBNull.Value) ? "" : reader["CIASeguroNm"].ToString();
                                entidad.CIASeguro = oCia;

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

                                Producto oProd = new Producto();
                                oProd.Nombre     = (reader["ProductoNm"] == DBNull.Value) ? "" : reader["ProductoNm"].ToString();
                                entidad.Producto = oProd;

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

                                Banco oBan = new Banco();
                                oBan.Nombre   = (reader["BancoNm"] == DBNull.Value) ? "" : reader["BancoNm"].ToString();
                                entidad.Banco = oBan;

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

                                Moneda oMon = new Moneda();
                                oMon.Nombre    = (reader["MonedaNm"] == DBNull.Value) ? "" : reader["MonedaNm"].ToString();
                                entidad.Moneda = oMon;

                                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();

                                lstCheque.Add(entidad);
                            }
                        }
                        recordCount = Convert.ToInt32(comando.Parameters["@vi_RecordCount"].Value);
                    }
                }
            }
            catch (Exception ex)
            {
                clientResponse.Mensaje = ex.Message;
                clientResponse.Status  = "ERROR";
            }
            finally
            {
                conexion.Close();
                conexion.Dispose();
                comando.Dispose();
                reader.Dispose();
            }
            Pagination responsepaginacion = new Pagination()
            {
                TotalItems = recordCount,
                TotalPages = (int)Math.Ceiling((double)recordCount / 10)
                             //TotalPages = (int)Math.Ceiling((double)recordCount / objeto.ItemsPerPage)
            };

            clientResponse.DataJson   = JsonConvert.SerializeObject(lstCheque).ToString();
            clientResponse.paginacion = JsonConvert.SerializeObject(responsepaginacion).ToString();
            return(clientResponse);
        }
Esempio n. 4
0
        protected void grvCiaSeguros_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Agregar")
            {
                int fila = Convert.ToInt32(e.CommandArgument);
                txtTipoSeguro.Text    = HttpUtility.HtmlDecode(Convert.ToString(grvCiaSeguros.Rows[fila].Cells[2].Text));
                txtTipoSeguro.Enabled = false;

                // LLenar combobox ...!!
                cUtil.ListarTipoSeguro(DDLTipoSeguro);
                cUtil.ListarTrama(DDLTrama);

                string jss = "openEditarTipoSeguro();";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", jss, true);
            }

            if (e.CommandName == "Edita")
            {
                int fila = Convert.ToInt32(e.CommandArgument);
                int id   = Convert.ToInt32(grvCiaSeguros.Rows[fila].Cells[9].Text);
                using (CiaSeguro_DAO db = new CiaSeguro_DAO())
                {
                    cUtil.ListarUbigeo(DDLDepartamento, "01", "00", "00");
                    CIASeguro ie = db.Buscar(id);

                    Session["idSeguro"] = ie.ID.ToString();
                    txtRazonSocial.Text = HttpUtility.HtmlDecode(ie.Nombre);
                    txtRuc.Text         = ie.RUC;
                    txtDireccion.Text   = ie.Direccion;
                    byte[] imagen = db.ObtenerImagenLogo(Convert.ToInt32(grvCiaSeguros.Rows[fila].Cells[1].Text));
                    if (imagen != null)
                    {
                        img_destinoCia.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(imagen);
                    }

                    DDLDepartamento.SelectedValue = ie.CodigoUbigeo.Substring(0, 2) + "0000";
                    DDLDepartamento_SelectedIndexChanged(null, null);
                    DDLProvincia.SelectedValue = ie.CodigoUbigeo.Substring(0, 2) + ie.CodigoUbigeo.Substring(2, 2) + "00";
                    DDLProvincia_SelectedIndexChanged(null, null);
                    DDLDistrito.SelectedValue = ie.CodigoUbigeo.Substring(0, 2) + ie.CodigoUbigeo.Substring(2, 2) + ie.CodigoUbigeo.Substring(4, 2);
                    chkEmpRecaudadora.Checked = ie.IsEmpresaRecaudadora;
                    btnGuardarCiaSeguro.Text  = "Editar";
                    MVSeguros.ActiveViewIndex = 1;
                }
            }

            if (e.CommandName == "Anula")
            {
                int   fila      = Convert.ToInt32(e.CommandArgument);
                Label lblestado = (Label)grvCiaSeguros.Rows[fila].FindControl("lblestado");
                int   id        = Convert.ToInt32(grvCiaSeguros.Rows[fila].Cells[9].Text);
                hdnIdCompañiaSeguro.Value = id.ToString();
                hdnEstado.Value           = lblestado.Text;

                using (CiaSeguro_DAO db = new CiaSeguro_DAO())
                {
                    if (lblestado.Text.ToUpper() == "ACTIVO")
                    {
                        lblTitleConfirm.Text = "Desactivar Compañía de Seguros";
                        lblmsgConfirm.Text   = "¿Desea desactivar esta compañia de seguro: " + grvCiaSeguros.Rows[fila].Cells[2].Text + " ?";
                    }
                    else if (lblestado.Text == "NO ACTIVO")
                    {
                        lblTitleConfirm.Text = "Activar Compañía de Seguros";
                        lblmsgConfirm.Text   = "¿Desea activar esta compañía de seguro: " + grvCiaSeguros.Rows[fila].Cells[2].Text + " ?";
                    }

                    ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "openConfirm();", true);
                }
            }
        }