Пример #1
0
        public void GetValorFromDS(bool esNuevo, int posicion = 0)
        {
            DataColumn MyColumna;
            DataRow    MyFila;
            ELRUtils   util   = new ELRUtils();
            string     NDecim = "N";

            string valor = "";

            try
            {
                valor = ValorPorDefecto;

                if (DSData != null)
                {
                    if (NombreTabla.Trim() == "")
                    {
                        if (!DSData.Tables[0].Columns.Contains(CampoData))
                        {
                            throw new Exception("El Campo [" + CampoData + "] No Existe!!");
                        }

                        MyColumna = DSData.Tables[0].Columns[CampoData];
                        MyFila    = DSData.Tables[0].Rows[posicion];
                    }
                    else
                    {
                        if (!DSData.Tables[NombreTabla].Columns.Contains(CampoData))
                        {
                            throw new Exception("El Campo [" + CampoData + "] No Existe!!");
                        }

                        MyColumna = DSData.Tables[NombreTabla].Columns[CampoData];
                        MyFila    = DSData.Tables[NombreTabla].Rows[posicion];
                    }

                    if (MyColumna.MaxLength > 0)
                    {
                        MaxLength = MyColumna.MaxLength;
                    }

                    //APLICAMOS FORMATO DECIMAL
                    if ((MyColumna.DataType == typeof(Decimal)) || (MyColumna.DataType == typeof(Double)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0.0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.DecimalPositivo;
                            if (Decimales <= 0)
                            {
                                Decimales = 2;
                            }
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        NDecim   += Decimales.ToString();
                        this.Text = util.ConvertirANumero(valor).ToString(NDecim);
                    }
                    else if ((MyColumna.DataType == typeof(Int16)) || (MyColumna.DataType == typeof(Int32)) || (MyColumna.DataType == typeof(Int64)) || (MyColumna.DataType == typeof(Single)) || (MyColumna.DataType == typeof(SByte)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.NumerosEnteros;
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        this.Text = valor;
                    }
                    else if ((MyColumna.DataType == typeof(UInt16)) || (MyColumna.DataType == typeof(UInt32)) || (MyColumna.DataType == typeof(UInt64)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.NumerosEnterosPositivos;
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        this.Text = valor;
                    }
                    else
                    {
                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila);
                        }

                        if (CampoData.ToUpper().Contains("CEDULA"))
                        {
                            valor = util.FormatearCedulaRNC(valor);
                        }
                        else if (CampoData.ToUpper().Contains("RNC"))
                        {
                            valor = util.FormatearCedulaRNC(valor);
                        }
                        else if (CampoData.ToUpper().Contains("TELEFONO"))
                        {
                            valor = util.FormatearTelefono(valor);
                        }
                        else if (CampoData.ToUpper().Contains("CELULAR"))
                        {
                            valor = util.FormatearTelefono(valor);
                        }


                        this.Text = valor.Trim();
                    }
                }

                if (EsAutoGenerado)
                {
                    this.Enabled = false;
                }
                if ((!esNuevo) && (this.Enabled))
                {
                    this.Enabled = EsEditable;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        public void MostrarEnControles(DataRow dr)
        {
            ELRUtils objUtil       = new ELRUtils();
            string   nombreControl = "";
            string   valor         = "0";

            try
            {
                drFilaSel = dr;

                if (AMostrar != null)
                {
                    foreach (ControlesMostrar item in AMostrar)
                    {
                        if (item.LabelControl != null)
                        {
                            if (dr != null)
                            {
                                item.LabelControl.Text = dr[item.NombreCampo].ToString();
                            }
                            else
                            {
                                item.LabelControl.Text = item.ValorPorDefecto;
                            }

                            nombreControl = item.LabelControl.Name;
                        }


                        if (item.TextBoxControl != null)
                        {
                            nombreControl = item.TextBoxControl.Name;

                            if (dr != null)
                            {
                                valor = objUtil.GetAsString(item.NombreCampo, dr, item.ValorPorDefecto);
                                if (item.NombreCampo.ToUpper() == "CEDULARNC")
                                {
                                    item.TextBoxControl.Text = objUtil.FormatearCedulaRNC(valor);
                                }
                                else
                                {
                                    item.TextBoxControl.Text = valor;
                                }

                                if (item.TextBoxControl != this)
                                {
                                    if (item.EsHabilitar)
                                    {
                                        item.TextBoxControl.Enabled = false;
                                    }
                                }
                            }
                            else
                            {
                                item.TextBoxControl.Text = item.ValorPorDefecto;
                                if (item.EsHabilitar)
                                {
                                    item.TextBoxControl.Enabled = true;
                                }
                            }
                        }


                        if (item.ComboBoxControl != null)
                        {
                            nombreControl = item.ComboBoxControl.Name;

                            if (dr != null)
                            {
                                valor = objUtil.GetAsString(item.NombreCampo, dr, "0");

                                if (item.ComboBoxControl.ValueMember.Trim() != "")
                                {
                                    item.ComboBoxControl.SelectedValue = valor;
                                }
                                else
                                {
                                    item.ComboBoxControl.Text = valor;
                                }

                                if (item.EsHabilitar)
                                {
                                    item.ComboBoxControl.Enabled = false;
                                }
                            }
                            else if (item.EsHabilitar)
                            {
                                item.ComboBoxControl.Enabled = true;
                            }
                        }

                        if (item.NumericUpDownControl != null)
                        {
                            nombreControl = item.NumericUpDownControl.Name;

                            if (dr != null)
                            {
                                item.NumericUpDownControl.Value = objUtil.GetAsDecimal(item.NombreCampo.ToString(), dr, 0);

                                if (item.EsHabilitar)
                                {
                                    item.NumericUpDownControl.Enabled = false;
                                }
                            }
                            else
                            {
                                item.NumericUpDownControl.Value = 0;
                                if (item.EsHabilitar)
                                {
                                    item.NumericUpDownControl.Enabled = true;
                                }
                            }
                        }
                    }
                }

                //if ((drFilaSel != null) && (CampoBusquedaID.Trim() != "")) this.Text = dr[CampoBusquedaID].ToString();
                // this.Text = "0";
            }
            catch (Exception ex)
            {
                objUtil.MostrarMensajeError("Error en " + nombreControl + ", " + ex.Message);
            }
        }
        void MostrarMenuFlatLayout(string aBuscar = "")
        {
            string menuId, descripcion = "";
            int    moduloId = 0;
            string nombreModulo = "", nombreForm = "", tipoForm = "0";
            bool   esModal = false;

            DataRow[] filas;
            DataRow   fila0;
            int       carpetaId      = 0;
            bool      esMenuConsulta = false;

            try
            {
                flpMenu.Visible = false;
                flpMenu.Controls.Clear();
                aBuscar = aBuscar.Trim();

                if (DTOpcionesMenu == null)
                {
                    return;
                }
                if (DTOpcionesMenu.Rows.Count <= 0)
                {
                    return;
                }

                if (cboBuscarPorMenu.SelectedValue != null)
                {
                    carpetaId = int.Parse(cboBuscarPorMenu.SelectedValue.ToString());
                }

                foreach (DataRow item in DTOpcionesMenu.Rows)
                {
                    menuId         = objUtil.GetAsString("Menu_Id", item, "0");
                    descripcion    = objUtil.GetAsString("Nombre", item).Trim();
                    moduloId       = objUtil.GetAsInt("Modulo_Id", item);
                    esMenuConsulta = objUtil.GetAsBoolean("EsMenuConsulta", item);

                    if (aBuscar != "")
                    {
                        if (!descripcion.ToUpper().Contains(aBuscar))
                        {
                            continue;
                        }
                    }


                    if (esMenuConsulta == false && moduloId != 10)
                    {
                        continue;
                    }
                    if (carpetaId > 0 && moduloId != carpetaId)
                    {
                        continue;
                    }

                    filas = DTMenuPrincipal.Select("Modulo_Id = " + moduloId.ToString());
                    if (filas.Count() > 0)
                    {
                        fila0        = filas[0];
                        nombreModulo = objUtil.GetAsString("Carpeta", fila0);
                    }

                    Button btn = new Button();
                    btn.Name    = "btnFP" + menuId;
                    btn.Text    = descripcion;
                    descripcion = nombreModulo + " => " + descripcion;
                    toolTip1.SetToolTip(btn, descripcion);
                    btn.Width  = 120;
                    btn.Height = 100;

                    //ASIGNAMOS EL FORM A EJECUTAR
                    nombreForm = objUtil.GetAsString("Formulario_AEjecutar", item).Trim();
                    esModal    = objUtil.GetAsBoolean("EsModal", item);
                    tipoForm   = objUtil.GetAsString("TipoFormulario", item);
                    if (nombreForm != "")
                    {
                        nombreForm += ";" + menuId.ToString();
                        if (esModal)
                        {
                            nombreForm += ";1;" + tipoForm;
                        }
                        else
                        {
                            nombreForm += ";0;" + tipoForm;
                        }

                        btn.Tag    = nombreForm;
                        btn.Click += new EventHandler(btnFlpClick);
                    }

                    btn.MouseLeave += new EventHandler(btnMouseLeave);
                    btn.MouseHover += new EventHandler(btnMouseHover);

                    flpMenu.Controls.Add(btn);
                }

                flpMenu.Visible = true;
            }
            catch (Exception)
            {
                throw;
            }
        }