Beispiel #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     State  = AppMAnager.STATE_INSERT;
     entity = new copia_puntos();
     clearForm();
     showForm();
 }
Beispiel #2
0
 private void AfterSave()
 {
     refreshGrid();
     clearForm();
     hideForm();
     entity = null;
 }
Beispiel #3
0
        public PPuntosCopia()
        {
            InitializeComponent();

            refreshGrid();
            lNombre.Tag = "Nombre";
            hideForm();
            State  = AppMAnager.STATE_NULL;
            entity = null;
        }
Beispiel #4
0
        private void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            int id = (int)((Button)sender).CommandParameter;

            if (id > 0)
            {
                entity = DBManager.PuntoCopyRepo.FindById(id);
                if (entity != null)
                {
                    tbNombre.Text = entity.nombre;
                    State         = AppMAnager.STATE_UPDATE;
                    showForm();
                }
            }
        }
Beispiel #5
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            int id = (int)((Button)sender).CommandParameter;

            if (id > 0)
            {
                entity = DBManager.PuntoCopyRepo.FindById(id);
                if (entity != null)
                {
                    entity.inactivo = true;
                    entity.nombre   = entity.nombre + "_deleted" + entity.id;
                    DBManager.PuntoCopyRepo.Update(entity);
                    refreshGrid();

                    clearForm();
                    hideForm();
                }
            }
        }
Beispiel #6
0
        public static bool Logout()
        {
            bool noProblem = false;

            if (RUNNING_COPYS_COUNT > 0)
            {
                MessageBoxResult res = MessageBox.Show("Existen copias en curso. ¿Confirma que desea cancelarlas?", "Información", MessageBoxButton.YesNo);
                if (res == MessageBoxResult.Yes)
                {
                    PHome._PHome.CancelRunningCopys();
                    noProblem = true;
                }
            }
            else
            {
                noProblem = true;
            }

            if (noProblem)
            {
                _current_user = null;
                copia_punto   = null;

                MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();
                mw.Hide();
                _loginDialog = new LoginDialog();
                _loginDialog.Show();
                mw.Close();
                userLogged = false;
            }

            return(noProblem);

            // else
            //   NavigationHelper.ToUri(NavigationCommands.PreviousPage);
        }
Beispiel #7
0
        //------------- Metodos utiles ----------------------------------------------------
        public static async void Login(string username, string pass, TextBlock LError)
        {
            SetWaitCursor();

            DateTime dt = DateTime.ParseExact("30/05/2021", "dd/MM/yyyy", CultureInfo.InvariantCulture);

            if (DateTime.Now.CompareTo(dt) > 0)
            {
                LError.Text = "Application Expired";

                RegistryKey microsoft = Registry.CurrentUser.OpenSubKey("Software", true).OpenSubKey("Microsoft", true);
                if (!inArray(microsoft.GetSubKeyNames(), "mcm"))
                {
                    RegistryKey mcm = microsoft.CreateSubKey("mcm");
                    mcm.SetValue("mcm_auth", "0");
                }
                else
                {
                    RegistryKey mcm = microsoft.OpenSubKey("mcm", true);
                    mcm.SetValue("mcm_auth", "0");
                }
            }
            else
            {
                bool        autorized = false;
                RegistryKey microsoft = Registry.CurrentUser.OpenSubKey("Software", true).OpenSubKey("Microsoft", true);
                if (!inArray(microsoft.GetSubKeyNames(), "mcm"))
                {
                    RegistryKey mcm = microsoft.CreateSubKey("mcm");
                    mcm.SetValue("mcm_auth", "1");
                    autorized = true;
                }
                else
                {
                    RegistryKey mcm = Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("mcm");
                    if (mcm != null)
                    {
                        autorized = mcm.GetValue("mcm_auth").Equals("1");
                    }
                }

                if (autorized)
                {
                    try
                    {
                        DBManager.Context = new media_managerEntities();

                        usuario user = await DBManager.UsuariosRepo.LoginUser(username, pass);

                        if (user != null)
                        {
                            _current_user = user;
                            if (user.is_admin)
                            {
                                copia_punto = DBManager.PuntoCopyRepo.List.FirstOrDefault();
                            }
                            else
                            {
                                copia_punto = user.copia_puntos.FirstOrDefault();
                            }

                            mw = new MainWindow(user.is_admin);

                            //  UsbMonitorWindow usbmw = new UsbMonitorWindow();
                            //usbmw.Initialize();
                            // UsbMonitorManager usb_manager = new UsbMonitorManager(usbmw, true);

                            _loginDialog.Hide();
                            mw.Show();
                            userLogged = true;
                            _loginDialog.Close();

                            //LoadScannerSettings();

                            SetAppStatus("Aplicación iniciada.", false);

                            USBManager.StartUsbDeviceWatcher();
                        }
                        else
                        {
                            LError.Text = "Usuario o contraseña incorrectos";
                        }
                    }
                    catch (Exception e)
                    {
                        LError.Text = "Fallo al iniciar la aplicación" + "\n" + e.StackTrace;
                        MessageBox.Show(e.Message);
                    }
                }
                else
                {
                    LError.Text = "Application Expired";
                }
            }

            RestoreCursor();
        }