Beispiel #1
0
        } //Clave de Método: Moves-MLM

        private void ControlClickMethod(object sender, EventArgs e)
        {
            try
            {
                for (; Index < ArrayControl.Length; Index++)
                {
                    if (ArrayControl[Index] == sender)
                    {
                        break;
                    }
                }
                switch (Index)
                {
                case 0:     // ButtonSearch
                {
                    if (TextBoxSearch.Visible)
                    {
                        if (ObjValidations.NumControlCheck(TextBoxSearch.TextTextBox.Trim()))
                        {
                            ObjSearch.NumControl = TextBoxSearch.TextTextBox.Trim();
                        }
                        else
                        {
                            throw new FormatException();
                        }
                    }
                    else
                    {
                        ObjSearch.NumControl = string.Empty;
                    }
                    if (RadioButtonAllDepartments.Checked || (!RadioButtonAllDepartments.Checked && !RadioButtonSearchDepartment.Checked) || !GroupBoxDepartment.Visible)
                    {
                        ObjSearch.IndexDeparmentStart = 0;
                        ObjSearch.IndexDeparmentEnd   = 30;
                    }
                    else
                    {
                        ObjSearch.IndexDeparmentStart = ComboTypeDepartment.SelectedIndex;
                        ObjSearch.IndexDeparmentEnd   = ComboTypeDepartment.SelectedIndex;
                    }
                    if (RadioButtonBothSex.Checked || (!RadioButtonBothSex.Checked && !RadioButtonMan.Checked && !RadioButtonWoman.Checked) || !GroupBoxSex.Visible)
                    {
                        ObjSearch.SexStart = 'M';
                        ObjSearch.SexEnd   = 'F';
                    }
                    else if (RadioButtonMan.Checked)
                    {
                        ObjSearch.SexStart = 'M';
                        ObjSearch.SexEnd   = 'M';
                    }
                    else
                    {
                        ObjSearch.SexStart = 'F';
                        ObjSearch.SexEnd   = 'F';
                    }
                    if (PanelDate.Visible)
                    {
                        ObjSearch.DateStart = DateTimePickerStart.Value;
                        ObjSearch.DateEnd   = DateTimePickerEnd.Value;
                    }
                    else
                    {
                        DateTimePickerStart.Value = DateTime.Parse("2000-01-01");
                        ObjSearch.DateEnd         = DateTimePickerEnd.Value;
                    }
                    ObjValidations.SearchMoves(TypeModules.Moves, ObjSearch);
                    PopUpGridSearch ObjPopUpGridSearch = new PopUpGridSearch(TypeModules.Moves, ObjSearch, "Búsqueda de Movimientos");
                    ObjPopUpGridSearch.Show();
                    break;
                }

                case 1:     // ButtonSearchAll
                {
                    ObjSearch.NumControl          = "";
                    ObjSearch.IndexDeparmentStart = 0;
                    ObjSearch.IndexDeparmentEnd   = 30;
                    ObjSearch.SexStart            = 'F';
                    ObjSearch.SexEnd          = 'M';
                    DateTimePickerStart.Value = DateTime.Parse("2000-01-01");
                    ObjSearch.DateEnd         = DateTimePickerEnd.Value;
                    ObjValidations.SearchMoves(TypeModules.Moves, ObjSearch);
                    PopUpGridSearch ObjPopUpGridSearch = new PopUpGridSearch(TypeModules.Moves, ObjSearch, "Búsqueda de Movimientos");
                    ObjPopUpGridSearch.Show();
                    break;
                }

                case 2:     //ButtonCleanSearch
                {
                    RadioButtonBothSex.Checked          = false;
                    RadioButtonMan.Checked              = false;
                    RadioButtonWoman.Checked            = false;
                    RadioButtonAllDepartments.Checked   = false;
                    RadioButtonSearchDepartment.Checked = false;
                    ComboTypeDepartment.Visible         = false;
                    DateTimePickerStart.Value           = DateTime.Now.AddMonths(-1);
                    DateTimePickerEnd.Value             = DateTime.Now;
                    break;
                }

                default:
                    throw new Exception("Excepción en Método: Moves-CCM", new IndexOutOfRangeException());
                }
            }
            catch (IndexOutOfRangeException)
            {
            }
            catch (FormatException)
            {
                using (Alerts ObjAlerts = new Alerts("Número de Control Invalido", "", "El número de control ingresado no es valido\n\nVereifique el texto que ingresó.", 1, "", "", "OK", TypeIcon.Warning))
                {
                    if (ObjAlerts.ShowDialog() == DialogResult.OK)
                    {
                        ObjAlerts.Close();
                        ObjAlerts.Dispose();
                    }
                }
            }
            Index = 0;
        } //Clave de Método: Moves-CCM
Beispiel #2
0
        } //Clave de Método: Stats-CIM

        private void ControlClickMethod(object sender, EventArgs e)
        {
            for (; Index < ArrayControl.Length; Index++)
            {
                if (ArrayControl[Index] == sender)
                {
                    break;
                }
            }
            switch (Index)
            {
            case 0:     //ButtonCreateReport
            {
                byte i   = 0;
                byte aux = 0;
                try
                {
                    foreach (RadioButton Value in ArrayRadioDate)
                    {
                        if (!Value.Checked)
                        {
                            i++;
                        }
                        else
                        {
                            aux = i;
                        }
                    }
                    if (i == 6)
                    {
                        throw new Exception();
                    }
                    switch (aux)
                    {
                    case 0:
                    {
                        ObjSearch.DateStart = DateTime.Now;
                        ObjSearch.DateEnd   = DateTime.Now;
                        break;
                    }

                    case 1:
                    {
                        ObjSearch.DateStart = DateTime.Now.AddDays(-7);
                        ObjSearch.DateEnd   = DateTime.Now;
                        break;
                    }

                    case 2:
                    {
                        ObjSearch.DateStart = DateTime.Now.AddMonths(-1);
                        ObjSearch.DateEnd   = DateTime.Now;
                        break;
                    }

                    case 3:
                    {
                        ObjSearch.DateStart = DateTime.Now.AddYears(-1);
                        ObjSearch.DateEnd   = DateTime.Now;
                        break;
                    }

                    case 4:
                    {
                        ObjSearch.DateStart = DateTime.Parse("2000-01-01");
                        ObjSearch.DateEnd   = DateTime.Now;
                        break;
                    }

                    case 5:
                    {
                        ObjSearch.DateStart = DateTimePickerStart.Value;
                        ObjSearch.DateEnd   = DateTimePickerEnd.Value;
                        break;
                    }

                    default:
                        throw new Exception();
                    }
                    i = 0;
                    foreach (CheckBox Value in ArrayCheckBox)
                    {
                        if (!Value.Checked)
                        {
                            i++;
                        }
                    }
                    if (i == 7)
                    {
                        throw new Exception();
                    }

                    if (RadioButtonBothSex.Checked || (!RadioButtonBothSex.Checked && !RadioButtonMan.Checked && !RadioButtonWoman.Checked))
                    {
                        ObjSearch.SexStart = 'M';
                        ObjSearch.SexEnd   = 'F';
                    }
                    else if (RadioButtonMan.Checked)
                    {
                        ObjSearch.SexStart = 'M';
                        ObjSearch.SexEnd   = 'M';
                    }
                    else
                    {
                        ObjSearch.SexStart = 'F';
                        ObjSearch.SexEnd   = 'F';
                    }
                    i = 1;
                    foreach (CheckBox Value in ArrayCheckBox)
                    {
                        if (Value.Checked)
                        {
                            ObjSearch.Services.Add(i);
                        }
                        else
                        {
                            ObjSearch.Services.Add(0);
                        }
                        i++;
                    }

                    if (ComboDepartmentCareer.SelectedIndex == 0)
                    {
                        ObjSearch.IndexDeparmentStart = 0;
                        ObjSearch.IndexDeparmentEnd   = 30;
                    }
                    else
                    {
                        ObjSearch.IndexDeparmentStart = ComboDepartmentCareer.SelectedIndex;
                        ObjSearch.IndexDeparmentEnd   = ComboDepartmentCareer.SelectedIndex;
                    }

                    ObjValidations.SearchStats(TypeModules.Stats, ObjSearch);
                    PopUpGridSearch ObjPopUpGridSearch = new PopUpGridSearch(TypeModules.Moves, ObjSearch, "Búsqueda para Reportes");
                    ObjPopUpGridSearch.Show();
                }
                catch (Exception)
                {
                    Alerts ObjAlerts = new Alerts("Falta Elegir Opciones", "", "Parece ser que no elegiste ningún tipo de servicio o ningún tipo de fecha. Estos datos son necesarios para generar el reporte.\n\nPor favor, elige algún servicio y alguna fecha para continuar.", 1);
                    ObjAlerts.ShowDialog();
                }
                finally
                {
                    i = 0;
                    ObjSearch.Services.Clear();
                }
                break;
            }

            case 1:     //ButtonCancel
            {
                CleanInputsMethod();
                break;
            }

            case 2:     //PictureBoxInfo
            {
                break;
            }

            default:
                throw new Exception("Excepción en Método: Stats-CCM", new IndexOutOfRangeException());
            }
            Index = 0;
        } //Clave de Método: Stats-CCM
Beispiel #3
0
        public void ControlClickMethod(object sender, EventArgs e)
        {
            for (; Index < ArrayControl.Length; Index++)
            {
                if (ArrayControl[Index] == sender)
                {
                    break;
                }
            }
            switch (Index)
            {
            case 0:     //ButtonExamine
            {
                using (OpenFileDialog ObjFile = new OpenFileDialog())
                {
                    ObjFile.Title            = "Archivo CSV para importación de usuarios";
                    ObjFile.Filter           = "CSV Files (*.csv) | *.csv";
                    ObjFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    ObjDialog = ObjFile.ShowDialog();
                    if (ObjDialog == DialogResult.OK)
                    {
                        string[] ArrayLinea;
                        int      x = 0;
                        try
                        {
                            string[] Lineas = File.ReadAllLines(ObjFile.FileName);
                            ObjSearch.Table.Rows.Clear();
                            GridSearch.DataSource = null;
                            if (GridSearch.Columns.Count > 0)
                            {
                                GridSearch.Columns.Clear();
                            }
                            if (GridSearch.Rows.Count > 0)
                            {
                                GridSearch.Rows.Clear();
                            }
                            foreach (string linea in Lineas)
                            {
                                x++;
                                DataRow Fila = ObjSearch.Table.NewRow();
                                string  temp = ObjValidations.RemoveAccent(linea.ToUpper());
                                temp       = ObjValidations.CleanLineaImport(temp);
                                ArrayLinea = temp.Split(',');
                                Fila["NUMERO DE CONTROL"]      = ArrayLinea[0];
                                Fila["NOMBRES"]                = ArrayLinea[1];
                                Fila["APELLIDO PATERNO"]       = ArrayLinea[2];
                                Fila["APELLIDO MATERNO"]       = ArrayLinea[3];
                                Fila["DEPARTAMENTO O CARRERA"] = ArrayLinea[4];
                                Fila["SEXO"]   = (ArrayLinea[5] == "M" || ArrayLinea[5] == "HOMBRE" || ArrayLinea[5] == "MASCULINO") ? "M" : "F";
                                Fila["STATUS"] = (ArrayLinea[6] == "A" || ArrayLinea[6] == "I" || ArrayLinea[6] == "ACTIVO" || ArrayLinea[6] == "ACT" || ArrayLinea[6] != "EGR" || ArrayLinea[6] != "EGRESADO") ? "A" : "I";
                                ObjSearch.Table.Rows.Add(Fila);
                            }
                            GridSearch.DataSource = ObjSearch.Table;
                            DataGridViewButtonColumn ObjButtonColumnEdit = new DataGridViewButtonColumn();
                            {
                                ObjButtonColumnEdit.Name       = "EDITAR";
                                ObjButtonColumnEdit.HeaderText = "EDITAR";
                                ObjButtonColumnEdit.Text       = "EDITAR";
                                ObjButtonColumnEdit.FlatStyle  = FlatStyle.Flat;
                                ObjButtonColumnEdit.UseColumnTextForButtonValue = true;
                                GridSearch.Columns.Add(ObjButtonColumnEdit);
                            }
                            GridSearch.CellClick += GridSearchCellClickMethod;
                            GridSearch.Columns["EDITAR"].DisplayIndex = GridSearch.Columns.Count - 1;
                        }
                        catch (Exception Error)
                        {
                            MessageBox.Show("Error: " + Error.ToString());
                        }
                    }
                }
                if (GridSearch.Rows.Count > 0)
                {
                    LabelTotal.Text           = GridSearch.Rows.Count.ToString();
                    ButtonImportTable.Enabled = true;
                }
                else
                {
                    LabelTotal.Text           = "0";
                    ButtonImportTable.Enabled = false;
                }
                break;
            }

            case 1:     //ButtonImportTable
            {
                if (GridSearch.Rows.Count > 0)
                {
                    using (Alerts ObjAlerts = new Alerts("Confirmación de Importación", "", "Usted está por realizar una importación de usuarios. La cantidad de usuarios a importar es de: " + GridSearch.Rows.Count.ToString() + "\n\n¿Está seguro de importar esta cantidad?", 1, "", "", "OK", TypeIcon.Warning))
                    {
                        if (ObjAlerts.ShowDialog() == DialogResult.OK)
                        {
                            DataTable TablaAuxiliar;
                            TablaAuxiliar = ObjSearch.Table.Copy();
                            TablaAuxiliar.Rows.Clear();
                            DataColumn ColumnaError = new DataColumn("RESULTADO DE OPERACION", typeof(string))
                            {
                                Caption = "RESULTADO DE OPERACION", ReadOnly = false, AutoIncrement = false, AllowDBNull = false
                            };
                            TablaAuxiliar.Columns.Add(ColumnaError);
                            int Contador = 0;
                            ProgressBarImport.Value   = 0;
                            ProgressBarImport.Maximum = GridSearch.Rows.Count;
                            PanelLoad.Visible         = true;
                            foreach (DataRow FilaTabla in ObjSearch.Table.Rows)
                            {
                                ObjModifyUsers.NumControl = FilaTabla["NUMERO DE CONTROL"].ToString().Trim();
                                if (FilaTabla["NOMBRES"].ToString().Contains(" "))
                                {
                                    ObjModifyUsers.FirstName  = FilaTabla["NOMBRES"].ToString().Split(' ')[0].Trim();
                                    ObjModifyUsers.SecondName = FilaTabla["NOMBRES"].ToString().Split(' ')[1].Trim();
                                }
                                else
                                {
                                    ObjModifyUsers.FirstName  = FilaTabla["NOMBRES"].ToString().Trim();
                                    ObjModifyUsers.SecondName = string.Empty;
                                }
                                ObjModifyUsers.FirstLastName  = (string.IsNullOrEmpty(FilaTabla["APELLIDO PATERNO"].ToString().Trim())) ? string.Empty : FilaTabla["APELLIDO PATERNO"].ToString();
                                ObjModifyUsers.SecondLastName = (string.IsNullOrEmpty(FilaTabla["APELLIDO MATERNO"].ToString().Trim())) ? string.Empty : FilaTabla["APELLIDO MATERNO"].ToString();
                                ObjModifyUsers.IndexDeparment = Convert.ToByte(FilaTabla["DEPARTAMENTO O CARRERA"].ToString());
                                ObjModifyUsers.Status         = Convert.ToChar(FilaTabla["STATUS"].ToString());
                                ObjModifyUsers.Sex            = Convert.ToChar(FilaTabla["SEXO"].ToString());

                                DataRow FilaAuxiliar = TablaAuxiliar.NewRow();
                                FilaAuxiliar["NUMERO DE CONTROL"]      = FilaTabla["NUMERO DE CONTROL"];
                                FilaAuxiliar["NOMBRES"]                = FilaTabla["NOMBRES"];
                                FilaAuxiliar["APELLIDO PATERNO"]       = FilaTabla["APELLIDO PATERNO"];
                                FilaAuxiliar["APELLIDO MATERNO"]       = FilaTabla["APELLIDO MATERNO"];
                                FilaAuxiliar["DEPARTAMENTO O CARRERA"] = FilaTabla["DEPARTAMENTO O CARRERA"];
                                FilaAuxiliar["SEXO"]   = FilaTabla["SEXO"];
                                FilaAuxiliar["STATUS"] = FilaTabla["STATUS"];

                                switch (ObjValidations.AddUser(TypeModules.Users, ObjModifyUsers))
                                {
                                case Result.Correct:
                                {
                                    FilaAuxiliar["RESULTADO DE OPERACION"] = "Registro importado correctamente.";
                                    Contador++;
                                    break;
                                }

                                case Result.Duplicate:
                                {
                                    FilaAuxiliar["RESULTADO DE OPERACION"] = "Ya existe este registro en la base de datos.";
                                    break;
                                }

                                case Result.Invalid:
                                {
                                    FilaAuxiliar["RESULTADO DE OPERACION"] = "El número de control no tiene el formato correcto.";
                                    break;
                                }

                                case Result.NullNames:
                                {
                                    FilaAuxiliar["RESULTADO DE OPERACION"] = "No existen nombres para este usuario.";
                                    break;
                                }

                                case Result.NullLastNames:
                                {
                                    FilaAuxiliar["RESULTADO DE OPERACION"] = "No existen apellidos para este usuario.";
                                    break;
                                }

                                default:
                                {
                                    FilaAuxiliar["RESULTADO DE OPERACION"] = "El origen del error es desconocido...";
                                    break;
                                }
                                }
                                TablaAuxiliar.Rows.Add(FilaAuxiliar);
                                ProgressBarImport.PerformStep();
                            }
                            LabelCantidadFilas.Text = +Contador + " de " + GridSearch.Rows.Count;
                            LabelFinish.Visible     = true;
                            GridSearch.DataSource   = null;
                            if (GridSearch.Columns.Count > 0)
                            {
                                GridSearch.Columns.Clear();
                            }
                            if (GridSearch.Rows.Count > 0)
                            {
                                GridSearch.Rows.Clear();
                            }
                            GridSearch.DataSource = TablaAuxiliar;
                        }
                    }
                }
                break;
            }

            case 2:     //ButtonRedo
            {
                RedoInterface();
                break;
            }

            default:
                throw new Exception("Excepción en Método: Imports-CCM");
            }
            Index = 0;
        } //Clave de Método: Imports-CCM
Beispiel #4
0
        } //Clave de Método: Users-SIVM

        private void ControlClickMethod(object sender, EventArgs e)
        {
            for (; Index < ArrayControl.Length; Index++)
            {
                if (ArrayControl[Index] == sender)
                {
                    break;
                }
            }
            switch (Index)
            {
            case 0:     //ButtonNewUser
            {
                PopUpUsers ObjPopUpUsers = new PopUpUsers();
                ObjPopUpUsers.Show();
                break;
            }

            case 1:     //PictureBoxInfo
            {
                break;
            }

            case 2:     //ButtonCleanSearch
            {
                GridSearch.DataSource     = ObjValidations.GridSearchMethod(TypeModules.Users, TypeSearch.Users);
                LabelTotalResults.Text    = GridSearch.Rows.Count.ToString();
                TextBoxSearch.TextTextBox = string.Empty;
                GridSearch.Columns["EDITAR"].DisplayIndex = GridSearch.Columns.Count - 1;
                break;
            }

            case 3:     //ButtonSearch
            {
                bool Flag = false;
                try
                {
                    switch (ComboTypeSearch.SelectedIndex)
                    {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    {
                        Flag = !string.IsNullOrEmpty(TextBoxSearch.TextTextBox) ? true : false;
                        break;
                    }

                    case 5:
                    case 7:
                    {
                        Flag = RadioButtonOption1.Checked || RadioButtonOption2.Checked ? true : false;
                        break;
                    }

                    case 6:
                    {
                        Flag = ComboTypeDepartment.SelectedIndex > -1 ? true : false;
                        break;
                    }
                    }
                    if (Flag)
                    {
                        GridSearch.DataSource = ObjValidations.SearchUser(TypeModules.Users,
                                                                          (byte)ComboTypeSearch.SelectedIndex,
                                                                          TextBoxSearch.TextTextBox.Trim().ToUpper(),
                                                                          RadioButtonOption1.Checked ? 'M' : 'F',
                                                                          (byte)ComboTypeDepartment.SelectedIndex,
                                                                          RadioButtonOption1.Checked ? 'A' : 'I');
                        GridSearch.Columns["EDITAR"].DisplayIndex = GridSearch.Columns.Count - 1;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                catch (Exception)
                {
                    using (Alerts ObjAlerts = new Alerts("Búsqueda Fallida", "", "Parece que ser que la búsqueda no se pudo completar.\nPor favor, revise los siguientes puntos:\n1. Es necesario que eliga un filtro de búsqueda."
                                                         + "\n2. Ingrese un texto a buscar o seleccione una opción de búsqueda..\n3. Haga clic en el botón de búsqueda (lupa).", 1, "", "", "OK", TypeIcon.Warning))
                    {
                        if (ObjAlerts.ShowDialog() == DialogResult.OK)
                        {
                            ObjAlerts.Close();
                            ObjAlerts.Dispose();
                        }
                    }
                }
                break;
            }

            default:
                throw new Exception("Excepción en Método: Users-CCM", new IndexOutOfRangeException());
            }
            Index = 0;
        } //Clave de Método: Users-CCM