Пример #1
0
        public void LoadUser()
        {
            try
            {
                employeeBLL = new EmployeeBLL();
                employeeML  = employeeBLL.GetEmploymentByIdUser(BussinesLayer.GlobalBLL.userML.Id);

                if (employeeML != null)
                {
                    KeyTextBox.Text      = employeeML.Id.ToString();
                    NameTextBox.Text     = employeeML.Name;
                    LastNameTextBox.Text = employeeML.LastName;
                }

                if (GlobalBLL.userML != null)
                {
                    UsersBLL usersBLL = new UsersBLL();
                    UsersML  usersML  = usersBLL.GetEntityById(GlobalBLL.userML.Id);

                    UserNameTextBox.Text = usersML.UserName;
                    PasswordTextBox.Text = usersML.Password;

                    if (!string.IsNullOrEmpty(GlobalBLL.userML.Image))
                    {
                        PathFileProfileTextBox.Text = string.Format("{0}\\{1}", System.IO.Path.GetFullPath(GlobalBLL.DirectoryFiles), GlobalBLL.userML.Image);

                        if (System.IO.File.Exists(PathFileProfileTextBox.Text))
                        {
                            ProfilePictureBox.BackgroundImage = new Bitmap(PathFileProfileTextBox.Text);
                        }
                        else
                        {
                            throw new Exception("No se encontró la imagen");
                        }
                    }
                }
                //else
                //{
                //    Alerts.cFAT100010 alr = new Alerts.cFAT100010("ERROR", "No se encontró la información del usuarios", MessageBoxIcon.Error);
                //    alr.ShowDialog();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("LoadUser: {0}", ex.Message));
            }
        }
Пример #2
0
        public void LoadGetEmployee(int id)
        {
            try
            {
                EmployeeML EmployeeML = new EmployeeML();
                EmployeeML EmployeeEntiy;
                UsersML    UserEntity;

                if (EmployeeBLL.GetIdEntity(id).Id > 0)
                {
                    EmployeeEntiy = EmployeeBLL.GetIdEntity(id);
                    if (radioButtonHombre.Text == EmployeeEntiy.Gender.ToString())
                    {
                        radioButtonHombre.Checked = true;
                    }
                    else
                    {
                        radioButtonMujer.Checked = true;
                    }

                    textBoxRfc.Text                    = EmployeeEntiy.RFC.ToString();
                    textBoxCurp.Text                   = EmployeeEntiy.Curp.ToString();
                    textBoxNombre.Text                 = EmployeeEntiy.Name.ToString();
                    textBoxApellidos.Text              = EmployeeEntiy.LastName.ToString();
                    dateTimeFechaNacimiento.Text       = Convert.ToDateTime(EmployeeEntiy.Birthdate).ToString();
                    textBoxNacionalidad.Text           = EmployeeEntiy.Nationality.ToString();
                    textBoxCalle.Text                  = EmployeeEntiy.Address.ToString();
                    textBoxPais.Text                   = EmployeeEntiy.Country.ToString();
                    textBoxMunicipio.Text              = EmployeeEntiy.Municipality.ToString();
                    textBoxEmail.Text                  = EmployeeEntiy.Email.ToString();
                    textBoxColonia.Text                = EmployeeEntiy.Colony.ToString();
                    textBoxTelefono.Text               = EmployeeEntiy.Telephone.ToString();
                    textBoxCodigoPostal.Text           = EmployeeEntiy.PostalCode.ToString();
                    textBoxEstado.Text                 = EmployeeEntiy.StateCountry.ToString();
                    textBoxNumSeguro.Text              = EmployeeEntiy.NumberSure.ToString();
                    textBoxSueldo.Text                 = EmployeeEntiy.Salary.ToString();
                    textBoxNumHours.Text               = EmployeeEntiy.HoursDay.ToString("HH:mm:ss");
                    comboBoxTipoSeguro.SelectedValue   = EmployeeEntiy.SureType.ToString();
                    comboBoxDepartamento.SelectedValue = EmployeeEntiy.IdDepartament.ToString();
                    comboBoxEscolaridad.SelectedValue  = EmployeeEntiy.Scholarship.ToString();
                    comboBoxPuesto.SelectedValue       = EmployeeEntiy.IdJob.ToString();
                    comboBoxEstadoCivil.SelectedValue  = EmployeeEntiy.CivilStatus.ToString();

                    if (!String.IsNullOrEmpty(UsersBLL.GetEntityById(Convert.ToInt32(EmployeeEntiy.IdUser.ToString())).UserName))
                    {
                        UserEntity = UsersBLL.GetEntityById(Convert.ToInt32(EmployeeEntiy.IdUser.ToString()));

                        textBoxUsuario.Text       = UserEntity.UserName.ToString();
                        textBoxPassword.Text      = UserEntity.Password.ToString();
                        comboBoxRol.SelectedValue = UserEntity.Rol.ToString();
                        PathFileNameTextBox.Text  = UserEntity.Image.ToString();
                        IdUser = Convert.ToInt32(UserEntity.Id.ToString());
                        if (!string.IsNullOrEmpty(UserEntity.Image.ToString()))
                        {
                            String FilePath = string.Format("{0}\\{1}", System.IO.Path.GetFullPath(DirectoryFiles), UserEntity.Image.ToString());
                            PathFileImageOld = FilePath;
                            if (System.IO.File.Exists(FilePath))
                            {
                                pictureBoxImage.BackgroundImage = new Bitmap(FilePath);
                            }
                            else
                            {
                                throw new Exception("No se encontró la imagen");
                            }
                        }
                    }
                    if (DaysOfWorkEmployeeBLL.GetAllEntitys(id).Rows.Count > 0)
                    {
                        int loop;
                        foreach (DataRow DaysWorkRow in DaysOfWorkEmployeeBLL.GetAllEntitys(id).Rows)
                        {
                            loop = 0;
                            foreach (object item in checkedListBoxDias.Items)
                            {
                                if (DaysWorkRow[DaysOfWorkEmployeeML.DataBase.IdDays].ToString() == item.GetType().GetProperty("Value").GetValue(item, null).ToString())
                                {
                                    checkedListBoxDias.SetItemChecked(loop, true);
                                    break;
                                }

                                loop++;
                            }
                        }
                    }


                    if (TurnsOfEmployeeBLL.GetAllEntitys(id).Rows.Count > 0)
                    {
                        int loopTurn;
                        foreach (DataRow TurnsOfEmployees in TurnsOfEmployeeBLL.GetAllEntitys(id).Rows)
                        {
                            loopTurn = 0;
                            foreach (object item in checkedListBoxTurns.Items)
                            {
                                if (TurnsOfEmployees[TurnsOfEmployeeML.DataBase.IdTurn].ToString() == item.GetType().GetProperty("Value").GetValue(item, null).ToString())
                                {
                                    checkedListBoxTurns.SetItemChecked(loopTurn, true);
                                    break;
                                }

                                loopTurn++;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("buttonGuardar_Click: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }