예제 #1
0
        /// <summary>
        /// guarda los cambios
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            Entities.Categoria categoria = new Entities.Categoria();
            categoria.categoria = TxtNombre.Text;

            var  validation = new Helps.DataValidations(categoria).Validate();
            bool valid      = validation.Item1;

            if (valid == true)
            {
                if (editarse == false)
                {
                    try
                    {
                        categoria = bll.Insert(categoria);

                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Categoria: " + categoria.categoria, "", ""));

                        Notifications.FrmSuccess.SuccessForm(Language.SearchValue("guardadoOK"));
                        RefrescarTabla();
                        LimpiarTxt();
                    }
                    catch (Exception ex)
                    {
                        System.Data.SqlClient.SqlException sqlException = ex as System.Data.SqlClient.SqlException;
                        erro = sqlException.Number;
                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Categoria: " + categoria.categoria, ex.StackTrace, ex.Message));
                        Notifications.FrmError.ErrorForm(Language.SearchValue("guardadoError") + "\n" + ex.Message);
                    }
                }
                if (editarse == true)
                {
                    try
                    {
                        categoria.id = id;

                        bll.Update(categoria);

                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Update, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Categoria: " + categoria.categoria, "", ""));

                        Notifications.FrmSuccess.SuccessForm(Language.SearchValue("editadoOK"));
                        RefrescarTabla();
                        LimpiarTxt();
                        editarse = false;
                    }
                    catch (Exception ex)
                    {
                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Categoria: " + categoria.categoria, ex.StackTrace, ex.Message));
                        Notifications.FrmError.ErrorForm(Language.SearchValue("editadoError") + "\n" + ex.Message);
                    }
                }
            }
            else
            {
                string messageValid = validation.Item2;
                Notifications.FrmInformation.InformationForm(messageValid);
            }
        }
예제 #2
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            CargarEntity();

            var  validation = new Helps.DataValidations(_Cabecera_egreso).Validate();
            bool valid      = validation.Item1;

            if (valid == true)
            {
                try
                {
                    _Cabecera_egreso = bllCab.Insert(_Cabecera_egreso);

                    InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Egreso: " + _Cabecera_egreso.letra + _Cabecera_egreso.sucursal.ToString() + _Cabecera_egreso.numero.ToString(), "", ""));

                    Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("guardadoOK"));

                    this.Close();
                }
                catch (SinStockException ex)
                {
                    Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("prodSinStock") + "\n" + ex.PrepararParaMostrar(ex.productos));
                }
                catch (Exception ex)
                {
                    if (ex.Message == EValidaciones.existe)
                    {
                        Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorExiste"));
                    }
                    else
                    {
                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Egreso: " + _Cabecera_egreso.letra + _Cabecera_egreso.sucursal.ToString() + _Cabecera_egreso.numero.ToString(), ex.StackTrace, ex.Message));
                        Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("guardadoError") + "\n" + ex.Message);
                    }
                }
            }
            else
            {
                string messageValid = validation.Item2;
                Notifications.FrmInformation.InformationForm(messageValid);
            }
        }
예제 #3
0
        /// <summary>
        /// buttom iniciar seseión, agarra user y pass, los valida y abre el form principal en caso de validación correcta
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnInisiarSesion_Click(object sender, EventArgs e)
        {
            Entities.UFP.Usuario user = new Entities.UFP.Usuario();
            user.Nombre = TxtNombre.Text;
            user.Pass   = TxtPass.Text;

            var  validation = new Helps.DataValidations(user).Validate();
            bool valid      = validation.Item1;

            if (valid == true)
            {
                try
                {
                    var isValid = BLL.UFP.Usuario.Login(user);

                    if (isValid.Item1)
                    {
                        frmPrincipal frmPrincipal = new frmPrincipal();
                        frmPrincipal.Show();
                        frmPrincipal.FormClosed += Logout;
                        this.Hide();
                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Login, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Inicio seción: " + user.Nombre, "", ""));
                    }
                    else
                    {
                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.LoginError, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Inicio seción fallido: " + user.Nombre, "", ""));
                        Notifications.FrmError.ErrorForm(Language.SearchValue("loginError"));
                    }
                }
                catch (Exception ex)
                {
                    InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.LoginError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Inicio seción fallido: " + user.Nombre, ex.StackTrace, ex.Message));
                    Notifications.FrmError.ErrorForm(Language.SearchValue("loginError") + "\n" + ex.Message);
                }
            }
            else
            {
                string messageValid = validation.Item2;
                Notifications.FrmInformation.InformationForm(messageValid);
            }
        }
예제 #4
0
        private void GuardarDatos()
        {
            var  validation = new Helps.DataValidations(stock).Validate();
            bool valid      = validation.Item1;

            if (valid == true)
            {
                try
                {
                    bllStock.Update(stock);
                    bllMov.Insert(movProd);

                    InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Stock Producto: " + producto.codigo + ' ' + stock.cantidad, "", ""));
                    InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Movimiento Producto: " + producto.codigo + ' ' + movProd.movimiento, "", ""));

                    Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("guardadoOK"));

                    this.Close();
                }
                catch (Exception ex)
                {
                    if (ex.Message == EValidaciones.existe)
                    {
                        Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorExiste"));
                    }
                    else
                    {
                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Stock Producto: " + producto.codigo + ' ' + stock.cantidad, ex.StackTrace, ex.Message));
                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Movimiento Producto: " + producto.codigo + ' ' + movProd.movimiento, ex.StackTrace, ex.Message));
                        Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("guardadoError") + "\n" + ex.Message);
                    }
                }
            }
            else
            {
                string messageValid = validation.Item2;
                Notifications.FrmInformation.InformationForm(messageValid);
            }
        }
예제 #5
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (id == null)
            {
                entity = new Entities.Cliente();
            }

            CargarEntity(entity);

            var  validation = new Helps.DataValidations(entity).Validate();
            bool valid      = validation.Item1;

            if (valid == true)
            {
                if (id == null)
                {
                    try
                    {
                        entity = bll.Insert(entity);

                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Cliente: " + entity.num_documento, "", ""));

                        Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("guardadoOK"));

                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == EValidaciones.existe)
                        {
                            Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorExiste"));
                        }
                        else if (ex.Message == EValidaciones.menor)
                        {
                            Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorMenor"));
                        }
                        else
                        {
                            InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Cliente: " + entity.num_documento, ex.StackTrace, ex.Message));
                            Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("guardadoError") + "\n" + ex.Message);
                        }
                    }
                }
                else
                {
                    try
                    {
                        bll.Update(entity);

                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Update, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Cliente: " + entity.num_documento, "", ""));

                        Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("editadoOK"));

                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == EValidaciones.existe)
                        {
                            Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("errorExiste"));
                        }
                        if (ex.Message == EValidaciones.menor)
                        {
                            Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorMenor"));
                        }
                        else
                        {
                            InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Cliente: " + entity.num_documento, ex.StackTrace, ex.Message));
                            Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("editadoError") + "\n" + ex.Message);
                        }
                    }
                }
            }
            else
            {
                string messageValid = validation.Item2;
                Notifications.FrmInformation.InformationForm(messageValid);
            }
        }
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (id == null)
            {
                entity = new Entities.UFP.Usuario();
            }

            CargarEntity(entity);

            var  validation = new Helps.DataValidations(entity).Validate();
            bool valid      = validation.Item1;

            if (valid == true)
            {
                if (id == null)
                {
                    try
                    {
                        BLL.UFP.Usuario.Insert(entity);

                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Usuario: " + entity.Nombre, "", ""));

                        Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("guardadoOK"));

                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == EValidaciones.existe)
                        {
                            Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorExiste"));
                        }
                        else
                        {
                            InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Usuario: " + entity.Nombre, ex.StackTrace, ex.Message));
                            Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("guardadoError") + "\n" + ex.Message);
                        }
                    }
                }
                else
                {
                    if (editaElUsuario == null)
                    {
                        try
                        {
                            entity.Pass = Convert.ToBase64String(new CryptoSeguridad().Encrypt(entity.Pass));
                            BLL.UFP.Usuario.Update(entity);

                            InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Update, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Usuario: " + entity.Nombre, "", ""));

                            Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("editadoOK"));

                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            if (ex.Message == EValidaciones.existe)
                            {
                                Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("errorExiste"));
                            }
                            else
                            {
                                InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Usuario: " + entity.Nombre, ex.StackTrace, ex.Message));
                                Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("editadoError") + "\n" + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            var isValid = CargarEntityVerificarUsuario(entity);

                            if (isValid.Item1)
                            {
                                if (!String.IsNullOrEmpty(txtPassNueva.Text))
                                {
                                    entity.Pass = txtPassNueva.Text;
                                }


                                entity.Pass = Convert.ToBase64String(new CryptoSeguridad().Encrypt(entity.Pass));
                                BLL.UFP.Usuario.Update(entity);

                                InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Update, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Usuario: " + entity.Nombre, "", ""));

                                Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("editadoOK"));

                                this.Close();
                            }
                            else
                            {
                                InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Usuario: " + entity.Nombre, "", ""));
                                Notifications.FrmError.ErrorForm(Language.SearchValue("loginError"));
                            }
                        }
                        catch (Exception ex)
                        {
                            if (ex.Message == EValidaciones.existe)
                            {
                                Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("errorExiste"));
                            }
                            else
                            {
                                InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Usuario: " + entity.Nombre, ex.StackTrace, ex.Message));
                                Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("editadoError") + "\n" + ex.Message);
                            }
                        }
                    }
                }
            }
            else
            {
                string messageValid = validation.Item2;
                Notifications.FrmInformation.InformationForm(messageValid);
            }
        }