Example #1
0
        void addDepartmentDetail(DepartmentModel data)
        {
            //pDetail.Controls.Clear();

            if (data.DepartmentID > 0)
            {

                 UCDepartmentListDetail ucDepartmentDetail=new UCDepartmentListDetail();

                if (pDetail.Controls.Count > 0)
                {
                    ucDepartmentDetail = (UCDepartmentListDetail) pDetail.Controls[0];
                }
                else
                {
                    ucDepartmentDetail.Dock = DockStyle.Fill;
                    pDetail.Controls.Add(ucDepartmentDetail);
                }

                ucDepartmentDetail.lbTilte.Text = data.DepartmentName;

                ucDepartmentDetail.txtRoleName.Text = data.DepartmentName;

                ucDepartmentDetail.flpPermission.Controls.Clear();
                ucDepartmentDetail.addUcPermission(data.DepartmentID);
                ucDepartmentDetail.addButton(data.DepartmentID);

                ucDepartmentDetail.btnSave.Tag = data;
                ucDepartmentDetail.btnSave.Click += btnSaveDepartment_Click;

                ucDepartmentDetail.btnDelete.Tag = data;
                ucDepartmentDetail.btnDelete.Click += btnDeleteDepartment_Click;
                ucDepartmentDetail.btnDelete.Show();

            }
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            pDetail.Controls.Clear();
            Button addNew = (Button)sender;
            int tag = Convert.ToInt32(addNew.Tag);

            switch (tag)
            {
                case 1:
                    UCDepartmentListDetail ucDepartment = new UCDepartmentListDetail();
                    ucDepartment.Dock = DockStyle.Fill;
                    ucDepartment.btnSave.Click += btnSaveDepartment_Click;
                    ucDepartment.btnDelete.Hide();
                    pDetail.Controls.Add(ucDepartment);
                    break;
                case 2:
                    UCUserListDetail ucUser = new UCUserListDetail();
                    ucUser.Dock = DockStyle.Fill;
                    ucUser.btnSave.Click += btnSaveUser_Click;
                    ucUser.btnDelete.Hide();

                    ucUser.cbRole.DisplayMember = "Value";
                    ucUser.cbRole.ValueMember = "Key";
                    var department = UserService.GetListDepartment().ToList();
                    foreach (var item in department)
                    {
                        var temp = new KeyValueModel();
                        temp.Key = item.DepartmentID;
                        temp.Value = item.DepartmentName;
                        ucUser.cbRole.Items.Add(temp);

                    }
                    //ucUser.cbRole.SelectedIndex = 0;
                    pDetail.Controls.Add(ucUser);
                    break;

            }
        }