コード例 #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lstUiDescuentosEmpleados.Count == 0)
                {
                    throw new Exception("Debe realizar un calculo de Descuentos");
                }

                if (Util.ConfirmationMessage("¿Desea guardar los descuentos calculados?") == false)
                {
                    return;
                }

                bool rpta = false;
                var  lnDescuentoEmpleado = new LN.DescuentoEmpleado();
                for (int i = 0; i < this.lstUiDescuentosEmpleados.Count; i++)
                {
                    BE.UI.DescuentoEmpleado uiDescuentoEmpleado = this.lstUiDescuentosEmpleados[i];
                    rpta = lnDescuentoEmpleado.Insertar(ref uiDescuentoEmpleado);
                    this.lstUiDescuentosEmpleados[i].ID = uiDescuentoEmpleado.ID;
                }

                Util.InformationMessage("Se guardo los descuentos calculados");

                if (this.frmList != null)
                {
                    this.frmList.CargarListadoDescuentos();
                }

                this.Close();
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }
コード例 #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validaciones

                if (this.cboEmpleado.SelectedIndex == 0)
                {
                    this.cboEmpleado.Focus();
                    throw new Exception("Seleccione un empleado");
                }

                if (this.cboDescuento.SelectedIndex == 0)
                {
                    this.cboDescuento.Focus();
                    throw new Exception("Seleccione un tipo de descuento");
                }

                if (this.txtMotivo.Text.Trim().Length == 0)
                {
                    this.txtMotivo.Focus();
                    throw new Exception("Ingrese el motivo del descuento");
                }

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

                double monto = 0;
                if (double.TryParse(this.txtMonto.Text, out monto) == false)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del descuento");
                }
                else if (monto == 0.0)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del descuento");
                }

                #endregion

                #region Guardar

                this.uiDescuentoEmpleado.Fecha                  = this.dtpFecha.Value;
                this.uiDescuentoEmpleado.EmpleadoCodigo         = ((BE.Record) this.cboEmpleado.SelectedItem).Codigo;
                this.uiDescuentoEmpleado.EmpleadoNombreCompleto = ((BE.Record) this.cboEmpleado.SelectedItem).Nombre;
                this.uiDescuentoEmpleado.DescuentoID            = ((BE.UI.Descuento) this.cboDescuento.SelectedItem).Id;
                this.uiDescuentoEmpleado.DescuentoNombre        = ((BE.UI.Descuento) this.cboDescuento.SelectedItem).Nombre;
                this.uiDescuentoEmpleado.Motivo                 = this.txtMotivo.Text.Trim();
                this.uiDescuentoEmpleado.Monto                  = double.Parse(this.txtMonto.Text);

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

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

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