Esempio n. 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lstUiAdelantos.Count == 0)
                {
                    throw new Exception("No se cargo los adelantos");
                }

                Util.PointerLoad(this);

                bool rpta = new LN.Adelanto().Insertar(ref this.lstUiAdelantos);

                if (rpta)
                {
                    this.frmList.CargarListadoAdelantos();

                    Util.InformationMessage("Se guardo los adelantos");

                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
            finally
            {
                Util.PointerReady(this);
            }
        }
Esempio n. 2
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dgvAdelantos.CurrentRow != null)
                {
                    if (Util.ConfirmationMessage("¿Desea eliminar al adelanto seleccionado?") == false)
                    {
                        return;
                    }

                    var uiAdelato = (BE.UI.Adelanto) this.dgvAdelantos.CurrentRow.DataBoundItem;

                    int  idAdelanto = uiAdelato.IdAdelanto;
                    bool rpta       = new LN.Adelanto().Eliminar(idAdelanto);

                    if (rpta == true)
                    {
                        Util.InformationMessage("Se eliminó el adelanto");
                        this.CargarListadoAdelantos();
                    }
                }
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }
Esempio n. 3
0
        public void CargarListadoAdelantos()
        {
            try
            {
                int anho = int.Parse(this.cboAnho.SelectedValue.ToString());
                int mes  = int.Parse(this.cboMes.SelectedValue.ToString());

                var lstUiAdelantos = new LN.Adelanto().Listar(anho, mes);

                var sorted = new SortableBindingList <BE.UI.Adelanto>(lstUiAdelantos);

                this.dgvAdelantos.DataSource = sorted;

                int    nroRegistros   = lstUiAdelantos.Count;
                double totalAdelantos = lstUiAdelantos.Sum(x => x.Monto);

                this.txtNroRegistros.Text   = nroRegistros.ToString();
                this.txtTotalAdelantos.Text = totalAdelantos.ToString("N2");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validaciones
                if (this.cboEmpleado.SelectedIndex == 0)
                {
                    this.cboEmpleado.Focus();
                    throw new Exception("Seleccione un empleado");
                }

                if (this.cboTipos.SelectedIndex == 0)
                {
                    this.cboTipos.Focus();
                    throw new Exception("Seleccione un tipo");
                }
                else if (this.cboTipos.SelectedValue.ToString() == "BAN")
                {
                    if (this.cboBancos.SelectedIndex == 0)
                    {
                        this.cboBancos.Focus();
                        throw new Exception("Seleccione un banco");
                    }
                }

                if (this.txtNumero.Text.Trim().Length == 0)
                {
                    this.txtNumero.Focus();
                    throw new Exception("Ingrese la descripcion del bono");
                }

                if (this.txtMonto.Text.Trim().Length == 0)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del bono");
                }

                if (double.Parse(this.txtMonto.Text) == 0.0)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del bono");
                }
                #endregion

                #region Guardar

                this.beAdelanto.Fecha          = this.dtpFecha.Value;
                this.beAdelanto.CodigoEmpleado = this.cboEmpleado.SelectedValue.ToString();
                this.beAdelanto.CodigoTipo     = this.cboTipos.SelectedValue.ToString();
                this.beAdelanto.Numero         = this.txtNumero.Text;
                this.beAdelanto.Monto          = double.Parse(this.txtMonto.Text);
                this.beAdelanto.IdBanco        = int.Parse(this.cboBancos.SelectedValue.ToString());

                bool   rpta       = false;
                string msg        = "";
                var    lnAdelanto = new LN.Adelanto();
                if (this.beAdelanto.IdAdelanto == 0) //Nuevo
                {
                    rpta = lnAdelanto.Insertar(ref this.beAdelanto);
                    if (true)
                    {
                        msg = "Se registro el nuevo adelanto";
                    }
                }
                else  //Actualizar
                {
                    rpta = lnAdelanto.Actualizar(this.beAdelanto);
                    if (true)
                    {
                        msg = "Se actualizo el adelanto";
                    }
                }

                if (rpta == true)
                {
                    Util.InformationMessage(msg);
                    this.frmList.CargarListadoAdelantos();
                    this.Close();
                }

                #endregion
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }