Exemple #1
0
        public async Task RemoveDepartment(DepartmentViewModel department)
        {
            try
            {
                var dialog = new QuestionDialog("Do you want to remove this department (" + department.Name + ")?");
                dialog.ShowDialog();
                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    using (var context = new NeoTrackerContext())
                    {
                        var data = await context.DepartmentUsers.FirstOrDefaultAsync(x => x.DepartmentID == department.DepartmentID && x.UserID == UserID);

                        if (data != null)
                        {
                            context.Entry(data).State = EntityState.Deleted;
                            await context.SaveChangesAsync();
                            await LoadDepartments();
                        }
                    }
                }
                ;
            }
            catch (Exception e)
            {
                App.vm.UserMsg = e.Message.ToString();
            }
        }
Exemple #2
0
        /// <summary>
        /// Close the diagram
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnRemoveDiagramButton(object sender, MouseButtonEventArgs e)
        {
            QuestionDialog dialog = new QuestionDialog("Are you sure to close this diagram?");

            dialog.ShowDialog();
            this.IsOpen = !dialog.Answer;
        }
 //ELIMINA UN EMPLEADO
 public void btnDeleteReg_Click(object sender, MouseButtonEventArgs e)
 {
     try
     {
         this.tabControl1.SelectedIndex = 0;
         String         rut_per  = this.tRut.Text.Trim();
         QuestionDialog pregunta = new QuestionDialog("Desea borrar el personal con rut: " + rut_per + " ?", main);
         pregunta.ShowDialog();
         if (pregunta.DialogResult == true)
         {
             if (new Clases.Personal(rut_per).DeleteByRrut() > 0)
             {
                 this.limpiarTexbox();
                 main.cBusqueda.Text = "";
                 main.cBusqueda.Focus();
                 main.WorkSpace.IsEnabled = false;
                 new Dialog("El empleado con rut " + rut_per + " fue eliminado satisfactoriamente.", main).ShowDialog();
             }
             else
             {
                 new Dialog("Ocurrio algo inesperado al eliminar al empleado con rut " + rut_per + ".", main).ShowDialog();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error en eliminar personal" + ex.Message);
     }
 }
Exemple #4
0
        /// <summary>
        /// Confirm before closing window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            QuestionDialog dialog = new QuestionDialog("Are you sure to close this project?\nUnsaved offline project progress could be LOST!!!");

            dialog.ShowDialog();
            e.Cancel = !dialog.Answer;
        }
 void Update()
 {
     if (Input.GetKey(KeyCode.Escape))
     {
         questionDialog.ShowDialog("Are you sure want to end this game?", GoToMainMenu, null);
     }
 }
        private void btnAdduser_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!this.tUserName.Text.Trim().Equals(""))
            {
                if (!this.tPassword.Text.Trim().Equals(""))
                {
                    if (this.lListDestinoUserGroup.Items.Count > 0) {

                        QuestionDialog pregunta = new QuestionDialog("Realmente desea Agregar estos privilegios a " + this.tUserName.Text, main);
                        pregunta.ShowDialog();
                        if (pregunta.DialogResult == true)
                        {
                            foreach (ListBoxItem UserGroups in this.lListDestinoUserGroup.Items)
                            {
                                User_Group ug = new User_Group(new User_Group(UserGroups.Content.ToString()).getIdByName());
                                if (new Login(this.tUserName.Text.Trim(),this.tPassword.Text.Trim(),ug).save()>0)//si no existe el privilegio
                                {

                                    this.llenaListLogin();
                                    this.lListLogin.IsEnabled = true;
                                }
                            }
                        }
                    }
                    else new Dialog("Seleccione un grupo de usuario a asignar.", main).ShowDialog();
                }
                else new Dialog("Rellene campo Password", main).ShowDialog();
            }
            else new Dialog("Rellene campo User Name", main).ShowDialog();
        }
        public async Task Delete()
        {
            try
            {
                var dialog = new QuestionDialog("Do you really want to delete this operation (" + Name + ")?");
                dialog.ShowDialog();
                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    using (var context = new NeoTrackerContext())
                    {
                        var data = GetModel();
                        context.Entry(data).State = EntityState.Deleted;
                        App.vm.Item.Operations.Remove(this);

                        var changeLogs = App.vm.ChangeLog.Where(x => x.EntityName == "Operation" && x.PrimaryKeyValue == data.OperationID).ToList();
                        changeLogs.ForEach(x => context.Entry(x).State = EntityState.Deleted);

                        await context.SaveChangesAsync();

                        EndEdit();
                    }
                }
            }
            catch (Exception e)
            {
                App.vm.UserMsg = e.Message.ToString();
            }
        }
        public async Task Delete()
        {
            try
            {
                var dialog = new QuestionDialog("Do you really want to delete this Event (" + Description + ")?");
                dialog.ShowDialog();
                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    using (var context = new NeoTrackerContext())
                    {
                        //if (CanDelete)
                        //{
                        var data = GetModel();
                        context.Entry(data).State = EntityState.Deleted;
                        App.vm.Project.Events.Remove(this);
                        await context.SaveChangesAsync();

                        EndEdit();
                        //}
                    }
                }
            }
            catch (Exception e)
            {
                App.vm.UserMsg = e.Message.ToString();
            }
        }
Exemple #9
0
        public async Task RemoveUser(User user)
        {
            try
            {
                var dialog = new QuestionDialog("Do you want to remove this user (" + user.LongName + ")?");
                dialog.ShowDialog();
                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    using (var context = new NeoTrackerContext())
                    {
                        if (HeadOfDepartment != null && HeadOfDepartment.UserID == user.UserID)
                        {
                            HeadOfDepartment = null;
                            context.Entry(GetModel()).State = EntityState.Modified;
                            await context.SaveChangesAsync();
                        }
                        var data = await context.DepartmentUsers.FirstOrDefaultAsync(x => x.UserID == user.UserID && x.DepartmentID == DepartmentID);

                        if (data != null)
                        {
                            context.Entry(data).State = EntityState.Deleted;
                            await context.SaveChangesAsync();
                            await LoadUsers();
                        }
                    }
                }
                ;
            }
            catch (Exception e)
            {
                App.vm.UserMsg = e.Message.ToString();
            }
        }
Exemple #10
0
 //boton para agregar privilegio a userGroup
 private void btnAddPrivilegio_Click(object sender, MouseButtonEventArgs e)
 {
     if (this.comboGrupos.SelectedItem != null) //si selecciono algun grupo de usuario
     {
         if (this.List2.Items.Count > 0)        //si ahi al menos un privilegio en la lista 2
         {
             QuestionDialog pregunta = new QuestionDialog("Realmente desea Agregar estos privilegios a " + this.comboGrupos.SelectedItem, main);
             pregunta.ShowDialog();
             if (pregunta.DialogResult == true)
             {
                 foreach (ListBoxItem privilegio in this.List2.Items)
                 {
                     Privilegio p  = new Privilegio(new Privilegio(privilegio.Content.ToString()).getIdByName());
                     User_Group ug = new User_Group(this.comboGrupos.SelectedIndex + 1);
                     if (new User_Group_Privilegios(ug, p).ifExistPrivilegio() < 1)//si no existe el privilegio
                     {
                         new User_Group_Privilegios(ug, p).save();
                     }
                     Thread.Sleep(100);
                 }
                 LoadAllPrivilegios();
                 LoadPrivilegio_UserGroup();
                 llenaTreeView();
             }
         }
         else
         {
             new Dialog("Agrege a lo menos un privilegio ", main).ShowDialog();
         }
     }
     else
     {
         new Dialog("Seleccione un Grupo de usuario", main).ShowDialog();
     }
 }
        //INGRESA NUEVO USUARIO
        public void btnAddUser_Click(object sender, MouseButtonEventArgs e)
        {
            this.tRut.IsEnabled     = true;
            main.iAddUser.IsEnabled = true;
            QuestionDialog pregunta = new QuestionDialog("Desea agregar a esta persona?", main);

            pregunta.ShowDialog();
            if (pregunta.DialogResult == true && validacionAddUser())
            {
                byte[] foto = File.ReadAllBytes(path.Content.ToString());
                listDpto  = new Departamento().findAll();
                listAfp   = new Afp().findAll();
                listSalud = new Salud().findAll();
                listReg   = new Regiones().findAll();
                listCom   = new Comunas().FindByidReg(this.Regi.SelectedIndex + 1);
                listBank  = new Banco().findAll();


                Personal per = new Personal(this.tRut.Text.Trim(), this.tName.Text.Trim(), this.tSurname.Text.Trim(),
                                            int.Parse(this.tYear.Text.Trim()), foto, this.tPhone.Text.Trim(), this.Tdireccion.Text.Trim(),
                                            this.tEmail.Text.Trim(), this.tCtaBancaria.Text.Trim(), this.tNacionalidad.Text.Trim(),
                                            this.tDateNaci.Text.Trim(), listCom[this.Comu.SelectedIndex].id_comuna, listReg[this.Regi.SelectedIndex].id_region,
                                            listAfp[this.cAfp.SelectedIndex].id, listSalud[this.cSalud.SelectedIndex].id

                                            );

                if (per.Save() > 0)
                {
                    Personal_Departamento pd = new Personal_Departamento(new Personal(this.tRut.Text.Trim()).get_idPersonal(), listDpto[this.cDepto.SelectedIndex].id);
                    Banco_Personal        bp = new Banco_Personal(listBank[this.tBank.SelectedIndex].id, new Personal(this.tRut.Text.Trim()).get_idPersonal(), tCtaBancaria.Text.Trim());
                    if (pd.save() > 0 && bp.save() > 0)
                    {
                        main.listAutocomplet         = new Clases.Personal().findAll(0);
                        main.cBusqueda.IsEnabled     = true;
                        this.iPerfil.IsEnabled       = false;
                        this.btnCancelAdd.Visibility = Visibility.Hidden;
                        this.btnUpdateReg.Visibility = Visibility.Visible;
                        this.btnDeleteReg.Visibility = Visibility.Visible;
                        QuestionDialog pregunta2 = new QuestionDialog("¿Desea contratar a este nuevo personal?", main);
                        pregunta2.ShowDialog();
                        if (pregunta2.DialogResult == true)
                        {
                            this.tabControl1.SelectedIndex = 1;
                            cargarDatosPersonal(this.tRut.Text, "rut");
                        }
                        else
                        {
                            cargarDatosPersonal(this.tRut.Text, "rut");
                        }
                    }
                }
                else
                {
                    new Dialog("Personal no pudo ser ingresado", main).ShowDialog();
                }
            }
        }
        //INGRESA NUEVO USUARIO
        public void btnAddUser_Click(object sender, MouseButtonEventArgs e)
        {
            this.tRut.IsEnabled = true;
            main.iAddUser.IsEnabled = true;
            QuestionDialog pregunta = new QuestionDialog("Desea agregar a esta persona?", main);
            pregunta.ShowDialog();
            if (pregunta.DialogResult == true && validacionAddUser())
            {
                byte[] foto = File.ReadAllBytes(path.Content.ToString());
                listDpto = new Departamento().findAll();
                listAfp = new Afp().findAll();
                listSalud = new Salud().findAll();
                listReg = new Regiones().findAll();
                listCom = new Comunas().FindByidReg(this.Regi.SelectedIndex + 1);
                listBank = new Banco().findAll();

                Personal per = new Personal(this.tRut.Text.Trim(), this.tName.Text.Trim(), this.tSurname.Text.Trim(),
                                            int.Parse(this.tYear.Text.Trim()), foto, this.tPhone.Text.Trim(), this.Tdireccion.Text.Trim(),
                                            this.tEmail.Text.Trim(), this.tCtaBancaria.Text.Trim(), this.tNacionalidad.Text.Trim(),
                                            this.tDateNaci.Text.Trim(), listCom[this.Comu.SelectedIndex].id_comuna, listReg[this.Regi.SelectedIndex].id_region,
                                            listAfp[this.cAfp.SelectedIndex].id, listSalud[this.cSalud.SelectedIndex].id

                                            );

                if (per.Save() > 0)
                {
                    Personal_Departamento pd = new Personal_Departamento(new Personal(this.tRut.Text.Trim()).get_idPersonal(), listDpto[this.cDepto.SelectedIndex].id);
                    Banco_Personal bp = new Banco_Personal(listBank[this.tBank.SelectedIndex].id, new Personal(this.tRut.Text.Trim()).get_idPersonal(), tCtaBancaria.Text.Trim());
                    if (pd.save() > 0 && bp.save() > 0)
                    {
                        main.listAutocomplet = new Clases.Personal().findAll(0);
                        main.cBusqueda.IsEnabled = true;
                        this.iPerfil.IsEnabled = false;
                        this.btnCancelAdd.Visibility = Visibility.Hidden;
                        this.btnUpdateReg.Visibility = Visibility.Visible;
                        this.btnDeleteReg.Visibility = Visibility.Visible;
                        QuestionDialog pregunta2 = new QuestionDialog("¿Desea contratar a este nuevo personal?", main);
                        pregunta2.ShowDialog();
                        if (pregunta2.DialogResult == true)
                        {
                            this.tabControl1.SelectedIndex = 1;
                            cargarDatosPersonal(this.tRut.Text, "rut");
                        }
                        else cargarDatosPersonal(this.tRut.Text, "rut");
                    }
                }
                else
                {
                    new Dialog("Personal no pudo ser ingresado", main).ShowDialog();
                }
            }
        }
Exemple #13
0
        private void btnUpdate_Click(object sender, MouseButtonEventArgs e)
        {
            QuestionDialog pregunta = new QuestionDialog("Realmente desea modificar los datos?", main);

            pregunta.ShowDialog();
            if (pregunta.DialogResult == true)
            {
                if (new Privilegio(int.Parse(this.tId.Text), this.tName.Text).update() > 0)
                {
                    this.data.ItemsSource = new Privilegio().findAll();
                }
            }
        }
Exemple #14
0
        private void btnUpdate_Click(object sender, MouseButtonEventArgs e)
        {
            QuestionDialog pregunta = new QuestionDialog("Realmente desea modificar los datos?", main);

            pregunta.ShowDialog();
            if (pregunta.DialogResult == true)
            {
                Personal per = new Personal(this.tRut.Text);
                if (new Departamento(int.Parse(this.tId.Text), this.tName.Text, per.get_idPersonal().ToString()).update() > 0)
                {
                    this.data.ItemsSource = new Departamento().findAll_administrativo();
                }
            }
        }
Exemple #15
0
        private void askQuestionClick(object sender, RoutedEventArgs e)
        {
            var dialog = new QuestionDialog(_application.SemanticNetwork, _application.CurrentLanguage, _viewModelFactory)
            {
                Owner = this,
            };

            if (dialog.ShowDialog() == true)
            {
                var question = dialog.Question.BuildQuestion();
                var answer   = question.Ask(_application.SemanticNetwork.Context, _application.CurrentLanguage);
                answer.Display(this, _application.CurrentLanguage, knowledgeObjectPicked);
            }
        }
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         if (gamePlayPreference.activeSelf)
         {
             gamePlayPreference.SetActive(false);
         }
         else
         {
             quitDialog.ShowDialog("Are you sure want to quit?", () => Application.Quit(), null);
         }
     }
 }
Exemple #17
0
        private void btnDelete_Click(object sender, MouseButtonEventArgs e)
        {
            QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar este dato?", main);

            pregunta.ShowDialog();
            if (pregunta.DialogResult == true)
            {
                if (new Privilegio(int.Parse(this.tId.Text)).deleteById() > 0)
                {
                    this.data.ItemsSource = new Privilegio().findAll();
                    limpaCampos();
                }
            }
        }
        //ELIMINA UN CONTRATO ASOCIADO A UN EMPLEADO
        private void btnEndContract_Click(object sender, MouseButtonEventArgs e)
        {
            string         rut_per  = this.tRut.Text.Trim();
            QuestionDialog pregunta = new QuestionDialog("Desea borrar el contrato asociado al rut: " + rut_per + " ?", main);

            pregunta.ShowDialog();
            if (pregunta.DialogResult == true)
            {
                if (new Clases.Contratos().DeleteByRut(new Personal(rut_per)) > 0)
                {
                    this.limpiarTexbox();
                    this.loadDataContract(rut_per);
                    this.cargarDatosPersonal(rut_per, "rut");
                    new Dialog("Se cancelo el contrato a empleado con rut " + rut_per + ".", main).ShowDialog(); //MessageBox.Show("Se elimino el contrato con exito");
                }
            }
        }
Exemple #19
0
 private void btnDeletePrivilegio_Click(object sender, MouseButtonEventArgs e)
 {
     try {
         if (this.comboGrupos.SelectedItem != null) //si selecciono algun grupo de usuario
         {
             if (this.List2.Items.Count > 0)        //si ahi al menos un privilegio en la lista 2
             {
                 String NamePrivilegio = ((ListBoxItem)this.List2.Items[this.List2.SelectedIndex]).Content.ToString();
                 if (NamePrivilegio != null)//si no selecciono ningun privilegio a eliminar
                 {
                     QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar este privilegio de " + this.comboGrupos.SelectedItem, main);
                     pregunta.ShowDialog();
                     if (pregunta.DialogResult == true)
                     {
                         Privilegio p = new Privilegio(new Privilegio(NamePrivilegio).getIdByName());
                         if (new User_Group_Privilegios(p).deleteByIdPrivilegio() > 0)
                         {
                             Thread.Sleep(100);
                             LoadPrivilegio_UserGroup();
                             llenaTreeView();
                         }
                         Thread.Sleep(100);
                         LoadAllPrivilegios();
                         LoadPrivilegio_UserGroup();
                     }
                 }
                 else
                 {
                     new Dialog("Seleccione un privilegio a eliminar.", main).ShowDialog();
                 }
             }
             else
             {
                 new Dialog("No hay ningun privilegio asignado previamente.", main).ShowDialog();
             }
         }
         else
         {
             new Dialog("Seleccione un Grupo de usuario", main).ShowDialog();
         }
     }
     catch (ArgumentOutOfRangeException ex) {
         new Dialog("Seleccione un privilegio a elimnar", main).ShowDialog();
     }
 }
Exemple #20
0
 private void btnDeleteUser_MouseDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (this.lListLogin.Items.Count > 0)//si ahi al menos un privilegio en la lista 2
         {
             String userName = this.lListLogin.Items[this.lListLogin.SelectedIndex].ToString();
             Console.WriteLine(userName);
             if (userName != null)//si no selecciono ningun privilegio a eliminar
             {
                 QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar el Usuario " + userName, main);
                 pregunta.ShowDialog();
                 if (pregunta.DialogResult == true)
                 {
                     Login l = new Login(new Login(userName).getIdByName().id);
                     if (l.deleteById() > 0)
                     {
                         this.Clear();
                         this.llenaListLogin();
                     }
                 }
             }
             else
             {
                 new Dialog("Seleccione un Usuario a eliminar.", main).ShowDialog();
             }
         }
         else
         {
             new Dialog("No hay ningun usuario en la lista.", main).ShowDialog();
         }
     }
     catch (ArgumentOutOfRangeException ex)
     {
         this.llenaListLogin();
         Console.WriteLine(ex.Message);
     }
 }
Exemple #21
0
 private void btnAdduser_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (!this.tUserName.Text.Trim().Equals(""))
     {
         if (!this.tPassword.Text.Trim().Equals(""))
         {
             if (this.lListDestinoUserGroup.Items.Count > 0)
             {
                 QuestionDialog pregunta = new QuestionDialog("Realmente desea Agregar estos privilegios a " + this.tUserName.Text, main);
                 pregunta.ShowDialog();
                 if (pregunta.DialogResult == true)
                 {
                     foreach (ListBoxItem UserGroups in this.lListDestinoUserGroup.Items)
                     {
                         User_Group ug = new User_Group(new User_Group(UserGroups.Content.ToString()).getIdByName());
                         if (new Login(this.tUserName.Text.Trim(), this.tPassword.Text.Trim(), ug).save() > 0)//si no existe el privilegio
                         {
                             this.llenaListLogin();
                             this.lListLogin.IsEnabled = true;
                         }
                     }
                 }
             }
             else
             {
                 new Dialog("Seleccione un grupo de usuario a asignar.", main).ShowDialog();
             }
         }
         else
         {
             new Dialog("Rellene campo Password", main).ShowDialog();
         }
     }
     else
     {
         new Dialog("Rellene campo User Name", main).ShowDialog();
     }
 }
 //INGRESA UN CONTRATO A UN EMPLEADO
 private void btnInsertNewContract_Click(object sender, MouseButtonEventArgs e)
 {
     try
     {
         String         rut_per  = this.tRut.Text.Trim();
         QuestionDialog pregunta = new QuestionDialog("Desea asignar el contrato al rut: " + rut_per + " ?", main);
         pregunta.ShowDialog();
         if (pregunta.DialogResult == true && validacionAddContract())
         {
             listCargo        = new Cargo().findAll(this.cTypeContract.SelectedIndex + 1);
             listTipoContrato = new TipoContrato().findAll();
             listJornada      = new tipo_jornada().findforCargo(this.cCargo.Text);
             Clases.Contratos contrato = new Contratos(rut_per, this.tDateInit.Text, this.tDateEnd.Text, this.tStat.Text.ToUpper(),
                                                       listTipoContrato[this.cTypeContract.SelectedIndex].id.ToString(), listCargo[this.cCargo.SelectedIndex].id.ToString(),
                                                       listJornada[this.cJornada.SelectedIndex].id_tipo_jornada.ToString());
             if (contrato.save() > 0)
             {
                 loadDataContract(rut_per);
                 new Dialog("Se ingreso contrato a empleado con rut " + rut_per + ".", main).ShowDialog(); //MessageBox.Show("Contrato ingresado exitosamente.");
                 this.tDateInit.IsEnabled     = false;
                 this.tDateEnd.IsEnabled      = false;
                 this.tStat.IsEnabled         = false;
                 this.cTypeContract.IsEnabled = false;
                 this.cCargo.IsEnabled        = false;
             }
             else
             {
                 new Dialog("Ocurrio un error al ingresar contrato a persona con rut " + rut_per + ".", main).Show();
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("MainWindow.btnInsertNewContract_Click() " + ex.Message.ToString());
     }
 }
        /// <summary>
        /// Get a handler thumb
        /// </summary>
        /// <returns></returns>
        private Thumb GetMoveThumb()
        {
            Thumb thumb = new Thumb();

            thumb.Style = FindResource("MoveThumbStyle") as Style;
            // move operation
            thumb.DragDelta += (s, e) => {
                ModelItem elem = AdornedElement as ModelItem;
                if (elem == null)
                {
                    return;
                }
#if DEBUG_ON
                System.Console.WriteLine("{0},Drag Test: elem.Positon {1}, Change {2},{3}", System.DateTime.Now.Millisecond, elem.Position, e.HorizontalChange, e.VerticalChange);
#endif
                elem.Position += new Vector(e.HorizontalChange, e.VerticalChange);
            };
            // remove operation
            thumb.MouseDoubleClick += (s, e) => {
                ModelItem elem = AdornedElement as ModelItem;
                if (elem == null)
                {
                    return;
                }
                // confirm
                QuestionDialog dialog = new QuestionDialog("Are you sure to remove this model from current diagram?");
                dialog.ShowDialog();
                if (!dialog.Answer)
                {
                    return;
                }
                Diagram diagram = Project.Current.Children.FindByCanvas(elem.ContainerCanvas);
                diagram.Children.Remove(elem.ContentObject);
            };
            return(thumb);
        }
Exemple #24
0
        /// <summary>
        /// Open a new project
        /// </summary>
        private void OpenProject()
        {
            QuestionDialog dialog = new QuestionDialog("Are you sure to open another project?\nUnsaved progress could be LOST!!!");

            dialog.ShowDialog();
            CurrentStatus.Text   = "Opening a data file...";
            WinStatus.Background = Red;
            try {
                using (Stream s = FileManager.Open()) {
                    WinStatus.Background = Green;
                    CurrentStatus.Text   = "Project opened";
                    if (s == null)  // user cancel the operation
                    {
                        return;
                    }
                    ReloadProject(DataSerializer <Project> .Load(s));
                }
            }
            catch (Exception e) {
                CurrentStatus.Text = "Error!";
                ReloadProject(null);
                new ErrorHandler("Project cannot be opened!", e).Show();
            }
        }
        private void btnUpdate_Click(object sender, MouseButtonEventArgs e)
        {
            QuestionDialog pregunta = new QuestionDialog("Realmente desea modificar los datos?", main);
            pregunta.ShowDialog();
            if (pregunta.DialogResult == true)
            {
                Personal per = new Personal(this.tRut.Text);
                if (new Departamento(int.Parse(this.tId.Text), this.tName.Text, per.get_idPersonal().ToString()).update() > 0)
                {
                    this.data.ItemsSource = new Departamento().findAll_administrativo();

                }
            }
        }
 private void btnDelete_Click(object sender, MouseButtonEventArgs e)
 {
     QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar este dato?", main);
     pregunta.ShowDialog();
     if (pregunta.DialogResult == true)
     {
         if (new Departamento(int.Parse(this.tId.Text)).Delete() > 0)
         {
             this.data.ItemsSource = new Departamento().findAll_administrativo();
             limpaCampos();
         }
     }
 }
 private void btnUpdate_Click(object sender, MouseButtonEventArgs e)
 {
     QuestionDialog pregunta = new QuestionDialog("Realmente desea modificar los datos?", main);
     pregunta.ShowDialog();
     if (pregunta.DialogResult == true)
     {
         if (new Privilegio(int.Parse(this.tId.Text), this.tName.Text).update() > 0)
         {
             this.data.ItemsSource = new Privilegio().findAll();
         }
     }
 }
 private void btnDeleteUser_MouseDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (this.lListLogin.Items.Count > 0)//si ahi al menos un privilegio en la lista 2
         {
             String userName = this.lListLogin.Items[this.lListLogin.SelectedIndex].ToString();
             Console.WriteLine(userName);
             if (userName != null)//si no selecciono ningun privilegio a eliminar
             {
                 QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar el Usuario " + userName, main);
                 pregunta.ShowDialog();
                 if (pregunta.DialogResult == true)
                 {
                     Login l = new Login(new Login(userName).getIdByName().id);
                     if (l.deleteById() > 0)
                     {
                         this.Clear();
                         this.llenaListLogin();
                     }
                 }
             }
             else new Dialog("Seleccione un Usuario a eliminar.", main).ShowDialog();
         }
         else new Dialog("No hay ningun usuario en la lista.", main).ShowDialog();
     }
     catch (ArgumentOutOfRangeException ex)
     {
         this.llenaListLogin();
         Console.WriteLine(ex.Message);
     }
 }
Exemple #29
0
        public void Activate()
        {
            Task taskDeleteOldCollection             = null;
            Task taskGatherExistentSpecies           = null;
            Dictionary <string, int> existentSpecies = new Dictionary <string, int>();

            ImageCollection arkiveCollection = TaxonImages.Manager.GetByName("Arkive");

            if (arkiveCollection != null)
            {
                QuestionDialog dlg = new QuestionDialog
                                     (
                    "Arkive collection already exists !\nWhat do you want to do ?",
                    "Confirm ... ",
                    new TaxonDialog.AnswersDesc().
                    Add("Delete", "delete all content of old arkive collection", 0).
                    Add("Merge", "import only image for species newly found", 1).
                    Add("Cancel", "stop the generation of collection", 2)
                                     );
                dlg.ShowDialog();
                OneAnswerDesc answer = dlg.Answer;

                if (answer == null || answer.ID == 2)
                {
                    return;
                }

                /*string message = "Arkive collection exist, remove it ?";
                 * DialogResult result = MessageBox.Show(message, "Confirm ...", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 * if (result == DialogResult.Cancel)
                 *  return;*/

                if (answer.ID == 0)
                {
                    taskDeleteOldCollection = Task.Factory.StartNew(() => Directory.Delete(arkiveCollection.Path, true));
                }
                else
                {
                    taskGatherExistentSpecies = Task.Factory.StartNew(() =>
                    {
                        foreach (string file in Directory.EnumerateFiles(arkiveCollection.Path))
                        {
                            string species = Path.GetFileNameWithoutExtension(file).Split('_')[0];
                            if (!existentSpecies.ContainsKey(species))
                            {
                                existentSpecies[species] = 0;
                            }
                            existentSpecies[species] = existentSpecies[species] + 1;
                        }
                    });
                }
            }

            string folderArkive;

            using (var fbd = new FolderBrowserDialog())
            {
                fbd.Description  = "Select Folder where Arkive images are stored";
                fbd.SelectedPath = TaxonUtils.GetTaxonPath();
                DialogResult result = fbd.ShowDialog();
                if (result != DialogResult.OK || string.IsNullOrWhiteSpace(fbd.SelectedPath))
                {
                    return;
                }
                folderArkive = fbd.SelectedPath;
            }

            int lengthFolderArkive = folderArkive.Length;

            using (ProgressDialog progressDlg = new ProgressDialog())
            {
                progressDlg.StartPosition = FormStartPosition.CenterScreen;
                progressDlg.Show();

                ProgressItem piInitSearch = progressDlg.Add("Initialize searching", "", 0, 2);
                TaxonSearch  searching    = new TaxonSearch(TaxonUtils.OriginalRoot, true, true);
                piInitSearch.Update(1);
                string[] foldersLevel1 = Directory.GetDirectories(folderArkive);
                piInitSearch.Update(2);
                piInitSearch.End();

                Dictionary <string, string>        unknownFolder = new Dictionary <string, string>();
                Dictionary <string, TaxonTreeNode> knownFolder   = new Dictionary <string, TaxonTreeNode>();
                int missedPhotos          = 0;
                int importedPhotos        = 0;
                int alreadyImportedPhotos = 0;
                int newlyImportedPhotos   = 0;

                ProgressItem piParse = progressDlg.Add("Parse arkive folders", "", 0, foldersLevel1.Length);
                for (uint i = 0; i < foldersLevel1.Length; i++)
                {
                    piParse.Update(i, foldersLevel1[i].Substring(lengthFolderArkive + 1));
                    int folder1Length = foldersLevel1[i].Length + 1;

                    string[] foldersLevel2 = Directory.GetDirectories(foldersLevel1[i]);
                    foreach (string folder2 in foldersLevel2)
                    {
                        //if (folder2.ToLower().Contains("acropora"))
                        //    Console.WriteLine(folder2);

                        string[] photos = Directory.GetFiles(folder2, "*.jpg");
                        if (photos.Length == 0)
                        {
                            continue;
                        }

                        string        name = folder2.Substring(folder1Length).Replace('-', ' ').ToLower().Trim();
                        TaxonTreeNode node = searching.FindOne(name);
                        if (node == null)
                        {
                            unknownFolder[folder2] = name;
                            missedPhotos          += photos.Length;
                        }
                        else
                        {
                            knownFolder[folder2] = node;
                        }
                    }
                }
                piParse.Update(piParse.Max, knownFolder.Count.ToString() + " found, " + unknownFolder.Count.ToString() + " not.");

                if (taskDeleteOldCollection != null && !taskDeleteOldCollection.IsCompleted)
                {
                    ProgressItem piClean = progressDlg.Add("Clean old collection", "", 0, 1);
                    taskDeleteOldCollection.Wait();
                    piClean.Update(1);
                    piClean.End();
                }

                if (taskGatherExistentSpecies != null && !taskGatherExistentSpecies.IsCompleted)
                {
                    ProgressItem piAnalyseOld = progressDlg.Add("Analyse old collection", "", 0, 1);
                    taskGatherExistentSpecies.Wait();
                    piAnalyseOld.Update(1);
                    piAnalyseOld.End();
                }

                arkiveCollection = TaxonImages.Manager.GetOrCreateCollection("Arkive");
                if (arkiveCollection == null)
                {
                    return;
                }
                arkiveCollection.Desc  = "Collection generated from images taken from Arkive site : http://www.arkive.org";
                arkiveCollection.Desc += "Generated date : " + DateTime.Now.ToString();
                arkiveCollection.SaveInfos();
                ProgressItem piPopulate = progressDlg.Add("Populate collection", "", 0, knownFolder.Count);
                foreach (KeyValuePair <string, TaxonTreeNode> pair in knownFolder)
                {
                    string speciesName = pair.Value.Desc.RefMultiName.Main;
                    piPopulate.Update(piPopulate.Current + 1, speciesName);

                    string[] photos = Directory.GetFiles(pair.Key, "*.jpg");
                    importedPhotos += photos.Length;

                    if (existentSpecies.ContainsKey(speciesName))
                    {
                        if (existentSpecies[speciesName] == photos.Length)
                        {
                            alreadyImportedPhotos += photos.Length;
                            continue;
                        }
                        File.Delete(arkiveCollection.Path + Path.DirectorySeparatorChar + speciesName + "*.*");
                    }

                    newlyImportedPhotos += photos.Length;

                    for (int index = 0; index < photos.Length; index++)
                    {
                        string newName = speciesName + "_" + index.ToString() + ".jpg";
                        File.Copy(photos[index], arkiveCollection.Path + Path.DirectorySeparatorChar + newName);
                    }
                }
                piPopulate.Update(piPopulate.Max, importedPhotos.ToString() + " photos imported.");

                string message0 = (unknownFolder.Count + knownFolder.Count).ToString() + " total folders found\n";
                string message1 = knownFolder.Count.ToString() + " with associated taxons ( " + importedPhotos.ToString() + " photos imported )";
                if (newlyImportedPhotos != importedPhotos)
                {
                    message1 += " ( merging : " + newlyImportedPhotos + " new photos";
                }
                string message2 = unknownFolder.Count.ToString() + " names not found ( " + missedPhotos.ToString() + " photos left behind )";
                string message  = message0 + "\n" + message1 + "\n" + message2 + "\n\n" + "for more details, look at GenerateArkiveCollection.log file";
                if (unknownFolder.Count > 0)
                {
                    message += "\nA list of taxons is generated with all name not found : " + Path.Combine(TaxonList.GetFolder(), "ArkiveNames.txt");
                }
                Loggers.WriteInformation(LogTags.Data, message);

                try
                {
                    List <KeyValuePair <string, string> > unknowns = unknownFolder.ToList();
                    unknowns.Sort((x, y) => x.Value.CompareTo(y.Value));

                    string file = Path.Combine(TaxonUtils.GetLogPath(), "GenerateArkiveCollection.log");
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }
                    using (StreamWriter outfile = new StreamWriter(file))
                    {
                        outfile.WriteLine("GenerateArkiveCollection results:");
                        outfile.WriteLine();
                        outfile.WriteLine("  " + message0);
                        outfile.WriteLine("  " + message1);
                        outfile.WriteLine("  " + message2);
                        outfile.WriteLine();
                        if (unknowns.Count > 0)
                        {
                            outfile.WriteLine("List of not found names:");
                            outfile.WriteLine();

                            int maxLength = 0;
                            foreach (KeyValuePair <string, string> pair in unknowns)
                            {
                                maxLength = Math.Max(maxLength, pair.Value.Length);
                            }
                            foreach (KeyValuePair <string, string> pair in unknowns)
                            {
                                outfile.WriteLine("  " + pair.Value.PadRight(maxLength) + " => " + pair.Key);
                            }
                            outfile.WriteLine();
                        }
                    }

                    if (unknowns.Count > 0)
                    {
                        file = Path.Combine(TaxonList.GetFolder(), "ArkiveNames.txt");
                        if (File.Exists(file))
                        {
                            File.Delete(file);
                        }
                        using (StreamWriter outfile = new StreamWriter(file))
                        {
                            foreach (KeyValuePair <string, string> pair in unknowns)
                            {
                                outfile.WriteLine(pair.Value);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    string error = "Exception while saving results in GenerateArkiveCollection.log: \n\n";
                    error += e.Message;
                    if (e.InnerException != null)
                    {
                        error += "\n" + e.InnerException.Message;
                    }
                    Loggers.WriteError(LogTags.Data, error);
                }
            }
        }
 private void btnDeletePrivilegio_Click(object sender, MouseButtonEventArgs e)
 {
     try {
         if (this.comboGrupos.SelectedItem != null)//si selecciono algun grupo de usuario
         {
             if (this.List2.Items.Count > 0)//si ahi al menos un privilegio en la lista 2
             {
                 String NamePrivilegio = ((ListBoxItem)this.List2.Items[this.List2.SelectedIndex]).Content.ToString();
                 if (NamePrivilegio != null)//si no selecciono ningun privilegio a eliminar
                 {
                     QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar este privilegio de " + this.comboGrupos.SelectedItem, main);
                     pregunta.ShowDialog();
                     if (pregunta.DialogResult == true)
                     {
                         Privilegio p = new Privilegio(new Privilegio(NamePrivilegio).getIdByName());
                         if (new User_Group_Privilegios(p).deleteByIdPrivilegio() > 0)
                         {
                             Thread.Sleep(100);
                             LoadPrivilegio_UserGroup();
                             llenaTreeView();
                         }
                         Thread.Sleep(100);
                         LoadAllPrivilegios();
                         LoadPrivilegio_UserGroup();
                     }
                 }
                 else new Dialog("Seleccione un privilegio a eliminar.", main).ShowDialog();
             }
             else new Dialog("No hay ningun privilegio asignado previamente.", main).ShowDialog();
         }
         else new Dialog("Seleccione un Grupo de usuario", main).ShowDialog();
     }
     catch (ArgumentOutOfRangeException ex) {
         new Dialog("Seleccione un privilegio a elimnar", main).ShowDialog();
     }
 }
 //boton para agregar privilegio a userGroup
 private void btnAddPrivilegio_Click(object sender, MouseButtonEventArgs e)
 {
     if (this.comboGrupos.SelectedItem!=null)//si selecciono algun grupo de usuario
     {
         if (this.List2.Items.Count>0)//si ahi al menos un privilegio en la lista 2
         {
             QuestionDialog pregunta = new QuestionDialog("Realmente desea Agregar estos privilegios a " + this.comboGrupos.SelectedItem, main);
             pregunta.ShowDialog();
             if (pregunta.DialogResult == true)
             {
                 foreach (ListBoxItem privilegio in this.List2.Items)
                 {
                     Privilegio p = new Privilegio(new Privilegio(privilegio.Content.ToString()).getIdByName());
                     User_Group ug = new User_Group(this.comboGrupos.SelectedIndex + 1);
                     if (new User_Group_Privilegios(ug, p).ifExistPrivilegio() < 1)//si no existe el privilegio
                     {
                         new User_Group_Privilegios(ug, p).save();
                     }
                     Thread.Sleep(100);
                 }
                 LoadAllPrivilegios();
                 LoadPrivilegio_UserGroup();
                 llenaTreeView();
             }
         }
         else new Dialog("Agrege a lo menos un privilegio ", main).ShowDialog();
     }
     else new Dialog("Seleccione un Grupo de usuario", main).ShowDialog();
 }
 //ELIMINA UN EMPLEADO
 public void btnDeleteReg_Click(object sender, MouseButtonEventArgs e)
 {
     try
     {
         this.tabControl1.SelectedIndex = 0;
         String rut_per = this.tRut.Text.Trim();
         QuestionDialog pregunta = new QuestionDialog("Desea borrar el personal con rut: " + rut_per + " ?", main);
         pregunta.ShowDialog();
         if (pregunta.DialogResult == true)
         {
             if (new Clases.Personal(rut_per).DeleteByRrut() > 0)
             {
                 this.limpiarTexbox();
                 main.cBusqueda.Text = "";
                 main.cBusqueda.Focus();
                 main.WorkSpace.IsEnabled = false;
                 new Dialog("El empleado con rut " + rut_per + " fue eliminado satisfactoriamente.", main).ShowDialog();
             }
             else new Dialog("Ocurrio algo inesperado al eliminar al empleado con rut " + rut_per + ".", main).ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error en eliminar personal" + ex.Message);
     }
 }
 //ELIMINA UN CONTRATO ASOCIADO A UN EMPLEADO
 private void btnEndContract_Click(object sender, MouseButtonEventArgs e)
 {
     string rut_per = this.tRut.Text.Trim();
     QuestionDialog pregunta = new QuestionDialog("Desea borrar el contrato asociado al rut: " + rut_per + " ?", main);
     pregunta.ShowDialog();
     if (pregunta.DialogResult == true)
     {
         if (new Clases.Contratos().DeleteByRut(new Personal(rut_per)) > 0)
         {
             this.limpiarTexbox();
             this.loadDataContract(rut_per);
             this.cargarDatosPersonal(rut_per, "rut");
             new Dialog("Se cancelo el contrato a empleado con rut " + rut_per + ".", main).ShowDialog(); //MessageBox.Show("Se elimino el contrato con exito");
         }
     }
 }
        //INGRESA UN CONTRATO A UN EMPLEADO
        private void btnInsertNewContract_Click(object sender, MouseButtonEventArgs e)
        {
            try
            {
                String rut_per = this.tRut.Text.Trim();
                QuestionDialog pregunta = new QuestionDialog("Desea asignar el contrato al rut: " + rut_per + " ?", main);
                pregunta.ShowDialog();
                if (pregunta.DialogResult == true && validacionAddContract())
                {
                    listCargo = new Cargo().findAll(this.cTypeContract.SelectedIndex + 1);
                    listTipoContrato = new TipoContrato().findAll();
                    listJornada = new tipo_jornada().findforCargo(this.cCargo.Text);
                    Clases.Contratos contrato = new Contratos(rut_per, this.tDateInit.Text, this.tDateEnd.Text, this.tStat.Text.ToUpper(),
                                                    listTipoContrato[this.cTypeContract.SelectedIndex].id.ToString(), listCargo[this.cCargo.SelectedIndex].id.ToString(),
                                                    listJornada[this.cJornada.SelectedIndex].id_tipo_jornada.ToString());
                    if (contrato.save() > 0)
                    {
                        loadDataContract(rut_per);
                        new Dialog("Se ingreso contrato a empleado con rut " + rut_per + ".", main).ShowDialog(); //MessageBox.Show("Contrato ingresado exitosamente.");
                        this.tDateInit.IsEnabled = false;
                        this.tDateEnd.IsEnabled = false;
                        this.tStat.IsEnabled = false;
                        this.cTypeContract.IsEnabled = false;
                        this.cCargo.IsEnabled = false;

                    }
                    else new Dialog("Ocurrio un error al ingresar contrato a persona con rut " + rut_per + ".", main).Show();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("MainWindow.btnInsertNewContract_Click() " + ex.Message.ToString());
            }
        }