示例#1
0
        private void GuardarBtn_Click(object sender, RoutedEventArgs e)
        {
            if (isModifying == true)
            {
                tipoUsuario.EntityState = EntityState.Modified;
                tipoUsuario.Id          = idTipoUsuario;
            }
            else
            {
                tipoUsuario.EntityState = EntityState.Added;
            }

            tipoUsuario.Nombre      = NombreTextBox.Text;
            tipoUsuario.TipoUsuario = TipoUsuarioCombox.SelectedItem.ToString();

            bool validation = new Helps.DataValidation(tipoUsuario).Validate();

            if (validation == true)
            {
                string result = tipoUsuario.Savechanges();
                MessageBox.Show(result);

                TipoUsuarioUControl control = new TipoUsuarioUControl();
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(Dashboard))
                    {
                        (window as Dashboard).SwitchScreen(control, "Tipos de usuarios");
                    }
                }
                //message = result;
                //DialogResult = true;
            }
        }
示例#2
0
        private void BtnAgregarALista_Click(object sender, RoutedEventArgs e)
        {
            stock.Estado         = EntityState.Agregado;
            stock.NumReferencia  = txtNumReferencia.Text.Trim();
            stock.IdProducto     = producto.IdProducto;
            stock.NombreProducto = producto.Descripcion;
            if (txtCantidad.Text != "")
            {
                stock.Cantidad = Convert.ToInt32(txtCantidad.Text.Trim());
            }
            else
            {
                stock.Cantidad = 0;
            }
            stock.FechaHora       = DateTime.Now;
            stock.IngresadoPor    = txtIngresadoPor.Text.Trim();
            stock.EstadoProducto  = "Pendiente";
            stock.IdProveedor     = Convert.ToInt32(cmbProveedor.SelectedValue);
            stock.NombreProveedor = cmbProveedor.Text;

            bool validar = new Helps.DataValidation(stock).Validar();

            if (validar)
            {
                stock.Estado = EntityState.Agregado;
                stock.GuardarCambios();

                txtProducto.Clear();
                txtCantidad.Clear();

                ListarStockActual(stock.NumReferencia);
            }
        }
示例#3
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            string RBState = "Inactivo";

            if (RBStateActive.Checked)
            {
                RBState = "Activo";
            }
            employeeModel.Username     = TBDni.Text;
            employeeModel.Dni          = TBDni.Text;
            employeeModel.FirstName    = TBFirstName.Text;
            employeeModel.LastName     = TBLastName.Text;
            employeeModel.Email        = TBEmail.Text;
            employeeModel.Birthday     = Convert.ToDateTime(DTPBirthay.Value);
            employeeModel.State        = RBState;
            employeeModel.PositionCode = Convert.ToString(CboPosition.SelectedValue);

            bool Valid = new Helps.DataValidation(employeeModel).Validate();

            if (Valid)
            {
                string Msg = employeeModel.SaveChanges();
                MessageBox.Show(Msg);
                All();
                Clear();
            }
        }
示例#4
0
        private void GuardarBtn_Click(object sender, RoutedEventArgs e)
        {
            if (isModifying == true)
            {
                ejercicio.EntityState = EntityState.Modified;
                ejercicio.Id          = idEjercicio;
            }
            else
            {
                ejercicio.EntityState = EntityState.Added;
            }

            ejercicio.Nombre      = NombreTextBox.Text;
            ejercicio.Descripcion = DescripcionTextBox.Text;

            bool validation = new Helps.DataValidation(ejercicio).Validate();

            if (validation == true)
            {
                string result = ejercicio.Savechanges();
                MessageBox.Show(result);

                EjercicioUControl control = new EjercicioUControl();
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(Dashboard))
                    {
                        (window as Dashboard).SwitchScreen(control, "Ejercicios");
                    }
                }
            }
        }
        private void BtnConfirmar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MessageBox.Show("Confirmar descuento", "Agregar descuento", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    transaccion                = DataContext as TransaccionModel;
                    transaccion.Estado         = CapaNegocio.ValueObjects.EntityState.Actualizado;
                    transaccion.PorcentajeDesc = Convert.ToDecimal(txtDescuento.Text) / 100;
                    transaccion.Descuento      = Convert.ToDecimal(txtTotalDescuento.Text);

                    bool validar = new Helps.DataValidation(transaccion).Validar();

                    if (validar)
                    {
                        transaccion.GuardarCambios();
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Agregar descuento", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#6
0
        private void BtnEditComp_Click(object sender, EventArgs e)
        {
            if (txtCantComp.Text == "")
            {
                MessageBox.Show("Ingrese la cantidad");
            }
            else
            {
                if (Convert.ToInt32(txtCantComp.Text) < 1)
                {
                    MessageBox.Show("Ingrese un cantidad mayor a 0");
                }
                else
                {
                    purchase.State        = EntityState.Modified;
                    purchase.IdCompMod    = Convert.ToInt32(txtIdComp.Text);
                    purchase.Prod_CodeMod = txtCodProdComp.Text;
                    purchase.Prod_NameMod = txtNameProdComp.Text;
                    purchase.Comp_DateMod = Convert.ToDateTime(txtDateComp.Text);
                    purchase.Comp_CantMod = Convert.ToInt32(txtCantComp.Text);

                    bool valid = new Helps.DataValidation(purchase).Validate();

                    if (valid == true)
                    {
                        string result = purchase.SaveChanges();
                        MessageBox.Show(result);
                        Restart();
                        Close();
                    }
                }
            }
        }
        private void BtnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtPassword.Password != txtConfirmarPass.Password)
                {
                    MessageBox.Show("La contraseña con coincide", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                usuario          = DataContext as UsuarioModel;
                usuario.Password = txtPassword.Password;

                bool validar = new Helps.DataValidation(usuario).Validar();

                if (validar)
                {
                    string resultado = usuario.GuardarCambios();
                    MessageBox.Show(resultado, "Usuario", MessageBoxButton.OK, MessageBoxImage.Information);

                    if (resultado == "Registro exitoso.")
                    {
                        Limpiar();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error inesperado", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void BtnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                stockAjuste.NumReferencia = txtNumReferencia.Text;
                stockAjuste.IdProducto = txtIdProducto.Text;
                if (txtCantidad.Text == "") stockAjuste.Cantidad = 0;
                else stockAjuste.Cantidad = Convert.ToInt32(txtCantidad.Text);
                stockAjuste.Accion = cmbComando.Text;
                stockAjuste.Observacion = txtObservacion.Text;
                stockAjuste.Fecha = DateTime.Now;
                stockAjuste.Username = txtUsuario.Text;
                stockAjuste.Estado = CapaNegocio.ValueObjects.EntityState.Agregado;

                bool validar = new Helps.DataValidation(stockAjuste).Validar();

                if (validar)
                {
                    //Validar cantidad
                    if (Convert.ToInt32(txtCantidad.Text) > cant)
                    {
                        MessageBox.Show("La cantidad de stock disponible debe ser mayor que la cantidad de ajuste.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }

                    //Actualizar cantidad
                    if (cmbComando.Text == "Eliminar del inventario")
                    {
                        string idProducto = producto.IdProducto;
                        int cantidad = Convert.ToInt32(txtCantidad.Text);

                        producto.ActualizarProductoCantidad(idProducto, cantidad);
                    }
                    else if (cmbComando.Text == "Agregar al inventario")
                    {
                        string idProducto = producto.IdProducto;
                        int cantidad = Convert.ToInt32(txtCantidad.Text) * -1;

                        producto.ActualizarProductoCantidad(idProducto, cantidad);
                    }

                    //Agregamos los datos a la tabla tblAdjustment
                    string resultado = stockAjuste.GuardarCambios();
                    MessageBox.Show(resultado, "Ajuste de Stock", MessageBoxButton.OK, MessageBoxImage.Information);

                    if (resultado == "Registro exitoso.")
                    {
                        Limpiar();
                        GenerarNumReferencia();
                        ListarProductos();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#9
0
        private void InsertProduct()
        {
            try
            {
                ProductoModel producto = new ProductoModel();

                producto.state           = Domain.ValueObjects.EntityState.Added;
                producto.Codigo_producto = txtCodigo.Text;
                producto.NombreComercial = txtNombre.Text;
                producto.Descripcion     = txtDesc.Text;
                producto.UsoTerapeutico  = txtUso.Text;
                producto.Precio          = Convert.ToDouble(txtPrecio.Text);
                producto.Existencia      = Convert.ToInt32(txtCantidad.Text);
                producto.IdTipo          = Convert.ToInt32(cmbTipo.SelectedValue);
                producto.IdPresentacion  = Convert.ToInt32(cmbPresentacion.SelectedValue);
                producto.IdRubro         = Convert.ToInt32(cmbRubro.SelectedValue);
                producto.Concentracion   = txtConcentracion.Text;
                producto.Laboratorio     = txtLaboratorio.Text;
                if (rdsi.IsChecked == true)
                {
                    producto.Reseta = true;
                }
                else
                {
                    producto.Reseta = false;
                }

                if (rdsi2.IsChecked == true)
                {
                    producto.Estado = true;
                }
                else
                {
                    producto.Estado = false;
                }


                producto.FechaElaboracion = Convert.ToDateTime(dateE.SelectedDate);
                producto.FechaRegistro    = Convert.ToDateTime(dateR.SelectedDate);
                producto.FechaVencimiento = Convert.ToDateTime(dateV.SelectedDate);


                bool valid = new Helps.DataValidation(producto).Validate();
                if (valid == true)
                {
                    string result = producto.SaveChanges();
                    MessageBox.Show(result);
                    productos.ItemsSource = producto.GetAll();
                }
            }
            catch (System.FormatException E)
            {
                MessageBox.Show("Error: " + E.Message);
            }
        }
示例#10
0
        private void GuardarBtn_Click(object sender, RoutedEventArgs e)
        {
            if (isModifying == true)
            {
                cliente.EntityState = EntityState.Modified;
                cliente.Id          = idUsuario;
            }
            else
            {
                cliente.EntityState = EntityState.Added;
            }

            cliente.Apodo           = ApodoTextBox.Text;
            cliente.Pin             = PinTextBox.Password;
            cliente.Nombre          = NombreTextBox.Text;
            cliente.ApellidoPaterno = APaternoTextBox.Text;
            cliente.ApellidoMaterno = AMaternoTextBox.Text;
            cliente.Correo          = CorreoTextBox.Text;
            cliente.ImgPath         = imagenpath;
            try
            {
                cliente.FNacimiento = FNacimientoPicker.SelectedDate.ToString().Substring(0, 10);
            }
            catch { }
            cliente.Peso     = PesoTextBox.Text;
            cliente.Estatura = EstaturaTextBox.Text;
            try
            {
                cliente.Genero = GeneroCombox.Text.Substring(0, 1);
            }
            catch { }


            bool validation = new Helps.DataValidation(cliente).Validate();

            if (validation == true)
            {
                string result = cliente.Savechanges();
                MessageBox.Show(result);

                ClienteUControl control = new ClienteUControl();
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(Dashboard))
                    {
                        (window as Dashboard).SwitchScreen(control, "Clientes");
                    }
                }
                //message = result;
                //DialogResult = true;
            }
        }
示例#11
0
        private void GuardarBtn_Click(object sender, RoutedEventArgs e)
        {
            if (isModifying == true)
            {
                usuario.EntityState = EntityState.Modified;
                usuario.Id          = idUsuario;
            }
            else
            {
                usuario.EntityState = EntityState.Added;
            }

            usuario.Apodo = ApodoTextBox.Text;
            usuario.Pin   = PinTextBox.Password;
            try
            {
                usuario.IdTipoUsuario = TipoUsuarioCombox.SelectedValue.ToString();
            }
            catch { }
            usuario.Nombre          = NombreTextBox.Text;
            usuario.ApellidoPaterno = APaternoTextBox.Text;
            usuario.ApellidoMaterno = AMaternoTextBox.Text;
            usuario.Correo          = CorreoTextBox.Text;
            usuario.ImgPath         = imagenpath;
            usuario.Telefono        = TelefonoTextBox.Text;
            try
            {
                usuario.Genero = GeneroCombox.Text.Substring(0, 1);
            }
            catch { }

            bool validation = new Helps.DataValidation(usuario).Validate();

            if (validation == true)
            {
                string result = usuario.Savechanges();
                MessageBox.Show(result);

                UsuarioUControl control = new UsuarioUControl();
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(Dashboard))
                    {
                        (window as Dashboard).SwitchScreen(control, "Usuarios");
                    }
                }
                //message = result;
                //DialogResult = true;
            }
        }
示例#12
0
        private void AddSalesDetails()
        {
            foreach (var item in lstArticles.Items)
            {
                detalleVenta.state   = Domain.ValueObjects.EntityState.Added;
                detalleVenta         = (DetalleVentaModel)item;
                detalleVenta.IdVenta = Convert.ToInt32(venta.IdVenta);

                bool valid = new Helps.DataValidation(detalleVenta).Validate();
                if (valid == true)
                {
                    string result = detalleVenta.SaveChanges();
                }
            }
            System.Windows.MessageBox.Show("Venta Facturada con Exito");
        }
示例#13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            employee.IdNumber = txtINumber.Text;
            employee.Name     = txtName.Text;
            employee.Mail     = txtMail.Text;
            employee.Birthday = txtDate.Value;

            bool valid = new Helps.DataValidation(employee).Validate();

            if (valid == true)
            {
                string result = employee.saveChange();
                MessageBox.Show(result);
                ListEmployee();
                Restar();
            }
        }
示例#14
0
        private void button5_Click_1(object sender, EventArgs e)
        {
            employee.IdNumber = textBox1.Text;
            employee.Mail     = textBox3.Text;
            employee.Name     = textBox2.Text;
            employee.Birthday = dateTimePicker1.Value;

            bool valid = new Helps.DataValidation(employee).Validate();

            if (valid == true)
            {
                string result = employee.SaveChanges();
                MessageBox.Show(result);
                ListEmployees();
                Restart();
            }
        }
示例#15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            cliente.Nombre    = txtNombre.Text;
            cliente.Apellido  = txtApellido.Text;
            cliente.Rfc       = txtRfc.Text;
            cliente.Domicilio = txtDomicilio.Text;

            bool valid = new Helps.DataValidation(cliente).Validate();

            if (valid == true)
            {
                string result = cliente.saveChanges();
                MessageBox.Show(result);
                ListarClientes();
                Restart();
            }
        }
示例#16
0
        private void GuardarBtn_Click(object sender, RoutedEventArgs e)
        {
            if (isModifying == true)
            {
                rutina.EntityState = EntityState.Modified;
                rutina.Id          = idRutina;
            }
            else
            {
                rutina.EntityState = EntityState.Added;
            }

            try
            {
                rutina.Dia = DiaCombox.SelectedValue.ToString();
            }
            catch { }
            rutina.Repeticiones = RepeticionesTextBox.Text;
            rutina.Peso         = PesoTextBox.Text;
            try
            {
                rutina.IdEjercicio = EjercicioCombox.SelectedValue.ToString();
                rutina.IdCliente   = ClienteCombox.SelectedValue.ToString();
            }
            catch { }

            bool validation = new Helps.DataValidation(rutina).Validate();

            if (validation == true)
            {
                string result = rutina.Savechanges();
                MessageBox.Show(result);

                RutinaUControl control = new RutinaUControl();
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(Dashboard))
                    {
                        (window as Dashboard).SwitchScreen(control, "Usuarios");
                    }
                }
                //message = result;
                //DialogResult = true;
            }
        }
示例#17
0
        private void BtnsaveProduct_Click(object sender, EventArgs e)
        {
            product.ProdCodMod  = txtCodPro.Text;
            product.ProdNameMod = txtNamePro.Text;
            if (txtIdPro.Text == "")
            {
                product.State = EntityState.Added;
            }
            else
            {
                product.State = EntityState.Modified;
            }

            bool valid = new Helps.DataValidation(product).Validate();

            if (valid == true)
            {
                if (txtMayPro.Text == "")
                {
                    MessageBox.Show("Ingrese el precio al por mayor del producto");
                }
                else
                {
                    if (txtMenPro.Text == "")
                    {
                        MessageBox.Show("Ingrese el precio al por menor del producto");
                    }
                    else
                    {
                        product.ProdPrMayMod = float.Parse(txtMayPro.Text.Trim());
                        product.ProdPrMenMod = float.Parse(txtMenPro.Text.Trim());
                        product.ProdStockMod = Convert.ToInt32(txtStockPro.Text);

                        string result = product.SaveChanges();
                        MessageBox.Show(result);
                        Restart();
                        Close();
                    }
                }
            }
        }
        private void BtnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                producto = DataContext as ProductoModel;

                bool validar = new Helps.DataValidation(producto).Validar();

                if (validar)
                {
                    string resultado = producto.GuardarCambios();
                    MessageBox.Show(resultado, "Producto", MessageBoxButton.OK, MessageBoxImage.Information);
                    Limpiar();
                    txtCodigo.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error inesperado", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#19
0
        private void BtnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                categoria = DataContext as CategoriaModel;

                bool validar = new Helps.DataValidation(categoria).Validar();

                if (validar)
                {
                    string resultado = categoria.GuardarCambios();
                    MessageBox.Show(resultado, "Categoría", MessageBoxButton.OK, MessageBoxImage.Information);
                    txtNombreCategoria.Clear();
                    txtNombreCategoria.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error inesperado", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#20
0
        private void Button_Save_Click(object sender, EventArgs e)
        {
            employee.DNI      = TextBox_DNI.Text;
            employee.Nombre   = TextBox_Nombre.Text;
            employee.Mail     = TextBox_Email.Text;
            employee.Birthday = dateTimePicker1.Value;

            bool Valid = new Helps.DataValidation(employee).Validate();

            if (Valid)
            {
                string Result = employee.SaveChanges();
                MessageBox.Show(Result);
                //Actualizar lista
                LoadGridView();
                CleanPanel();
            }
            else
            {
            }
        }
示例#21
0
        //
        private void GuardarOrdenCancelada(string username)
        {
            OrdenCanceladaModel ordenCancelada = new OrdenCanceladaModel();

            ordenCancelada.NumTransaccion = txtNumTransaccion.Text;
            ordenCancelada.IdProducto     = txtIdProducto.Text;
            ordenCancelada.Precio         = Convert.ToDecimal(txtPrecio.Text);
            ordenCancelada.Cantidad       = Convert.ToInt32(txtCantidad.Text);
            ordenCancelada.Fecha          = DateTime.Now;
            ordenCancelada.AnuladoPor     = username;
            ordenCancelada.CanceladoPor   = txtCanceladoPor.Text;
            ordenCancelada.Razon          = txtRazon.Text;
            ordenCancelada.Accion         = cmbAgregarAInventario.Text;

            bool validar = new Helps.DataValidation(ordenCancelada).Validar();

            if (validar)
            {
                string resultado = ordenCancelada.GuardarCambios();
                MessageBox.Show(resultado, "Cancelar Orden", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void BtnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MessageBox.Show("¿Guardar detalle de tienda?", "Confirmar", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    tienda = DataContext as TiendaModel;

                    bool validar = new Helps.DataValidation(tienda).Validar();

                    if (validar)
                    {
                        string resultado = tienda.GuardarCambios();
                        MessageBox.Show(resultado, "Detalle de Tienda", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error inesperado", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#23
0
        private void BtnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                proveedor = DataContext as ProveedorModel;

                bool validar = new Helps.DataValidation(proveedor).Validar();

                if (validar && ValidarEmail())
                {
                    string resultado = proveedor.GuardarCambios();
                    MessageBox.Show(resultado, "Proveedor", MessageBoxButton.OK, MessageBoxImage.Information);
                    //Limpiar();
                    //txtVendedor.Focus();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error inesperado", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#24
0
        private void btnFactura_Click(object sender, RoutedEventArgs e)
        {
            var idClient = Convert.ToInt32(cmbClientes.SelectedValue);

            if (lstArticles.Items.Count == 0)
            {
                System.Windows.MessageBox.Show("La factura debe tener minimo un detalle de venta");
            }
            else
            {
                venta.state     = Domain.ValueObjects.EntityState.Added;
                venta.IdCliente = idClient;
                bool valid = new Helps.DataValidation(venta).Validate();
                if (valid == true)
                {
                    string result = venta.SaveChanges();
                }
                venta.IdVenta = venta.FindLast().IdVenta; //busca el id de la ultima venta

                //metodos para cargar los detalles de venta
                AddSalesDetails();
            }
        }
示例#25
0
        private void BtnSaveCusto_Click(object sender, EventArgs e)
        {
            customer.CustoNameMod    = txtCustoName.Text;
            customer.CustoCedMod     = txtCustoCed.Text;
            customer.CustoAddressMod = txtCustoAddress.Text;
            customer.CustoPhoneMod   = txtCustoPhone.Text;
            if (txtCustoId.Text == "")
            {
                customer.State = EntityState.Added;
            }
            else
            {
                customer.State = EntityState.Modified;
            }

            bool valid = new Helps.DataValidation(customer).Validate();

            if (valid == true)
            {
                if (txtCustoCed.Text.Length == 13)// pregunta si es ruc
                {
                    string ruc = txtCustoCed.Text.Substring(10, 3);

                    if (ruc == "001")
                    {
                        bool resp = Val_Ced(txtCustoCed.Text.Substring(0, 10));

                        if (resp == true)
                        {
                            MessageBox.Show("Ingrese un R.U.C valido");
                        }
                        else
                        {
                            string result = customer.SaveChanges();
                            MessageBox.Show(result);
                            Restart();
                            Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("R.U.C. debe terminar en 001");
                    }
                }
                else
                {
                    if (txtCustoCed.Text.Length == 10)//pregunta si es cedula
                    {
                        bool resp = Val_Ced(txtCustoCed.Text);

                        if (resp == true)
                        {
                            MessageBox.Show("Ingrese una cédula valida");
                        }
                        else
                        {
                            string result = customer.SaveChanges();
                            MessageBox.Show(result);
                            Restart();
                            Close();
                        }
                    }
                    else
                    {
                        if (txtCustoCed.Text.Length > 0)
                        {
                            MessageBox.Show("Ingrese una cédula / R.U.C. valido");
                        }
                    }
                }
            }
        }
示例#26
0
        private void SaveUser_Click(object sender, EventArgs e)
        {
            user.User_NameMod   = txt_user_Name.Text;
            user.User_CedMod    = txt_user_Ced.Text;
            user.User_PasswdMod = txt_user_Passwd.Text;
            user.User_TypeMod   = txt_user_Type.Text;
            if (txtID.Text == "")
            {
                user.State = EntityState.Added;
            }
            else
            {
                user.State = EntityState.Modified;
            }

            bool valid = new Helps.DataValidation(user).Validate();

            if (valid == true)
            {
                if (txt_user_Ced.Text.Length == 13)// pregunta si es ruc
                {
                    string ruc = txt_user_Ced.Text.Substring(10, 3);

                    if (ruc == "001")
                    {
                        bool resp = Val_Ced(txt_user_Ced.Text.Substring(0, 10));

                        if (resp == true)
                        {
                            MessageBox.Show("Ingrese un R.U.C valido");
                        }
                        else
                        {
                            string result = user.SaveChanges();
                            MessageBox.Show(result);
                            Restart();
                            Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("R.U.C. debe terminar en 001");
                    }
                }
                else
                {
                    if (txt_user_Ced.Text.Length == 10)//pregunta si es cedula
                    {
                        bool resp = Val_Ced(txt_user_Ced.Text);

                        if (resp == true)
                        {
                            MessageBox.Show("Ingrese una cédula valida");
                        }
                        else
                        {
                            string result = user.SaveChanges();
                            MessageBox.Show(result);
                            Restart();
                            Close();
                        }
                    }
                    else
                    {
                        if (txt_user_Ced.Text.Length > 0)
                        {
                            MessageBox.Show("Ingrese una cédula / R.U.C. valido");
                        }
                    }
                }
            }
        }
示例#27
0
        private void TxtCantidad_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            int caracter = Convert.ToInt32(Convert.ToChar(e.Text));

            if ((caracter >= 48 && caracter <= 57) || caracter == 13)
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }


            if (caracter == 13 && txtCantidad.Text != string.Empty)
            {
                transaccion.Estado         = EntityState.Agregado;
                transaccion.NumTransaccion = numTransaccion;
                transaccion.IdProducto     = idProducto;
                transaccion.Precio         = precio;
                transaccion.Cantidad       = Convert.ToInt32(txtCantidad.Text.Trim());
                transaccion.Fecha          = DateTime.Now;
                transaccion.Cajero         = UserCache.Username;

                bool validar = new Helps.DataValidation(transaccion).Validar();

                //Comprobar si la cantidad pedida esta disponible en actualmente
                if (cantidad < transaccion.Cantidad)
                {
                    MessageBox.Show($"Incapaz de proceder, la cantidad en stock actual es: {cantidad}", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                //Comprobar si el producto ya se encuentra registrado
                var productoDuplicado = transaccion.ComprobarProductosDuplicados(transaccion.NumTransaccion, transaccion.IdProducto);
                if (productoDuplicado.Count > 0)
                {
                    //Actualizar la cantidad del producto
                    transaccion.Estado = EntityState.Actualizado;

                    //Comprobar si la cantidad pedida esta disponible en actualmente
                    if (cantidad < transaccion.Cantidad + productoDuplicado[0].Cantidad)
                    {
                        MessageBox.Show($"Incapaz de proceder, la cantidad en stock actual es: {cantidad}", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }

                    transaccion.ActualizarCantidadTransaccion(transaccion.IdTransaccion, transaccion.NumTransaccion, transaccion.IdProducto, transaccion.Cantidad);
                    MessageBox.Show("Registro exitoso.", "Resultado de Transacción", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    //Ingresar el producto
                    if (validar)
                    {
                        string resultado = transaccion.GuardarCambios();
                        MessageBox.Show(resultado, "Resultado de Transacción", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }

                this.Close();
            }
        }