Пример #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                this.txtMensajeError.Visible = false;
                List <Error> Errores = this.ValidarDatos();
                if (Errores.Count == 0)
                {
                    Producto_Negocio ProdNeg = new Producto_Negocio();
                    GenerarClave     Result  = ProdNeg.GenerarNuevaClaveProduccion(Comun.Conexion, EsEmpleado, DatosEmpleado != null ? DatosEmpleado.IDEmpleado : string.Empty, Actual.IDProducto, this.ObtenerCantidad(), Comun.IDSucursalCaja, Comun.IDUsuario);

                    if (Result._Resultado == 1)
                    {
                        MessageBox.Show(string.Format("Datos guardados correctamente. Las claves generadas son: {0}", Result._ClavesProduccion), Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        string Message = string.Empty;
                        switch (Result._Resultado)
                        {
                        case -2:
                            Message = "No hay existencias suficientes para generar las claves.";
                            break;

                        default:
                            Message = "Error al guardar los datos. Intente nuevamente.";
                            break;
                        }
                        MessageBox.Show(Message, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    this.MostrarMensajeError(Errores);
                }
            }
            catch (Exception ex)
            {
                LogError.AddExcFileTxt(ex, "frmNuevaClaveProduccion ~ btnGuardar_Click");
                MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }