Exemple #1
0
        /// <summary>
        /// 窗体载入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormUser_Load(object sender, EventArgs e)
        {
            if (GlobalObject.GeneralFunction.IsNullOrEmpty(m_dept))
            {
                m_findPersonnel = m_personnelServer.GetAllInfo();
            }
            else
            {
                m_findPersonnel = m_personnelServer.GetPersonnelViewInfo(Service_Peripheral_HR.PersonnelDefiniens.ParameterType.部门, m_dept);
            }

            if (m_findPersonnel == null || m_findPersonnel.Count() == 0)
            {
                return;
            }

            RefreshDataGridView(m_findPersonnel);

            // 显示列
            string[] showColumns = new string[] { "员工编号", "员工姓名", "部门", "职位" };

            for (int i = 0; i < dataGridView1.Columns.Count; i++)
            {
                dataGridView1.Columns[i].Width = 100;
                cmbFindItem.Items.Add(dataGridView1.Columns[i].Name);

                if (!showColumns.Contains(dataGridView1.Columns[i].Name))
                {
                    dataGridView1.Columns[i].Visible = false;
                }
            }

            cmbFindItem.SelectedIndex = 0;
        }
Exemple #2
0
        /// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormSelectUser_Load(object sender, EventArgs e)
        {
            try
            {
                if (m_type == "员工")
                {
                    if (AllUser == null)
                    {
                        if (DeptCode == null)
                        {
                            AllUser = m_personnelInfo.GetAllInfo().ToList();
                        }
                        else
                        {
                            string[] dept = DeptCode.Split(';');

                            if (dept.Length > 0)
                            {
                                string sql = "";

                                for (int i = 0; i < dept.Length; i++)
                                {
                                    if (i == 0)
                                    {
                                        sql += " and 部门编号 in (select DeptCode from fun_get_BelongDept('" + dept[i] + "'))";
                                    }
                                    else if (dept[i] != "")
                                    {
                                        sql += " or 部门编号 in (select DeptCode from fun_get_BelongDept('" + dept[i] + "'))";
                                    }
                                }

                                AllUser = m_personnelInfo.GetPersonByDept(sql).ToList();
                            }
                            else
                            {
                                AllUser = m_personnelInfo.GetAllInfo(DeptCode).ToList();
                            }
                        }
                    }

                    DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();

                    column.Visible    = true;
                    column.Name       = "选中";
                    column.HeaderText = "选中";
                    column.ReadOnly   = false;

                    dataGridView.Columns.Add(column);

                    dataGridView.Columns.Add("员工姓名", "员工姓名");
                    dataGridView.Columns.Add("员工编号", "员工编号");
                    dataGridView.Columns.Add("部门", "部门");

                    foreach (DataGridViewColumn item in dataGridView.Columns)
                    {
                        if (item.Name != "选中")
                        {
                            item.ReadOnly = true;
                            item.Width    = item.HeaderText.Length * (int)this.Font.Size + 100;
                        }
                        else
                        {
                            item.Width    = 68;
                            item.ReadOnly = false;
                            item.Frozen   = false;
                        }
                    }

                    bool selectedFlag = false;
                    int  count        = 0;

                    foreach (var item in AllUser)
                    {
                        selectedFlag = false;

                        if (SelectedUser != null && count < SelectedUser.Count)
                        {
                            if (SelectedUser.FindIndex(c => c.员工编号 == item.员工编号) >= 0)
                            {
                                selectedFlag = true;
                                count++;
                            }
                        }

                        dataGridView.Rows.Add(new object[] { selectedFlag, item.员工姓名, item.员工编号, item.部门 });
                    }
                }

                if (m_type == "部门")
                {
                    if (AllDept == null)
                    {
                        if (!m_deptServer.GetAllDeptInfo(out m_findDepartment, out error))
                        {
                            MessageDialog.ShowErrorMessage(error);
                            return;
                        }

                        AllDept = m_findDepartment.ToList();
                    }

                    DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();

                    column.Visible    = true;
                    column.Name       = "选中";
                    column.HeaderText = "选中";
                    column.ReadOnly   = false;

                    dataGridView.Columns.Add(column);

                    dataGridView.Columns.Add("部门代码", "部门代码");
                    dataGridView.Columns.Add("部门名称", "部门名称");
                    dataGridView.Columns.Add("部门类型", "部门类型");

                    foreach (DataGridViewColumn item in dataGridView.Columns)
                    {
                        if (item.Name != "选中")
                        {
                            item.ReadOnly = true;
                            item.Width    = item.HeaderText.Length * (int)this.Font.Size + 100;
                        }
                        else
                        {
                            item.Width    = 68;
                            item.ReadOnly = false;
                            item.Frozen   = false;
                        }
                    }

                    bool selectedFlag = false;
                    int  count        = 0;

                    foreach (var item in AllDept)
                    {
                        selectedFlag = false;

                        if (SelectedDept != null && count < SelectedDept.Count)
                        {
                            if (SelectedDept.FindIndex(c => c.部门代码 == item.部门代码) >= 0)
                            {
                                selectedFlag = true;
                                count++;
                            }
                        }

                        dataGridView.Rows.Add(new object[] { selectedFlag, item.部门代码, item.部门名称, item.部门类型 });
                    }
                }

                userControlDataLocalizer1.Init(dataGridView, this.Name,
                                               UniversalFunction.SelectHideFields(this.Name, dataGridView.Name, BasicInfo.LoginID));

                lblSumCount.Text = dataGridView.Rows.Count.ToString();
            }
            catch (Exception err)
            {
                MessageDialog.ShowErrorMessage(err.Message);
            }
        }