예제 #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;
            }

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            dh             = new Departamento.Core.DeptoHelper();
            dh.Command     = cmd;

            Departamento.Core.Depto depto = new Departamento.Core.Depto();
            depto.descripcion = txtDescripcion.Text;
            depto.estatus     = 1;

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    dh.insertaDepartamento(depto);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar el departamento. \r\n \r\n Error: " + error.Message);
                }
                break;

            case 2:
                try
                {
                    depto.id          = _iddepartamento;
                    depto.descripcion = txtDescripcion.Text;
                    cnx.Open();
                    dh.actualizaDepartamento(depto);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el departamento. \r\n \r\n Error: " + error.Message);
                }
                break;
            }

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

            case 1:
                if (OnNuevoDepto != null)
                {
                    OnNuevoDepto(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }
예제 #2
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;
            }
        }
예제 #3
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;
            }

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;

            ph         = new Plaza.Core.PlazasHelper();
            ph.Command = cmd;

            Plaza.Core.Plazas p = new Plaza.Core.Plazas();
            p.nombre = txtNombre.Text;
            p.activo = 1;

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    ph.insertaPlaza(p);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }
                break;

            case 2:
                try
                {
                    cnx.Open();
                    p.id = _idplaza;
                    ph.actualizaPlaza(p);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }
                break;
            }

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

            case 1:
                if (OnNuevaPlaza != null)
                {
                    OnNuevaPlaza(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }
예제 #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;
            }

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            sh             = new Salario.Core.SalariosHelper();
            sh.Command     = cmd;

            Salario.Core.Salarios salario = new Salario.Core.Salarios();
            salario.periodo = dtpPeriodo.Value;
            salario.valor   = decimal.Parse(txtValor.Text.Trim());

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    sh.insertaSalario(salario);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar el salario. \r\n \r\n Error: " + error.Message);
                }
                break;

            case 2:
                try
                {
                    salario.idsalario = _idsalario;
                    cnx.Open();
                    sh.actualizaSalario(salario);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el salario. \r\n \r\n Error: " + error.Message);
                }
                break;
            }

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

            case 1:
                if (OnNuevoSalario != null)
                {
                    OnNuevoSalario(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }
예제 #5
0
        private void guardar(int tipoGuardar)
        {
            //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;
            eh             = new Empleados.Core.EmpleadosHelper();
            eh.Command     = cmd;

            Empleados.Core.Empleados em = new Empleados.Core.Empleados();
            em.nombres           = txtNombre.Text;
            em.paterno           = txtApMaterno.Text;
            em.materno           = txtApMaterno.Text;
            em.nombrecompleto    = txtApPaterno.Text + (string.IsNullOrEmpty(txtApMaterno.Text) ? "" : " " + txtApMaterno.Text) + " " + txtNombre.Text;
            em.fechanacimiento   = dtpFechaNacimiento.Value;
            em.edad              = int.Parse(txtEdad.Text);
            em.idempresa         = GLOBALES.IDEMPRESA;
            em.fechaingreso      = dtpFechaIngreso.Value;
            em.localforaneo      = cmbLocalForaneo.SelectedValue.ToString();
            em.sua               = cmbSua.SelectedValue.ToString();
            em.rfc               = txtRFC.Text;
            em.curp              = txtCURP.Text;
            em.nss               = txtNSS.Text;
            em.digitoverificador = int.Parse(txtDigito.Text);

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    em.antiguedad  = 0;
                    em.idcliente   = int.Parse(cmbCliente.SelectedValue.ToString());
                    em.idperiodo   = int.Parse(cmbPeriodo.SelectedValue.ToString());
                    em.tiposalario = cmbTipoSalario.SelectedValue.ToString();
                    em.sdi         = decimal.Parse(txtSDI.Text);
                    em.sd          = decimal.Parse(txtSD.Text);
                    em.sueldo      = decimal.Parse(txtSueldo.Text);
                    em.idinfonavit = 0;
                    em.estatus     = 0;
                    em.idse        = 0;
                    em.modsalario  = 0;
                    em.idplaza     = GLOBALES.IDPLAZA;

                    cnx.Open();
                    eh.insertaEmpleado(em);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar el empleado. \r\n \r\n Error: " + error.Message);
                }
                break;

            case 2:
                try
                {
                    em.idempresa = _idempleado;
                    cnx.Open();
                    eh.actualizaEmpleado(em);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el empleado. \r\n \r\n Error: " + error.Message);
                }
                break;
            }

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

            case 1:
                if (OnNuevoEmpleado != null)
                {
                    OnNuevoEmpleado(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }
예제 #6
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;
            }
        }
예제 #7
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;
            }

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            ph             = new Periodos.Core.PeriodosHelper();
            ph.Command     = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.idcliente = int.Parse(cmbCliente.SelectedValue.ToString());
            periodo.pago      = cmbPago.SelectedText;
            periodo.dias      = cmbPago.SelectedText.Equals("SEMANAL") ? 7 : 15;
            periodo.inicio    = cmbDiaInicio.SelectedText;
            periodo.termino   = cmbDiaTermino.SelectedText;
            periodo.estatus   = 1;

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    ph.insertaPeriodo(periodo);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar el periodo. \r\n \r\n Error: " + error.Message);
                }
                break;

            case 2:
                try
                {
                    periodo.idperiodo = _idperiodo;
                    cnx.Open();
                    ph.actualizaPeriodo(periodo);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el periodo. \r\n \r\n Error: " + error.Message);
                }
                break;
            }

            switch (tipoGuardar)
            {
            case 0:
                GLOBALES.LIMPIAR(this, typeof(TextBox));
                GLOBALES.REFRESCAR(this, typeof(ComboBox));
                break;

            case 1:
                if (OnNuevoPeriodo != null)
                {
                    OnNuevoPeriodo(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }
예제 #8
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;
            }

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            fh             = new Factores.Core.FactoresHelper();
            fh.Command     = cmd;

            Factores.Core.Factores factor = new Factores.Core.Factores();
            factor.anio  = int.Parse(txtAnio.Text.Trim());
            factor.valor = decimal.Parse(txtValor.Text.Trim());

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    fh.insertaFactor(factor);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar el factor. \r\n \r\n Error: " + error.Message);
                }
                break;

            case 2:
                try
                {
                    factor.idfactor = _idfactor;
                    cnx.Open();
                    fh.actualizaFactor(factor);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el factor. \r\n \r\n Error: " + error.Message);
                }
                break;
            }

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

            case 1:
                if (OnNuevoFactor != null)
                {
                    OnNuevoFactor(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }