Exemplo n.º 1
0
        private void LoadData()
        {
            DBGrid.Columns.Clear();
            ArrayList arrHeader = new ArrayList();
            ArrayList arrTitle  = new ArrayList();

            arrHeader.Add(clsTranslate.TranslateString("GroupId"));
            arrHeader.Add(clsTranslate.TranslateString("TaskCode"));
            arrHeader.Add(clsTranslate.TranslateString("TaskName"));
            arrTitle.Add(clsTranslate.TranslateString("GroupId"));
            arrTitle.Add(clsTranslate.TranslateString("TaskCode"));
            arrTitle.Add(clsTranslate.TranslateString("TaskName"));
            dalUserList blluser = new dalUserList();
            BindingCollection <modUserList> listuser = blluser.GetIList(true, out Util.emsg);

            if (listuser != null && listuser.Count > 0)
            {
                foreach (modUserList mod in listuser)
                {
                    arrHeader.Add(mod.UserId);
                    arrTitle.Add(mod.UserName);
                }
            }
            for (int i = 0; i < arrHeader.Count; i++)
            {
                //if (i <= 1)
                //{
                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                col.HeaderText       = arrTitle[i].ToString();
                col.DataPropertyName = arrHeader[i].ToString();
                col.Name             = arrHeader[i].ToString();
                if (i == 1)
                {
                    col.Visible = false;
                }
                else if (i == 0 || i == 2)
                {
                    col.Width = 120;
                }
                else
                {
                    col.Width = 30;
                }
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                DBGrid.Columns.Add(col);
                col.Dispose();
                //}
                //else
                //{
                //    DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
                //    col.HeaderText = arrTitle[i].ToString();
                //    col.DataPropertyName = arrHeader[i].ToString();
                //    col.Width = 70;
                //    DBGrid.Columns.Add(col);
                //    col.Dispose();
                //}
            }

            DataGridViewRow row;
            dalTaskList     bll = new dalTaskList();
            BindingCollection <modTaskList> list = bll.GetIList(string.Empty, false, false, out Util.emsg);

            if (list != null && list.Count > 0)
            {
                foreach (modTaskList mod in list)
                {
                    row = new DataGridViewRow();
                    row.CreateCells(DBGrid);
                    row.Cells[0].Value = clsTranslate.TranslateString(mod.GroupId);
                    row.Cells[1].Value = mod.TaskCode;
                    row.Cells[2].Value = clsTranslate.TranslateString(mod.TaskName);
                    DBGrid.Rows.Add(row);
                    row.Dispose();
                }
            }
            for (int iCol = 3; iCol < DBGrid.ColumnCount; iCol++)
            {
                dalTaskGrant blltg = new dalTaskGrant();
                BindingCollection <modTaskGrant> listtg = blltg.GetUserGrantData(false, false, DBGrid.Columns[iCol].Name, string.Empty, string.Empty, out Util.emsg);
                if (listtg != null && listtg.Count > 0)
                {
                    foreach (modTaskGrant mod in listtg)
                    {
                        for (int iRow = 0; iRow < DBGrid.RowCount; iRow++)
                        {
                            if (mod.TaskCode.CompareTo(DBGrid.Rows[iRow].Cells[1].Value.ToString()) == 0)
                            {
                                DBGrid.Rows[iRow].Cells[iCol].Value = "√";
                                break;
                            }
                        }
                    }
                }
            }
            DBGrid.Columns[2].Frozen = true;
            DBGrid.AlternatingRowsDefaultCellStyle.BackColor = Color.Empty;
            DBGrid.Columns[0].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.Columns[1].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.Columns[2].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.MergeColumnNames.Add(arrHeader[0].ToString());
            DBGrid.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
        }
Exemplo n.º 2
0
        private void SEC_TASK_GRANT_Load(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                dalRoleList bll = new dalRoleList();
                //DataSet ds = bll.GetRoleList(true, out Util.emsg);
                tvUser2.ImageList = Util.GetImageList();
                BindingCollection <modRoleList> rolelist = new BindingCollection <modRoleList>();
                rolelist = bll.GetIList(true, out Util.emsg);
                if (rolelist != null)
                {
                    comboBox1.ValueMember   = "RoleId";
                    comboBox1.DisplayMember = "RoleDesc";
                    comboBox1.DataSource    = rolelist;
                    if (comboBox1.Items.Count > 0)
                    {
                        comboBox1.SelectedIndex = 0;
                        //LoadListBox();
                    }

                    foreach (modRoleList role in rolelist)
                    {
                        dalUserList _ubll = new dalUserList();
                        BindingCollection <modUserList> userlist = _ubll.GetIList(role.RoleId, out Util.emsg);
                        if (userlist != null)
                        {
                            TreeNode tn = tvUser2.Nodes.Add(role.RoleId, role.RoleDesc, 0, 1);
                            foreach (modUserList user in userlist)
                            {
                                TreeNode node = tn.Nodes.Add(user.UserId, user.UserName, 2, 3);
                                node.ToolTipText = node.Name;
                            }
                        }
                    }
                    tvUser2.ShowNodeToolTips = true;
                    dalTaskList task = new dalTaskList();
                    BindingCollection <modTaskList> tasklist = task.GetIList(string.Empty, true, false, out Util.emsg);
                    DBGrid2.DataSource = tasklist;
                    for (int j = 0; j < DBGrid2.RowCount; j++)
                    {
                        DBGrid2.Rows[j].Cells["Taskname"].Value = clsTranslate.TranslateString(DBGrid2.Rows[j].Cells["Taskname"].Value.ToString());
                    }

                    DataGridViewCheckBoxColumn checkboxColumn = new DataGridViewCheckBoxColumn();
                    checkboxColumn.HeaderText       = clsTranslate.TranslateString("Select");
                    checkboxColumn.DataPropertyName = "Select";
                    DBGrid2.Columns.Insert(0, checkboxColumn);

                    DBGrid2.Columns[9].Visible = false;
                    DBGrid2.Columns[8].Visible = false;
                    DBGrid2.Columns[7].Visible = false;
                    DBGrid2.Columns[6].Visible = false;
                    DBGrid2.Columns[5].Visible = false;
                    DBGrid2.Columns[4].Visible = false;
                    DBGrid2.Columns[3].Visible = false;

                    //DBGrid2.Columns[8].ReadOnly = true;
                    //DBGrid2.Columns[7].ReadOnly = true;
                    //DBGrid2.Columns[6].ReadOnly = true;
                    //DBGrid2.Columns[5].ReadOnly = true;
                    //DBGrid2.Columns[4].ReadOnly = true;
                    //DBGrid2.Columns[3].ReadOnly = true;
                    DBGrid2.Columns[2].ReadOnly = true;
                    DBGrid2.Columns[1].ReadOnly = true;
                    //Util.AutoSetColWidth(1, DBGrid2);
                    DBGrid2.AllowUserToAddRows = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }