Example #1
0
        private void guardar(int tipoGuardar)
        {
            //SE VALIDA SI TODOS LOS TEXTBOX HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this, typeof(TextBox));

            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            control = GLOBALES.VALIDAR(this, typeof(MaskedTextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            int idempresa;

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            eh             = new Empresas.Core.EmpresasHelper();
            eh.Command     = cmd;

            Empresas.Core.Empresas em = new Empresas.Core.Empresas();
            em.nombre            = txtNombre.Text;
            em.rfc               = txtRfc.Text;
            em.registro          = txtRegistroPatronal.Text;
            em.digitoverificador = int.Parse(txtDigitoVerificador.Text);
            em.sindicato         = Convert.ToInt32(chkEsSindicato.Checked);
            em.representante     = txtRepresentante.Text;
            em.activo            = 1;

            dh         = new Direccion.Core.DireccionesHelper();
            dh.Command = cmd;

            Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
            d.calle         = txtCalle.Text;
            d.exterior      = txtExterior.Text;
            d.interior      = txtInterior.Text;
            d.colonia       = txtColonia.Text;
            d.ciudad        = txtMunicipio.Text;
            d.estado        = txtEstado.Text;
            d.pais          = txtPais.Text;
            d.cp            = txtCP.Text;
            d.tipodireccion = GLOBALES.dFISCAL;
            d.tipopersona   = GLOBALES.pEMPRESA;

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    MySqlCommand lastId = eh.insertaEmpresa(em);
                    long         Id     = lastId.LastInsertedId;
                    idempresa   = (int)eh.obtenerIdEmpresa(em);
                    d.idpersona = idempresa;
                    dh.insertaDireccion(d);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar la empresa. \r\n \r\n Error: " + error.Message);
                }
                break;

            case 2:
                try
                {
                    em.idempresa  = _idempresa;
                    d.iddireccion = _iddireccion;
                    d.idpersona   = _idempresa;
                    cnx.Open();
                    eh.actualizaEmpresa(em);
                    dh.actualizaDireccion(d);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar la empresa. \r\n \r\n Error: " + error.Message);
                }
                break;
            }

            switch (tipoGuardar)
            {
            case 0:
                GLOBALES.LIMPIAR(this, typeof(TextBox));
                GLOBALES.LIMPIAR(this, typeof(MaskedTextBox));
                //limpiar(this, typeof(TextBox));
                break;

            case 1:
                if (OnNuevaEmpresa != null)
                {
                    OnNuevaEmpresa(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }
Example #2
0
        private void toolGuardar_Click(object sender, EventArgs e)
        {
            //SE VALIDA SI TODOS LOS CAMPOS HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this, typeof(TextBox));

            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            control = GLOBALES.VALIDAR(this, typeof(MaskedTextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            ch             = new Complementos.Core.ComplementoHelper();
            dh             = new Direccion.Core.DireccionesHelper();
            ch.Command     = cmd;
            dh.Command     = cmd;

            Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
            d.idpersona     = _idEmpleado;
            d.calle         = txtCalle.Text;
            d.exterior      = txtExterior.Text;
            d.interior      = txtInterior.Text;
            d.cp            = txtCP.Text;
            d.colonia       = txtColonia.Text;
            d.ciudad        = txtMunicipio.Text;
            d.estado        = txtEstado.Text;
            d.pais          = txtPais.Text;
            d.tipodireccion = 2;
            d.tipopersona   = 2;

            Complementos.Core.Complemento c = new Complementos.Core.Complemento();
            c.idtrabajador   = _idEmpleado;
            c.contrato       = cmbContrato.SelectedValue.ToString();
            c.jornada        = cmbJornada.SelectedValue.ToString();
            c.iddepartamento = int.Parse(cmbDepartamento.SelectedValue.ToString());
            c.idpuesto       = int.Parse(cmbPuesto.SelectedValue.ToString());
            c.estadocivil    = cmbEstadoCivil.SelectedValue.ToString();
            c.sexo           = cmbSexo.SelectedValue.ToString();
            c.escolaridad    = cmbEscolaridad.SelectedValue.ToString();
            c.horario        = txtHorario.Text;
            c.nocontrol      = txtNoControl.Text;
            c.clinica        = txtClinica.Text;
            c.nacionalidad   = txtNacionalidad.Text;
            c.funciones      = txtFunciones.Text;

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    dh.insertaDireccion(d);
                    ch.insertaComplemento(c);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar los datos. \r\n \r\n Error: " + error.Message);
                    this.Dispose();
                }
                break;

            case 2:
                try
                {
                    d.iddireccion = idDireccion;
                    c.id          = idComplemento;

                    cnx.Open();
                    ch.actualizaComplemento(c);
                    dh.actualizaDireccion(d);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar los datos. \r\n \r\n Error: " + error.Message);
                    this.Dispose();
                }
                break;
            }
        }
Example #3
0
        private void frmEmpresas_Load(object sender, EventArgs e)
        {
            /// _tipoOperacion CONSULTA = 1, EDICION = 2
            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                cnx = new MySqlConnection();
                cnx.ConnectionString = cdn;
                cmd            = new MySqlCommand();
                cmd.Connection = cnx;
                eh             = new Empresas.Core.EmpresasHelper();
                eh.Command     = cmd;

                dh         = new Direccion.Core.DireccionesHelper();
                dh.Command = cmd;

                Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
                d.idpersona   = _idempresa;
                d.tipopersona = 0; ///TIPO PERSONA 0 - Empresas
                List <Empresas.Core.Empresas>     lstEmpresa;
                List <Direccion.Core.Direcciones> lstDireccion;

                try
                {
                    cnx.Open();
                    lstEmpresa   = eh.obtenerEmpresa(_idempresa);
                    lstDireccion = dh.obtenerDireccion(d);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstEmpresa.Count; i++)
                    {
                        txtNombre.Text            = lstEmpresa[i].nombre;
                        txtRepresentante.Text     = lstEmpresa[i].representante;
                        txtRfc.Text               = lstEmpresa[i].rfc;
                        txtRegistroPatronal.Text  = lstEmpresa[i].registro;
                        txtDigitoVerificador.Text = lstEmpresa[i].digitoverificador.ToString();
                        chkEsSindicato.Checked    = Convert.ToBoolean(lstEmpresa[i].sindicato);
                    }

                    for (int i = 0; i < lstDireccion.Count; i++)
                    {
                        _iddireccion      = lstDireccion[i].iddireccion;
                        txtCalle.Text     = lstDireccion[i].calle;
                        txtExterior.Text  = lstDireccion[i].exterior;
                        txtInterior.Text  = lstDireccion[i].interior;
                        txtColonia.Text   = lstDireccion[i].colonia;
                        txtCP.Text        = lstDireccion[i].cp;
                        txtMunicipio.Text = lstDireccion[i].ciudad;
                        txtEstado.Text    = lstDireccion[i].estado;
                        txtPais.Text      = lstDireccion[i].pais;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta Empresa";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(MaskedTextBox));
                    GLOBALES.INHABILITAR(this, typeof(CheckBox));
                }
                else
                {
                    toolTitulo.Text = "Edición Empresa";
                }
            }
        }
Example #4
0
        private void guardar(int tipoGuardar)
        {
            //SE VALIDA SI TODOS LOS TEXTBOX HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this, typeof(TextBox));

            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            control = GLOBALES.VALIDAR(this, typeof(MaskedTextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            int idcliente;

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            ch             = new Clientes.Core.ClientesHelper();
            ch.Command     = cmd;

            Clientes.Core.Clientes cli = new Clientes.Core.Clientes();
            cli.nombre  = txtNombre.Text;
            cli.rfc     = txtRfc.Text;
            cli.estatus = 1;
            cli.plaza   = GLOBALES.IDPLAZA;

            dh         = new Direccion.Core.DireccionesHelper();
            dh.Command = cmd;

            Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
            d.calle    = txtCalle.Text;
            d.exterior = txtExterior.Text;
            d.interior = txtInterior.Text;
            d.colonia  = txtColonia.Text;
            d.ciudad   = txtMunicipio.Text;
            d.estado   = txtEstado.Text;
            d.pais     = txtPais.Text;
            d.cp       = txtCP.Text;
            ///TIPO DIRECCION
            ///0 - Dirección fiscal
            ///1 - Dirección sucursal
            ///2 - Dirección personal
            d.tipodireccion = 0;
            ///TIPO PERSONA
            ///0 - Empresa
            ///1 - Cliente
            ///2 - Empleado
            d.tipopersona = 1;

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    ch.insertaCliente(cli);
                    idcliente   = (int)ch.obtenerIdCliente(cli);
                    d.idpersona = idcliente;
                    dh.insertaDireccion(d);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar el cliente. \r\n \r\n Error: " + error.Message);
                }
                break;

            case 2:
                try
                {
                    cli.idcliente = _idcliente;
                    d.iddireccion = _iddireccion;
                    d.idpersona   = _idcliente;
                    cnx.Open();
                    ch.actualizaCliente(cli);
                    dh.actualizaDireccion(d);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el cliente. \r\n \r\n Error: " + error.Message);
                }
                break;
            }

            switch (tipoGuardar)
            {
            case 0:
                GLOBALES.LIMPIAR(this, typeof(TextBox));
                GLOBALES.LIMPIAR(this, typeof(MaskedTextBox));
                //limpiar(this, typeof(TextBox));
                break;

            case 1:
                if (OnNuevoCliente != null)
                {
                    OnNuevoCliente(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }
Example #5
0
        private void frmComplementos_Load(object sender, EventArgs e)
        {
            CargaComboBox();
            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                cnx = new MySqlConnection();
                cnx.ConnectionString = cdn;
                cmd            = new MySqlCommand();
                cmd.Connection = cnx;
                ch             = new Complementos.Core.ComplementoHelper();
                dh             = new Direccion.Core.DireccionesHelper();
                ch.Command     = cmd;
                dh.Command     = cmd;

                List <Complementos.Core.Complemento> lstComplemento;
                List <Direccion.Core.Direcciones>    lstDireccion;

                Complementos.Core.Complemento c = new Complementos.Core.Complemento();
                c.idtrabajador = _idEmpleado;

                Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
                d.idpersona   = _idEmpleado;
                d.tipopersona = 2;

                try
                {
                    cnx.Open();
                    lstComplemento = ch.obtenerComplemento(c);
                    lstDireccion   = dh.obtenerDireccion(d);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstComplemento.Count; i++)
                    {
                        idComplemento                 = lstComplemento[i].id;
                        cmbContrato.SelectedValue     = lstComplemento[i].contrato;
                        cmbJornada.SelectedValue      = lstComplemento[i].jornada;
                        cmbDepartamento.SelectedValue = lstComplemento[i].iddepartamento;
                        cmbPuesto.SelectedValue       = lstComplemento[i].idpuesto;
                        cmbEstadoCivil.SelectedValue  = lstComplemento[i].estadocivil;
                        cmbSexo.SelectedValue         = lstComplemento[i].sexo;
                        cmbEscolaridad.SelectedValue  = lstComplemento[i].escolaridad;
                        txtHorario.Text               = lstComplemento[i].horario;
                        txtNoControl.Text             = lstComplemento[i].nocontrol;
                        txtClinica.Text               = lstComplemento[i].clinica;
                        txtNacionalidad.Text          = lstComplemento[i].nacionalidad;
                        txtFunciones.Text             = lstComplemento[i].funciones;
                    }

                    for (int j = 0; j < lstDireccion.Count; j++)
                    {
                        idDireccion       = lstDireccion[j].iddireccion;
                        txtCalle.Text     = lstDireccion[j].calle;
                        txtExterior.Text  = lstDireccion[j].exterior;
                        txtInterior.Text  = lstDireccion[j].interior;
                        txtColonia.Text   = lstDireccion[j].colonia;
                        txtCP.Text        = lstDireccion[j].cp;
                        txtMunicipio.Text = lstDireccion[j].ciudad;
                        txtEstado.Text    = lstDireccion[j].estado;
                        txtPais.Text      = lstDireccion[j].pais;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta del Complemento";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(MaskedTextBox));
                    GLOBALES.INHABILITAR(this, typeof(ComboBox));
                }
                else
                {
                    toolTitulo.Text = "Edición del Complemento";
                }
            }
        }
Example #6
0
        private void frmClientes_Load(object sender, EventArgs e)
        {
            /// _tipoOperacion CONSULTA = 1, EDICION = 2
            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                cnx = new MySqlConnection();
                cnx.ConnectionString = cdn;
                cmd            = new MySqlCommand();
                cmd.Connection = cnx;
                ch             = new Clientes.Core.ClientesHelper();
                ch.Command     = cmd;

                dh         = new Direccion.Core.DireccionesHelper();
                dh.Command = cmd;

                Clientes.Core.Clientes cli = new Clientes.Core.Clientes();
                cli.idcliente = _idcliente;

                Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
                d.idpersona   = _idcliente;
                d.tipopersona = 1; ///TIPO PERSONA 1 - Clientes
                List <Clientes.Core.Clientes>     lstCliente;
                List <Direccion.Core.Direcciones> lstDireccion;

                try
                {
                    cnx.Open();
                    lstCliente   = ch.obtenerCliente(cli);
                    lstDireccion = dh.obtenerDireccion(d);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstCliente.Count; i++)
                    {
                        txtNombre.Text = lstCliente[i].nombre;
                        txtRfc.Text    = lstCliente[i].rfc;
                    }

                    for (int i = 0; i < lstDireccion.Count; i++)
                    {
                        _iddireccion      = lstDireccion[i].iddireccion;
                        txtCalle.Text     = lstDireccion[i].calle;
                        txtExterior.Text  = lstDireccion[i].exterior;
                        txtInterior.Text  = lstDireccion[i].interior;
                        txtColonia.Text   = lstDireccion[i].colonia;
                        txtCP.Text        = lstDireccion[i].cp;
                        txtMunicipio.Text = lstDireccion[i].ciudad;
                        txtEstado.Text    = lstDireccion[i].estado;
                        txtPais.Text      = lstDireccion[i].pais;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta Cliente";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(MaskedTextBox));
                }
                else
                {
                    toolTitulo.Text = "Edición Cliente";
                }
            }
        }
Example #7
0
        private void toolGuardar_Click(object sender, EventArgs e)
        {
            //SE VALIDA SI TODOS LOS CAMPOS HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this, typeof(TextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            control = GLOBALES.VALIDAR(this, typeof(MaskedTextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;
            ch = new Complementos.Core.ComplementoHelper();
            dh = new Direccion.Core.DireccionesHelper();
            ah = new Altas.Core.AltasHelper();
            ch.Command = cmd;
            dh.Command = cmd;
            ah.Command = cmd;

            Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
            d.idpersona = _idEmpleado;
            d.calle = txtCalle.Text;
            d.exterior = txtExterior.Text;
            d.interior = txtInterior.Text;
            d.cp = txtCP.Text;
            d.colonia = txtColonia.Text;
            d.ciudad = txtMunicipio.Text;
            d.estado = txtEstado.Text;
            d.pais = txtPais.Text;
            d.tipodireccion = GLOBALES.dPERSONAL;
            d.tipopersona = GLOBALES.pEMPLEADO;

            Complementos.Core.Complemento c = new Complementos.Core.Complemento();
            c.idtrabajador = _idEmpleado;
            c.contrato = int.Parse(cmbContrato.SelectedValue.ToString());
            c.jornada = int.Parse(cmbJornada.SelectedValue.ToString());
            c.estadocivil = int.Parse(cmbEstadoCivil.SelectedValue.ToString());
            c.sexo = int.Parse(cmbSexo.SelectedValue.ToString());
            c.escolaridad = int.Parse(cmbEscolaridad.SelectedValue.ToString());
            c.clinica = txtClinica.Text;
            c.nacionalidad = txtNacionalidad.Text;
            c.tempresa1 = mTelEmpresa.Text;
            c.tempresa2 = mTelEmpresa2.Text;
            c.tempresa3 = mTelEmpresa3.Text;
            c.extension = txtExtension.Text;
            c.cempresa = mCelEmpresa.Text;
            c.cpersonal = mTelPersonal.Text;
            c.email = txtCorreo.Text;
            c.observaciones = txtObservaciones.Text;

            Altas.Core.Altas a = new Altas.Core.Altas();
            a.idtrabajador = _idEmpleado;
            a.jornada = int.Parse(cmbJornada.SelectedValue.ToString());
            a.contrato = int.Parse(cmbContrato.SelectedValue.ToString());
            a.cp = txtCP.Text;
            a.clinica = txtClinica.Text;

            switch (_tipoOperacion)
            {
                case 0:
                    try
                    {
                        cnx.Open();
                        dh.insertaDireccion(d);
                        ch.insertaComplemento(c);
                        ah.actualizaAltaComplemento(a);
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error al ingresar los datos. \r\n \r\n Error: " + error.Message);
                        this.Dispose();
                    }
                    break;
                case 2:
                    try
                    {
                        d.iddireccion = idDireccion;
                        c.id = idComplemento;
                        cnx.Open();
                        ch.actualizaComplemento(c);
                        dh.actualizaDireccion(d);
                        ah.actualizaAltaComplemento(a);
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error al actualizar los datos. \r\n \r\n Error: " + error.Message);
                        this.Dispose();
                    }
                    break;
            }

            this.Dispose();
        }
Example #8
0
        private void frmComplementos_Load(object sender, EventArgs e)
        {
            CargaComboBox();
            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                cnx = new SqlConnection();
                cnx.ConnectionString = cdn;
                cmd = new SqlCommand();
                cmd.Connection = cnx;
                ch = new Complementos.Core.ComplementoHelper();
                dh = new Direccion.Core.DireccionesHelper();
                ch.Command = cmd;
                dh.Command = cmd;

                List<Complementos.Core.Complemento> lstComplemento;
                List<Direccion.Core.Direcciones> lstDireccion;

                Complementos.Core.Complemento c = new Complementos.Core.Complemento();
                c.idtrabajador = _idEmpleado;

                Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
                d.idpersona = _idEmpleado;
                d.tipopersona = GLOBALES.pEMPLEADO;

                try
                {
                    cnx.Open();
                    lstComplemento = ch.obtenerComplemento(c);
                    lstDireccion = dh.obtenerDireccion(d);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstComplemento.Count; i++)
                    {
                        idComplemento = lstComplemento[i].id;
                        cmbContrato.SelectedValue = lstComplemento[i].contrato;
                        cmbJornada.SelectedValue = lstComplemento[i].jornada;
                        cmbEstadoCivil.SelectedValue = lstComplemento[i].estadocivil;
                        cmbSexo.SelectedValue = lstComplemento[i].sexo;
                        cmbEscolaridad.SelectedValue = lstComplemento[i].escolaridad;
                        txtClinica.Text = lstComplemento[i].clinica;
                        txtNacionalidad.Text = lstComplemento[i].nacionalidad;
                        mTelEmpresa.Text = lstComplemento[i].tempresa1;
                        mTelEmpresa2.Text = lstComplemento[i].tempresa2;
                        mTelEmpresa3.Text = lstComplemento[i].tempresa3;
                        txtExtension.Text = lstComplemento[i].extension;
                        mCelEmpresa.Text = lstComplemento[i].cempresa;
                        mTelPersonal.Text = lstComplemento[i].cpersonal;
                        txtCorreo.Text = lstComplemento[i].email;
                        txtObservaciones.Text = lstComplemento[i].observaciones;
                    }

                    for (int j = 0; j < lstDireccion.Count; j++)
                    {
                        idDireccion = lstDireccion[j].iddireccion;
                        txtCalle.Text = lstDireccion[j].calle;
                        txtExterior.Text = lstDireccion[j].exterior;
                        txtInterior.Text = lstDireccion[j].interior;
                        txtColonia.Text = lstDireccion[j].colonia;
                        txtCP.Text = lstDireccion[j].cp;
                        txtMunicipio.Text = lstDireccion[j].ciudad;
                        txtEstado.Text = lstDireccion[j].estado;
                        txtPais.Text = lstDireccion[j].pais;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta del Complemento";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(MaskedTextBox));
                    GLOBALES.INHABILITAR(this, typeof(ComboBox));
                    toolGuardar.Enabled = false;
                }
                else
                    toolTitulo.Text = "Edición del Complemento";
            }
            else
            {
                lblEmpleado.Text = _nombreEmpleado;
            }
        }
Example #9
0
        private void guardar(int tipoGuardar)
        {
            int existe = 0;
            //SE VALIDA SI TODOS LOS TEXTBOX HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this,typeof(TextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            control = GLOBALES.VALIDAR(this, typeof(MaskedTextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            int idempresa;

            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;
            eh = new Empresas.Core.EmpresasHelper();
            eh.Command = cmd;

            Empresas.Core.Empresas em = new Empresas.Core.Empresas();
            em.nombre = txtNombre.Text;
            em.rfc = txtRfc.Text;
            em.registro = txtRegistroPatronal.Text;
            em.digitoverificador = int.Parse(txtDigitoVerificador.Text);
            em.representante = txtRepresentante.Text;
            em.estatus = 1;
            em.regimen = txtRegimen.Text;
            em.certificado = txtCertificado.Text;
            em.llave = txtLlave.Text;
            em.password = txtPassword.Text;
            em.nocertificado = txtNoCertificado.Text;
            em.vigenciacertificado = dtpVigencia.Value.Date;
            em.observacion = txtObservacion.Text;

            dh = new Direccion.Core.DireccionesHelper();
            dh.Command = cmd;

            Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
            d.calle = txtCalle.Text;
            d.exterior = txtExterior.Text;
            d.interior = txtInterior.Text;
            d.colonia = txtColonia.Text;
            d.ciudad = txtMunicipio.Text;
            d.estado = txtEstado.Text;
            d.pais = txtPais.Text;
            d.cp = txtCP.Text;
            d.tipodireccion = GLOBALES.dFISCAL;
            d.tipopersona = GLOBALES.pEMPRESA;

            ih = new Imagen.Core.ImagenesHelper();
            ih.Command = cmd;

            Imagen.Core.Imagenes img = null;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.dias = int.Parse(txtDias.Text);
            periodo.estatus = GLOBALES.ACTIVO;
            periodo.pago = cmbPago.Text;

            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;

            CalculoNomina.Core.PagoNomina pn = new CalculoNomina.Core.PagoNomina();
            pn.idtrabajador = 0;
            pn.idconcepto = 0;
            pn.noconcepto = 0;
            pn.tipoconcepto = "P";
            pn.exento = 0;
            pn.gravado = 0;
            pn.cantidad = 0;
            pn.fechainicio = inicioPeriodo;
            pn.fechafin = finPeriodo;
            pn.noperiodo = 0;
            pn.diaslaborados = 0;
            pn.idusuario = 0;
            pn.tiponomina = 0;
            pn.fechapago = finPeriodo;
            pn.iddepartamento = 0;
            pn.idpuesto = 0;

            try
            {
                if (ImagenAsignada == true)
                {
                    img = new Imagen.Core.Imagenes();
                    img.imagen = GLOBALES.IMAGEN_BYTES(bmp);
                    img.tipopersona = GLOBALES.pEMPRESA;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message, "Error");
            }

            switch (_tipoOperacion)
            {
                case 0:
                    try
                    {
                        cnx.Open();
                        eh.insertaEmpresa(em);
                        idempresa = (int)eh.obtenerIdEmpresa(em);
                        d.idpersona = idempresa;
                        dh.insertaDireccion(d);
                        if (ImagenAsignada == true)
                        {
                            img.idpersona = idempresa;
                            ih.insertaImagen(img);
                        }
                        periodo.idempresa = idempresa;
                        ph.insertaPeriodo(periodo);
                        pn.idempresa = idempresa;
                        nh.insertaPrimerPeriodoNomina(pn);
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error al ingresar la empresa. \r\n \r\n Error: " + error.Message);
                    }
                    break;
                case 2:
                    try
                    {
                        em.idempresa = _idempresa;
                        d.iddireccion = _iddireccion;
                        d.idpersona = _idempresa;

                        cnx.Open();
                        eh.actualizaEmpresa(em);
                        dh.actualizaDireccion(d);
                        if (ImagenAsignada == true)
                        {
                            img.idpersona = _idempresa;
                            img.tipopersona = GLOBALES.pEMPRESA;
                            existe = (int)ih.ExisteImagen(img);
                            if (existe != 0)
                                ih.actualizaImagen(img);
                            else
                                ih.insertaImagen(img);
                        }
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error al actualizar la empresa. \r\n \r\n Error: " + error.Message);
                    }
                    break;
            }

            switch (tipoGuardar)
            {
                case 0:
                    GLOBALES.LIMPIAR(this,typeof(TextBox));
                    GLOBALES.LIMPIAR(this, typeof(MaskedTextBox));
                    //limpiar(this, typeof(TextBox));
                    break;
                case 1:
                    if (OnNuevaEmpresa != null)
                        OnNuevaEmpresa(_tipoOperacion);
                    this.Dispose();
                    break;
            }
        }
Example #10
0
        private void frmEmpresas_Load(object sender, EventArgs e)
        {
            /// _tipoOperacion CONSULTA = 1, EDICION = 2
            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                cmbPago.Visible = false;
                txtDias.Visible = false;

                cnx = new SqlConnection();
                cnx.ConnectionString = cdn;
                cmd = new SqlCommand();
                cmd.Connection = cnx;
                eh = new Empresas.Core.EmpresasHelper();
                eh.Command = cmd;

                dh = new Direccion.Core.DireccionesHelper();
                dh.Command = cmd;

                Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
                d.idpersona = _idempresa;
                d.tipopersona = GLOBALES.pEMPRESA; ///TIPO PERSONA 0 - Empresas
                List<Empresas.Core.Empresas> lstEmpresa;
                List<Direccion.Core.Direcciones> lstDireccion;

                try
                {
                    cnx.Open();
                    lstEmpresa = eh.obtenerEmpresa(_idempresa);
                    lstDireccion = dh.obtenerDireccion(d);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstEmpresa.Count; i++)
                    {
                        txtNombre.Text = lstEmpresa[i].nombre;
                        txtRepresentante.Text = lstEmpresa[i].representante;
                        txtRfc.Text = lstEmpresa[i].rfc;
                        txtRegistroPatronal.Text = lstEmpresa[i].registro;
                        txtObservacion.Text = lstEmpresa[i].observacion;
                        txtDigitoVerificador.Text = lstEmpresa[i].digitoverificador.ToString();
                        txtRegimen.Text = lstEmpresa[i].regimen.ToString();
                        txtCertificado.Text = lstEmpresa[i].certificado;
                        txtLlave.Text = lstEmpresa[i].llave;
                        txtPassword.Text = lstEmpresa[i].password;
                        txtNoCertificado.Text = lstEmpresa[i].nocertificado;
                        dtpVigencia.Value = lstEmpresa[i].vigenciacertificado;
                    }

                    for (int i = 0; i < lstDireccion.Count; i++)
                    {
                        _iddireccion = lstDireccion[i].iddireccion;
                        txtCalle.Text = lstDireccion[i].calle;
                        txtExterior.Text = lstDireccion[i].exterior;
                        txtInterior.Text = lstDireccion[i].interior;
                        txtColonia.Text = lstDireccion[i].colonia;
                        txtCP.Text = lstDireccion[i].cp;
                        txtMunicipio.Text = lstDireccion[i].ciudad;
                        txtEstado.Text = lstDireccion[i].estado;
                        txtPais.Text = lstDireccion[i].pais;
                    }

                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta Empresa";
                    ((Control)this.tabEmpresa).Enabled = false;
                    ((Control)this.tabPeriodo).Enabled = false;
                    ((Control)this.tabDomicilio).Enabled = false;
                    ((Control)this.tabTimbrado).Enabled = false;
                    btnAsignar.Enabled = false;
                    toolGuardarCerrar.Enabled = false;
                    toolGuardarNuevo.Enabled = false;

                }
                else
                    toolTitulo.Text = "Edición Empresa";
            }

            cmbPago.SelectedIndex = 0;
        }