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

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