private void btnBusqAct_Click(object sender, EventArgs e)
        {
            try
            {
                frmBuscActivos form = new frmBuscActivos("BAJAS");

                var result = form.ShowDialog();

                if (result == DialogResult.OK)
                {
                    // muestra los datos del activo
                    Modelos.ActivosDesc activo = form._activoSelecc;
                    string[]            array  = activo.descripcion.Split('&');

                    this.tbNombre.Text         = activo.nombreCorto;
                    this.tbTipo.Text           = activo.tipo;
                    this.tbSucursal.Text       = activo.sucursal;
                    this.tbArea.Text           = activo.area;
                    this.tbMarca.Text          = array[0];
                    this.tbModelo.Text         = array[1];
                    this.tbNumSerie.Text       = array[2];
                    this.tbColor.Text          = array[3];
                    this.tbCosto.Text          = array[4];
                    this.tbFactura.Text        = array[5];
                    this.dtpFechaConsulta.Text = array[6];
                    this.tbDescripcion.Text    = array[7];
                    this.tbUsuario.Text        = activo.usuario;

                    this.lbNumetiqueta.Text = activo.numEtiqueta;
                    this.lbCveActivo.Text   = activo.claveActivo;

                    this._idActivo = activo.idActivo;

                    this._usuario  = activo.usuario;
                    this._sucursal = activo.sucursal;

                    // reinicia campos
                    this.cbMotivo.SelectedIndex = -1;
                    this.tbDetalles.Text        = string.Empty;
                }

                if (result == DialogResult.Cancel)
                {
                    MessageBox.Show("Operación Cancelada", "Activos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, "Activos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 2
0
        private void btnBusqAct_Click(object sender, EventArgs e)
        {
            try
            {
                frmBuscActivos form = new frmBuscActivos("MODIFICACION");

                var result = form.ShowDialog();

                if (result == DialogResult.OK)
                {
                    this.inicializaValores();

                    // trae permisos de tipos
                    this._tipos = this._catalogosNegocio.getTipo(form._idTipo);

                    // muestra los datos del activo
                    this._activoAntes = form._activoSelecc;

                    string[] array = this._activoAntes.descripcion.Split('&');

                    this.tbNombre.Text = this._activoAntes.nombreCorto;

                    this.tbMarca.Text       = array[0];
                    this.tbModelo.Text      = array[1];
                    this.tbNumSerie.Text    = array[2];
                    this.tbColor.Text       = array[3];
                    this.tbCosto.Text       = array[4];
                    this.tbFactura.Text     = array[5];
                    this.dtpFecha.Text      = array[6];
                    this.tbDescripcion.Text = array[7];
                    this.tbUsuario.Text     = this._activoAntes.usuario;

                    this.lbNumetiqueta.Text = this._activoAntes.numEtiqueta;
                    this.lbCveActivo.Text   = this._activoAntes.claveActivo;

                    this._idActivo = this._activoAntes.idActivo;

                    this.cmbTipo.SelectedValue     = this._activoAntes.idTipo;
                    this.cmbSucursal.SelectedValue = this._activoAntes.idSucursal;
                    this.cargaAreas(this._activoAntes.idSucursal);
                    this.cmbArea.SelectedValue = this._activoAntes.idArea;

                    this._idTipoAnt = this._activoAntes.idTipo;
                    this._idAreaAnt = this._activoAntes.idArea;

                    if (!string.IsNullOrEmpty(this._activoAntes.usuario))
                    {
                        MessageBox.Show(
                            "No es permitido cambiar la Sucursal\n" +
                            "El Activo pertenece a una responsiva\n" +
                            "Para realizar el cambio debe ser por medio de un traspaso", "Activos",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);

                        // this.cmbArea.Enabled = false;
                        this.cmbSucursal.Enabled = false;
                    }
                }

                if (result == DialogResult.Cancel)
                {
                    if (string.IsNullOrEmpty(this.tbNombre.Text))
                    {
                        this.tbNombre.ReadOnly      = true;
                        this.tbMarca.ReadOnly       = true;
                        this.tbModelo.ReadOnly      = true;
                        this.tbNumSerie.ReadOnly    = true;
                        this.tbColor.ReadOnly       = true;
                        this.tbCosto.ReadOnly       = true;
                        this.tbFactura.ReadOnly     = true;
                        this.tbDescripcion.ReadOnly = true;
                        this.dtpFecha.Enabled       = false;
                    }

                    MessageBox.Show("Operación Cancelada", "Activos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, "Activos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }