Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.User.Identity.IsAuthenticated)
            {
                Tablas.ReloadData();

                if (!Page.IsPostBack)
                {
                    Tablas.ReloadData();
                    lbl.Visible      = false;
                    calendar.Visible = false;
                    Reloj.Visible    = false;
                    Reloj.Text       = DateTime.Now.Hour.ToString();
                    Minuto.Visible   = false;
                    Minuto.Text      = DateTime.Now.Minute.ToString();

                    solicitud.SetDropDownList(ddlservicio, "consulta_servicios", "descripcion");
                    solicitud.SetDropDownList(ddlsectorini, "consulta_sectores", "descripcion");
                    solicitud.SetDropDownList(ddlsectorfin, "consulta_sectores", "descripcion");
                }
                else
                {
                }
            }
            else
            {
                Response.Redirect("~/Accounts/IniciarSesión.aspx");
            }
        }
Example #2
0
        public bool TablasUpdate(Tablas oTablas)
        {
            try
            {
                Conexion         oConexion = new Conexion();
                OracleConnection cn        = oConexion.getConexion();
                cn.Open();
                ds  = new DataSet();
                cmd = new OracleCommand("update TABLAS " +
                                        "SET TAB_CODIGO='" + oTablas.TabCodigo + "'," +
                                        "TAB_NOMBRE='" + oTablas.TabNombre + "'," +
                                        "TAB_DESCRIPCION= '" + oTablas.TabDescripcion + "' " +

                                        "WHERE TAB_CODIGO='" + oTablas.TabCodigo + "'", cn);
                adapter  = new OracleDataAdapter(cmd);
                response = cmd.ExecuteNonQuery();
                cn.Close();
                if (response > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        public List <Tablas> TablasGetAll()
        {
            List <Tablas> lstTablas = new List <Tablas>();

            try
            {
                ds = new DataSet();
                Conexion         oConexion = new Conexion();
                OracleConnection cn        = oConexion.getConexion();
                cn.Open();
                string sqlSelect = "select * from Tablas ";
                cmd     = new OracleCommand(sqlSelect, cn);
                adapter = new OracleDataAdapter(cmd);
                cmd.ExecuteNonQuery();
                adapter.Fill(ds);
                DataTable dt = new DataTable();
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; dt.Rows.Count > i; i++)
                    {
                        DataRow dr     = dt.Rows[i];
                        Tablas  NewEnt = new Tablas();
                        NewEnt = CargarTablas(dr);
                        lstTablas.Add(NewEnt);
                    }
                }
                return(lstTablas);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        public ActionResult Index()
        {
            Tablas      t    = new Tablas();
            List <Tipo> tipo = t.tipos.ToList();

            return(View(tipo));
        }
Example #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Tablas.ReloadData();
     }
 }
Example #6
0
    public string ConstruyeListadoE()
    {
        Tablas generarTabla = new Tablas();
        this.Tabla = generarTabla.contruirTablaGen(this.Query, "ListadoEstado", this.NomColumnas);

        return this.Tabla;
    }
Example #7
0
        public Tablas TablasGetById(string Id)
        {
            try
            {
                DataSet          ds        = new DataSet();
                Conexion         oConexion = new Conexion();
                OracleConnection cn        = oConexion.getConexion();
                cn.Open();

                string sqlSelect = "select * from tablas " +
                                   "where TAB_CODIGO='" + Id + "'";

                cmd     = new OracleCommand(sqlSelect, cn);
                adapter = new OracleDataAdapter(cmd);
                cmd.ExecuteNonQuery();
                adapter.Fill(ds);


                DataTable dt;
                dt = ds.Tables[0];

                Tablas NewEnt = new Tablas();

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    NewEnt = CargarTablas(dr);
                }
                return(NewEnt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void FillControls(int i)
 {
     txtCodigo.Text          = GridView1.Rows[i].Cells[1].Text;
     txtPrecio.Text          = GridView1.Rows[i].Cells[4].Text;
     ddlInicio.SelectedIndex = Tablas.GetCode(Tablas.sectores, Convert.ToInt32(GridView1.Rows[i].Cells[2].Text), "cod_sector");
     ddlFin.SelectedIndex    = Tablas.GetCode(Tablas.sectores, Convert.ToInt32(GridView1.Rows[i].Cells[3].Text), "cod_sector");
 }
        public override global::System.Data.DataSet Clone()
        {
            Tablas cln = ((Tablas)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Example #10
0
        public ActionResult Detalle(string id)
        {
            Tablas t        = new Tablas();
            Tipo   empleado = t.tipos.Single(tipo =>
                                             tipo.cod_tipo == id);

            return(View(empleado));
        }
Example #11
0
        public DataTable TablasBusquedaGetAllFilter(string Campos, Admin oAdmin)
        {
            Tablas oTabla = new Tablas();

            oTabla = TablasGetById(oAdmin.TabCodigo);
            TablasImpl oTablasImpl = new TablasImpl();

            return(oTablasImpl.TablasBusquedaGetAllFilter(oTabla.TabQueryJoin, Campos, oTabla.TabQueryFilter, oAdmin));
        }
Example #12
0
        public DataTable TablasBusquedaGetAllFilter(string Codigo, string Campos, string filterCampos, string filterValores)
        {
            Tablas oTabla = new Tablas();

            oTabla = TablasGetById(Codigo);
            TablasImpl oTablasImpl = new TablasImpl();

            return(oTablasImpl.TablasBusquedaGetAllFilter(oTabla.TabQueryJoin, Campos, filterCampos, filterValores, oTabla.TabQueryFilter));
        }
Example #13
0
        public void MostrarTabla(string Tabla)
        {
            // Obtener de DetallesColumnasTablas todos los campos de la tabla menos el campo clave
            // Pasar esos campos a un arreglo de campos y valores
            // actualizar
            Tablas    otabla    = new Tablas();
            TablasBus tablasGrd = new TablasBus();

            tablasGrd.MostrarEstructura(Tabla);
        }
Example #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="t"></param>
        /// <param name="tran"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public List <Tablas> ListSelectSQL(Tablas t, string parameter, MySqlTransaction tran)
        {
            DataSet ds = this.DataSetSelectSQL(t, parameter, tran);

            if (ds != null)
            {
                return(t.ListSelectSQL(ds));
            }

            return(null);
        }
Example #15
0
        public string Get()
        {
            Tablas tab    = new Tablas();
            string result = string.Empty;

            for (int i = 0; i < 9; i++)
            {
                result += multiplicar(i);
            }
            return(result);
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="t"></param>
        /// <param name="tran"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public DataSet DataSetSelectSQL(Tablas t, string parameter, MySqlTransaction tran)
        {
            string strQuery = t.DataSetSelectSQL(parameter);

            if (strQuery != null)
            {
                return(this.GetDataSet(strQuery, tran));
            }

            return(null);
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            Tablas ds = new Tablas();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Example #18
0
        public JsonResult agregarTablas(Tablas con)
        {
            var seguridad = new TablasManager();

            return(Json(new
            {
                Success = "OK",
                Result = seguridad.agregarTablas(con,
                                                 (long)HttpContext.Session["IdSesion"]
                                                 )
            }));
        }
Example #19
0
        private Type ObtenerTipoDeTabla(Tablas EnumeracionTipoTabla)
        {
            Type Tipo = null;

            switch (EnumeracionTipoTabla)
            {
            case Tablas.DatosProvisionados:
            {
                Tipo = typeof(DatosProvisionados);
            }
            break;

            case Tablas.Persona:
            {
                Tipo = typeof(Persona);
            }
            break;

            case Tablas.Usuario:
            {
                Tipo = typeof(Usuario);
            }
            break;

            case Tablas.Estudiante:
            {
                Tipo = typeof(Estudiante);
            }
            break;

            case Tablas.Empadronado:
            {
                Tipo = typeof(Empadronado);
            }
            break;

            case Tablas.Profesor:
            {
                Tipo = typeof(Profesor);
            }
            break;

            case Tablas.TieneUsuarioPerfilEnfasis:
            {
                Tipo = typeof(Tiene_Usuario_Perfil_Enfasis);
            }
            break;
            }
            return(Tipo);
        }
Example #20
0
 public string agregarTablas(Tablas cuenta, long idSesion)
 {
     try
     {
         using (EnerCable.Models.DB.EnercableConexion db = new EnerCable.Models.DB.EnercableConexion())
         {
             int _x = db.GuardarTablas(cuenta.IdTabla, cuenta.Tabla, cuenta.Ejercicio, (bool)cuenta.Activo, cuenta.TablaNCRBON, idSesion);
         }
         return("OK");
     }
     catch (Exception ex)
     {
         return(ex.InnerException.Message);
     }
 }
Example #21
0
 private Tablas CargarTablas(DataRow dr)
 {
     try
     {
         Tablas oObjeto = new Tablas();
         oObjeto.TabCodigo      = dr["TAB_CODIGO"].ToString();
         oObjeto.TabNombre      = dr["TAB_NOMBRE"].ToString();
         oObjeto.TabDescripcion = dr["TAB_DESCRIPCION"].ToString();
         oObjeto.TabQueryJoin   = dr["TAB_QUERY_JOIN"].ToString();
         oObjeto.TabQueryFilter = dr["TAB_QUERY_FILTER"].ToString();
         return(oObjeto);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #22
0
        private DataTable ObtenerTabla(Tablas EnumeracionTipoTabla)
        {
            Type      Tipo = ObtenerTipoDeTabla(EnumeracionTipoTabla);
            DataTable dt   = null;

            if (Tipo != null)
            {
                PropertyInfo[] propiedadesDeTipo = Tipo.GetProperties();
                dt = new DataTable(Tipo.Name);

                foreach (PropertyInfo propiedad in propiedadesDeTipo)
                {
                    dt.Columns.Add(propiedad.Name, Nullable.GetUnderlyingType(propiedad.PropertyType) ?? propiedad.PropertyType);
                }
            }
            return(dt);
        }
Example #23
0
        // Evento de cambio del indez de la combo de zonas que trae las localidades correspondientes
        private void cmbZonas_SelectedIndexChanged(object sender, EventArgs e)
        {
            App.ShowMsg("Cargando...");

            // Cuando cambia de zona, traer las localidades pertenecientes
            m_leLocalidades = Tablas.LocGetLocalidadesZona(cmbZonas.SelectedStrCode, m_smResult);
            if (MsgRuts.AnalizeError(this, m_smResult))
            {
                return;
            }
            m_leLocalidades.AddExprColumn("Deleted", typeof(decimal), "0");
            cmbLocalidades.FillFromStrLEntidad(m_leLocalidades, "loc_ecd_codpost", "loc_ede_nombre", "Deleted");
            cmbLocalidades.AddStrCD("", "", 0);
            cmbLocalidades.SelectedStrCode = "";

            App.HideMsg();
        }
Example #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="t"></param>
        /// <param name="trans"></param>
        /// <returns></returns>
        public int InsertSQL(Tablas t, MySqlTransaction trans)
        {
            int cuantos = 0;

            try
            {
                //MySqlTransaction trans = this.StartTransaction(false);

                string[] listaInserciones = t.InsertSQL();
                for (int i = 0; i < listaInserciones.Length; i++)
                {
                    if (listaInserciones[i] != null)
                    {
                        if (LastInsertedValue != 0)
                        {
                            listaInserciones[i] = SetParameterLastInsertedValue(listaInserciones[i], "<LastInsertedValue>", LastInsertedValue);
                        }

                        cuantos += this.ExecuteNonQuery(listaInserciones[i], trans);
                        if (LastInsertedValue != 0)
                        {
                            t.InsertedId = LastInsertedValue;
                        }
                    }
                }

                //this.Commit(trans);

                return(cuantos);
            }
            catch (MySqlException e)
            {
                logDebugView.Error("(GestorBaseDatos-InsertSQL):", e);
                logFile.Error("(GestorBaseDatos-InsertSQL):", e);

                return(0);

                /**
                 * AGL. ID.83/84. A este nivel, las excepciones se deberían enviar a niveles superiores..
                 * */
                /** return 0; */
                //throw e;
                /** Fin Modificacion */
            }
        }
Example #25
0
        // Evento de load del form que se encarga de cargar todo en pantalla
        private void BusquedaClientesSecretaria_Load(object sender, EventArgs e)
        {
            App.ShowMsg("Cargando...");

            ListaEntidades marcas = Bll.Tablas.MrcUpFull(true, m_smResult);

            if (MsgRuts.AnalizeError(this, m_smResult))
            {
                return;
            }
            cargaCombo(marcas, cdcMarcas, Bel.EMarca.CodCmp, Bel.EMarca.DesCmp);

            cdcTipoCliente.AddStrCD("AP", "AREAS PROTEGIDAS");
            cdcTipoCliente.AddStrCD("SD", "SOCIOS DIRECTOS");
            cdcTipoCliente.AddStrCD("", "");
            cdcTipoCliente.SelectedStrCode = "";

            // Trae todas las zonas existentes a un comboBox
            m_leZonas = Tablas.ZnsUpFull(false, m_smResult);
            if (MsgRuts.AnalizeError(this, m_smResult))
            {
                return;
            }
            cargaCombo(m_leZonas, cmbZonas, Bel.EZona.CodCmp, Bel.EZona.NombreCmp);

            // Mostramos en pantalla los filtros cargados.
            neNumero.Text                  = m_bsBusqueda.Numero;
            neNumeroAvalon.Text            = m_bsBusqueda.NumeroAvalon;
            teRSocial.Text                 = m_bsBusqueda.Rsocial;
            teNombreFant.Text              = m_bsBusqueda.NFant;
            teCargador.Text                = m_bsBusqueda.Cargador;
            teCodVend.Text                 = m_bsBusqueda.CodVend;
            cdcMarcas.SelectedStrCode      = m_bsBusqueda.Marca.PadLeft(2, ' ');
            cmbZonas.SelectedStrCode       = m_bsBusqueda.Zona.PadLeft(2, ' ');
            cmbLocalidades.SelectedStrCode = m_bsBusqueda.Loc.PadLeft(8, ' ');
            teDir.Text      = m_bsBusqueda.Dir;
            neAltura.Text   = m_bsBusqueda.Altura;
            teTelefono.Text = m_bsBusqueda.Telefono;
            cdcTipoCliente.SelectedStrCode = m_bsBusqueda.TipoCliente.PadLeft(2, ' ');

            // Chequeamos los radiobuttons correspondientes a cada filtro.
            checkRadioButton(m_bsBusqueda.Vendido, rbVndSi, rbVndNo, rbVndAmbos);

            App.HideMsg();
        }
Example #26
0
        private void ResultadoLlamada_Load(object sender, EventArgs e)
        {
            App.ShowMsg("Cargando...");

            //Aplicamos permisos
            App.ApplySecurity(this);

            //---Trae todas los motivos de llamada existentes
            motivosLlamadas = Tablas.MtlUpFull(false, m_smResult);
            if (MsgRuts.AnalizeError(this, m_smResult))
            {
                return;
            }
            motivosLlamadas.AddExprColumn("Deleted", typeof(decimal), "0");

            // Cargamos todas las categorias existentes
            categoriasLlamadas = Tablas.CtlUpFull(false, m_smResult);
            if (MsgRuts.AnalizeError(this, m_smResult))
            {
                return;
            }
            categoriasLlamadas.AddExprColumn("Deleted", typeof(decimal), "0");

            cdcCategorias.FillFromStrLEntidad(categoriasLlamadas, Bel.ECategoriaLlamada.CodCmp, Bel.ECategoriaLlamada.DesCmp, "Deleted");
            cdcMotivos.FillFromStrLEntidad(motivosLlamadas, Bel.EMotivosLlamada.CodCmp, Bel.EMotivosLlamada.DesCmp, "Deleted");

            Bel.ECliente l_eCliente = Bll.Clientes.Get(m_intNumCliente, true, m_smResult);
            if (MsgRuts.AnalizeError(this, m_smResult))
            {
                return;
            }

            teNTelefono.Text = l_eCliente.Telefono1.Trim() != "" ? l_eCliente.Telefono1 : l_eCliente.Celular;

            rbSalientes.Checked = true;

            cambiarVisibilidadOperacionesCorrespondientes(l_eCliente);

            // TODO: Borrar cuando usemos estos botones.
            gbRecupero.Location = new System.Drawing.Point(-1000, -1000);
            gbBaja.Location     = new System.Drawing.Point(-1000, -1000);

            App.HideMsg();
        }
Example #27
0
        public bool dropTable(string nombre)
        {
            int index = -1;

            for (int i = 0; i < tablas.Count; i++)
            {
                if (tablas.ElementAt(i).Name.ToLower().Equals(nombre.ToLower()))
                {
                    index = i;
                }
            }

            if (index != -1)
            {
                Tablas.RemoveAt(index);
                return(true);
            }
            return(false);
        }
Example #28
0
        public int TablasAdd(Tablas oTablas)
        {
            try
            {
                Conexion         oConexion = new Conexion();
                OracleConnection cn        = oConexion.getConexion();
                cn.Open();

                ds  = new DataSet();
                cmd = new OracleCommand("insert into TABLAS(TAB_CODIGO, TAB_NOMBRE, TAB_DESCRIPCION, TAB_QUERY_JOIN) " +
                                        "values('" + oTablas.TabCodigo + "', '" + oTablas.TabNombre + "', '" + oTablas.TabDescripcion + "','" + oTablas.TabQueryJoin + "','" + oTablas.TabQueryFilter + "')", cn);
                adapter  = new OracleDataAdapter(cmd);
                response = cmd.ExecuteNonQuery();
                cn.Close();
                return(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #29
0
        public ActionResult verBeneficiarios(int numeroCuenta)
        {
            List <Beneficiarios> beneficariosList = SP_ProcedureBeneficiario.SeleccionarBeneficiarios(numeroCuenta).ToList();
            List <Cliente>       clientesList     = new List <Cliente>();
            List <Parentezco>    parentezcoList   = new List <Parentezco>();

            foreach (var item in beneficariosList)
            {
                Cliente cliente = SP_ProcedureCliente.SeleccionarClientePorCedula(item.ValorDocumentoIdentidadBeneficiario);
                clientesList.Add(cliente);
                Parentezco parentezco = SP_ProcedureParentezco.SeleccionarParentezco(item.ParentezcoId);
                parentezcoList.Add(parentezco);
            }
            Tablas tabla = new Tablas();

            tabla.ListaDeBeneficiarios = beneficariosList;
            tabla.ListaDeClientes      = clientesList;
            tabla.ListaDeParentezcos   = parentezcoList;

            TempData["WarningPorcentage"] = SP_ProcedureVerificarPorcentajeBeneficiarios.VerificarPorcentaje(numeroCuenta);;
            return(View("verBeneficiarios", tabla));
        }
Example #30
0
        //PRIMER METODO EN EJECUTARCE AL CREARCE EL FORMULARIO
        //ENCARGADO DE ADAPTAR LA GRILLA PARA CONTENER TODO TIPO DE TABLAS
        public void Inicializar(string tabla, bool claveSecuencia)
        {
            Tabla          = tabla;
            ClaveSecuencia = claveSecuencia;

            _filtroCampos  = "";
            _filtroValores = "";
            _Campo         = "";
            _Checks        = "";
            _Combos        = "";

            _dtCombo = new DataTable();

            _dtCombo.Columns.Add("DctColumna", typeof(string));
            _dtCombo.Columns.Add("DctDescripcion", typeof(string));

            DetallesColumnasTablasBus oDetalleBus = new DetallesColumnasTablasBus();

            /*
             *  SE RECUPERA LAS COLUMAS DE LA TABLA QUE SE VA A CARGAR
             *  DETALLES COLUMNAS TABLAS TRAE MUCHA INFORMACION
             *  DE LOS CAMPOS DE LA BASE DE DATOS Y DE LAS TABLAS
             *  A TRABAJAR, CONTROLAR BIEN CUALES SON ESOS DATOS,
             *  Y INDICAR PARA QUE SIRVE CADA CAMPO, COMO VA A MODIFICAR LA EJECUCION DEL PROGRAMA?
             */
            ListDetalle = oDetalleBus.DetallesColumnasTablasGetByCodigo(tabla);

            /*  DE LAS COLUMAS QUE SE RECUPERAN DE LA BD, SE CONTROLA QUE TIPO DE CONTROL ES
             *  EN EL CASO DE SER COMBO O CHECK
             *
             *  NO SE QUE SE HACE CON LAS VARIABLES _Combos y _Check
             *  TAMBIEN SE HACE LA CARGA DE LA QUERY QUE LUEGO BUSCARA LOS DATOS
             */
            foreach (DetallesColumnasTablas oDetalle in ListDetalle)
            {
                if (oDetalle.DctNroOrden == 1)
                {
                    // ESTO ES PARA PODER GUARDAR EL NOMBRE DE LA COLUMNA
                    ColumnaClave = oDetalle.DctDescripcion;
                }

                //ACA SE PUEDEN CARGAR MAS CONTROLES PARA DARLE VERSATILIDAD A LA GRILLA
                switch (oDetalle.DctTipoControl)
                {
                //          ESTO ESTOY MUY SEGURO QUE SE PUEDE OMITIR TOTAL MENTE......
                case "COMBO":
                {
                    _Combos += ' ' + oDetalle.DctColumna + ' ' + oDetalle.DctDescripcion + ',';
                    break;
                }

                case "CHECK":
                {
                    _Checks += ' ' + oDetalle.DctColumna + ' ' + oDetalle.DctDescripcion + ',';
                    break;
                }
                }
                _Campo = _Campo + ' ' + oDetalle.DctColumna + ' ' + oDetalle.DctDescripcion + ',';
                if ((oDetalle.DctFiltroBusqueda == "S") && (oDetalle.DctTipoControl != "FECHA") && oDetalle.DctTipoControl != "ESTADO")
                {
                    _dtCombo.Rows.Add(oDetalle.DctColumna, oDetalle.DctDescripcion);
                }
                if ((oDetalle.DctFiltroBusqueda == "S") && (oDetalle.DctTipoControl == "FECHA"))
                {
                    _vista.grupoFecha = true;
                    _vista.fechaDesde = DateTime.Now.Date.AddMonths(-1);
                    _vista.fechaHasta = DateTime.Now.Date;
                    _filtroCampos     = _filtroCampos + oDetalle.DctColumna + "&";
                    _Fecha            = oDetalle.DctColumna + "&";
                    _filtroValores    = _filtroValores + _vista.fechaDesde.ToString("dd/MM/yyyy") + "%" + _vista.fechaHasta.ToString("dd/MM/yyyy") + "&";
                }
                if ((oDetalle.DctFiltroBusqueda == "S") && (oDetalle.DctTipoControl == "ESTADO"))
                {
                    _vista.grupoEstado = true;
                    _filtroCampos      = _filtroCampos + oDetalle.DctColumna + "&";
                    _filtroValores     = _filtroValores + _vista.comboEstado.Text + "&";
                }
            }
            //FIN DEL FOREACH

            /*
             * HASTA ACA SE ENCARGO DE PREPARAR LOS DATOS PARA DESPUES CARGAR LA GRILLA
             */
            //SE CARGA EL COMBO DE BUSQUEDA
            oUtil.CargarCombo(_vista.comboBuscar, _dtCombo, "DctColumna", "DctDescripcion");
            if (_Campo.Length > 0)
            {
                _Campo = _Campo.Substring(0, _Campo.Length - 1);
            }

            /*
             * ACA HACE LA BUSQUEDA EN LA BASE DE DATOS
             */
            TablasBus oTablasBus = new TablasBus();
            DataTable dt         = oTablasBus.TablasBusquedaGetAllFilter(tabla, _Campo, _filtroCampos, _filtroValores);

            //CARGAR GRILLA
            _vista.grilla.AutoGenerateColumns = false;
            _vista.cantidad = oUtil.CargarGrilla(_vista.grilla, dt) + " registros";

            //SUBRUTINA ENCARGADA DE QUE LA GRILLA TENGA LAS COLUMNAS DEL TIPO NECESARIA
            generarDT(ListDetalle);
            //SUBRUTINA QUE ENLAZA LOS DATOS RECUPERADOS CON LA GRILLA YA PREPARADA
            vincularDT(_vista.grilla);


            //LA ULTIMA COLUMNA ES EL CONTROL PARA SABER SI LA FILA FUE CREADA, MODIFICADA O ELIMINADA
            _vista.grilla.Columns.Add("ALTERADO", "");
            _vista.grilla.Columns["ALTERADO"].Visible = false;

            if (claveSecuencia)
            {
                _vista.grilla.Columns[ColumnaClave].ReadOnly = true;
            }
            //ESTE METODO SE UTILIZARA PARA ACOMODAR LAS COLUMNAS, CELDAS O CUALQUEIR OTRA PROPIEDAD VISUAL
            //DE LA GRILLA, ORIENTADA A PERSONALIZAR MAS LA GRILLA DEPENDIENDO LA TABLA QUE SE LE PIDA
            // TRABAJAR
            presonalizarGrilla(_vista.grilla, tabla);

            //SETEA TODAS LAS ROWS EN ESTADO SIN MODIFICACION
            foreach (DataGridViewRow row in _vista.grilla.Rows)
            {
                if (!row.IsNewRow)
                {
                    row.Cells["ALTERADO"].Value = "0";
                }
            }

            // Obtengo nombre de la tabla
            Tablas otabla = new Tablas();

            otabla = oTablasBus.TablasGetById(tabla);

            // Obtengo la estructura de la tabla con la que cargue la grilla
            //LA ESTRUCTURA SE ENCARGA DESPUES DE AYUDAR A PASAR LOS VALORES A LA CLASE BISSNES DE TABLAS PARA REALIZAR LOS CAMBIOS EN LA BASE DE DATOS
            _estructuraTablaGrilla = oTablasBus.Estructura(otabla.TabNombre);

            // Si la clave es secuencia no permito editarla, caso contrario si
            // La clave se edita unicamente cuando se agrega un nuevo registro, esto se habilita en addnew
            // cuando doy confirmar cambios se debe validar cada uno de los campos teniendo en cuenta los tipos de datos de la tabla y el mapeo
        }
Example #31
0
        //ESTE METODO SE ENCARGA DE IMPACTAR LOS NUEVOS CAMBIOS A LA BASE DE DATOS
        public void ActualizaTabla(string Tabla, string campoClave, bool claveSecuencia)
        {
            // Obtener de DetallesColumnasTablas todos los campos de la tabla menos el campo clave
            // Pasar esos campos a un arreglo de campos y valores
            // actualizar
            bool      datosOK   = true;
            Tablas    otabla    = new Tablas();
            TablasBus tablasGrd = new TablasBus();

            otabla = tablasGrd.TablasGetById(Tabla);


            if (ListDetalle == null)
            {
                DetallesColumnasTablasBus oDetalleGrd = new DetallesColumnasTablasBus();
                ListDetalle = oDetalleGrd.DetallesColumnasTablasGetByCodigo(Tabla);
            }

            //ACA SE RECORREN TODAS LAS ROWS DE LA GRILLA
            foreach (DataGridViewRow row in _vista.grilla.Rows)
            {
                if (!row.IsNewRow)
                {
                    string caso = row.Cells["ALTERADO"].Value.ToString();
                    if (caso != "0")
                    {
                        string[] nombreCampos  = { };
                        string[] valoresCampos = { };
                        string   valorClave    = "";
                        string   columnaClave  = "";
                        int      posicion      = 0;

                        // Actualizar tabla
                        foreach (DetallesColumnasTablas oDetalle in ListDetalle)
                        {
                            posicion++;
                            if (oDetalle.DctDescripcion != campoClave || (row.Cells[_vista.grilla.ColumnCount - 1].Value.ToString() == "3" && oDetalle.DctDescripcion == campoClave && !claveSecuencia))
                            {
                                Array.Resize(ref nombreCampos, nombreCampos.Length + 1);
                                Array.Resize(ref valoresCampos, valoresCampos.Length + 1);
                                nombreCampos[nombreCampos.Length - 1] = oDetalle.DctColumna;

                                if (row.Cells[posicion - 1].Visible)
                                {
                                    if (row.Cells[posicion - 1].ValueType == typeof(DateTime))
                                    {
                                        String fechatmp;
                                        fechatmp = row.Cells[posicion - 1].FormattedValue.ToString();
                                        valoresCampos[valoresCampos.Length - 1] = fechatmp;
                                    }
                                    else
                                    {
                                        if (row.Cells[posicion - 1].Value != null)
                                        {
                                            valoresCampos[valoresCampos.Length - 1] = row.Cells[posicion - 1].Value.ToString();
                                        }
                                        else
                                        {
                                            if (oDetalle.DctTipoControl == "CHKCK")
                                            {
                                                valoresCampos[valoresCampos.Length - 1] = ((DataGridViewCheckBoxCell)row.Cells[posicion - 1]).FalseValue.ToString();
                                            }
                                        }
                                    }
                                }

                                else
                                // Si la columna a actualizar no es visible tiene una homonima visible
                                // Busco la homonima visible y tomo su valor que es el que debo tener en cuenta para actualizar
                                //ACA TENDRIA QUE RECUPERAR EL VALOR DEL cmbLista, pero no lo hace!!!!!!!!!!!!

                                {
                                    object celda = row.Cells[oDetalle.DctColumna];

                                    switch (oDetalle.DctTipoControl)
                                    {
                                    case "COMBO":
                                    {
                                        valoresCampos[valoresCampos.Length - 1] = ((DataGridViewComboBoxCell)celda).Value.ToString();
                                        break;
                                    }

                                    case "CHKCK":
                                    {
                                        valoresCampos[valoresCampos.Length - 1] = ((DataGridViewCheckBoxCell)celda).Value.ToString();

                                        break;
                                    }

                                    case "FECHA":
                                    {
                                        valoresCampos[valoresCampos.Length - 1] = ((DataGridViewTextBoxCell)celda).Value.ToString();
                                        valoresCampos[valoresCampos.Length - 1] = valoresCampos[valoresCampos.Length - 1].Substring(0, 9);
                                        break;
                                    }
                                    }
                                }
                            }
                            else
                            {
                                if (row.Cells[posicion - 1].Value != null)
                                {
                                    valorClave = row.Cells[posicion - 1].Value.ToString();
                                }
                                columnaClave = oDetalle.DctColumna;
                            }
                        }
                        ;
                        //FIN FOREACH DE DETALLES COLUMNA
                        // Para cada registro deberia actualizar su estado si se pudo actualizar
                        switch (caso)
                        {
                        case "1":
                        {
                            // Update
                            // Para cada campo validar que tenga el tipo de dato adecuado
                            // contra la estructura de la tabla que esta en _estructuraTablaGrilla datatable
                            // Si todos los campos menos la clave son validos actualizo
                            foreach (DataRow oCampo in _estructuraTablaGrilla.Rows)
                            {
                                int pos;
                                pos = Array.IndexOf(nombreCampos, oCampo.ItemArray[2]);
                                if (pos >= 0 && datosOK)
                                {
                                    datosOK = (oUtil.TipoDatoValido(valoresCampos[pos], oCampo.ItemArray[4].ToString()));
                                }
                                //MessageBox.Show(oCampo.ItemArray[2].ToString()); // campo
                            }
                            if (datosOK && tablasGrd.TablaActualizaGrid(otabla.TabNombre, nombreCampos, valoresCampos, columnaClave + "='" + valorClave + "'", "U"))
                            {
                                row.Cells[_vista.grilla.ColumnCount - 1].Value = "0";
                            }
                            break;
                        }

                        case "2":
                        {
                            // Delete
                            if (datosOK && tablasGrd.TablaActualizaGrid(otabla.TabNombre, nombreCampos, valoresCampos, columnaClave + "='" + valorClave + "'", "D"))
                            {
                                _vista.grilla.Rows.Remove(row);
                                row.Cells[_vista.grilla.ColumnCount - 1].Value = "0";
                            }
                            break;
                        }

                        case "3":
                        {
                            // Insert
                            // Para cada campo validar que tenga el tipo de dato adecuado
                            // contra la estructura de la tabla que esta en _estructuraTablaGrilla datatable
                            // Si todos los campos inclusive la clave, si no es secuencia, son validos actualizo
                            foreach (DataRow oCampo in _estructuraTablaGrilla.Rows)
                            {
                                int pos;
                                pos = Array.IndexOf(nombreCampos, oCampo.ItemArray[2]);
                                if (pos >= 0 && datosOK)
                                {
                                    datosOK = (oUtil.TipoDatoValido(valoresCampos[pos], oCampo.ItemArray[4].ToString()));
                                    if (valoresCampos[pos] != null)
                                    {
                                        datosOK = valoresCampos[pos].Length > 0 || oCampo.ItemArray[8].ToString() == "Y";
                                    }
                                }
                            }
                            if (claveSecuencia)
                            {
                                if (datosOK && tablasGrd.TablaActualizaGrid(otabla.TabNombre, nombreCampos, valoresCampos, columnaClave + "='" + valorClave + "'", "IN"))
                                {
                                    row.Cells[_vista.grilla.ColumnCount - 1].Value = "0";
                                }
                            }
                            else
                            {
                                if (datosOK && tablasGrd.TablaActualizaGrid(otabla.TabNombre, nombreCampos, valoresCampos, columnaClave + "='" + valorClave + "'", "I"))
                                {
                                    row.Cells[_vista.grilla.ColumnCount - 1].Value = "0";
                                }
                            }


                            break;
                        }
                        }
                    }
                    ;
                    if (!datosOK)
                    {
                        MessageBox.Show("Error al actualizar los datos, Revice las filas resaltadas.");
                    }
                }
            }
        }
Example #32
0
 private void rellenaVentana()
 {
     tabla = new Tablas ();
     combohelper = new ComboBoxHelper (App.Instance.DbConnection,this.miCombo,"articulo","id",0,"televisor");
     inf = new Informacion ();
     helper = new TreeViewHelper (inf.getTreviewTelevisor(), "select * from televisor");
     helper2 = new TreeViewHelper (inf.getTreviewComprador(), "select saldo from comprador");
     Show ();
 }