private void CreateModuleList() { Atiran.UI.WindowsForms.UIElements.Checkbox chk1 = new Atiran.UI.WindowsForms.UIElements.Checkbox(); chk1.Tag = "selectAll"; chk1.Name = "selectAll"; chk1.Text = " انتخاب همه موارد ... "; chk1.AutoSize = true; chk1.CheckedChanged += Chk_CheckedChanged; chk1.ForeColor = System.Drawing.Color.Orange; //chk1.BackColor = System.Drawing.Color.DarkOrange; flowLayoutPanel1.Controls.Add(chk1); List <Atiran.Connections.AtiranAccModel.SubSystem> module = Connections.Operaions.SubSystemOp.SubSystemOperaion.ResultAllSubSystem; foreach (var item in module) { Atiran.UI.WindowsForms.UIElements.Checkbox chk = new Atiran.UI.WindowsForms.UIElements.Checkbox(); chk.Tag = item.SubSystemId; chk.Text = item.Name; chk.AutoSize = true; chk.CheckedChanged += Chk_CheckedChanged; flowLayoutPanel1.Controls.Add(chk); } }
private void cb_User_SelectedValueChanged(object sender, EventArgs e) { ModuleNodes.Clear(); ModuleNodesOrginal.Clear(); Atiran.UI.WindowsForms.UIElements.Checkbox chk2 = flowLayoutPanel1.Controls.Find("selectAll", true).FirstOrDefault() as Atiran.UI.WindowsForms.UIElements.Checkbox; chk2.Checked = false; foreach (System.Windows.Forms.Control c1 in flowLayoutPanel1.Controls) { Atiran.UI.WindowsForms.UIElements.Checkbox chk = (Atiran.UI.WindowsForms.UIElements.Checkbox)c1; if (cb_User.SelectedValue != null) { if (chk.Tag.ToString() != "selectAll") { Atiran.Connections.AtiranAccModel.SubSystemPermission mod = Atiran.Connections.Operaions.SubSystemPermissionOp.SubSystemPermissionOperaion.GetUserModulePermissionStatus(Convert.ToInt32(cb_User.SelectedValue), int.Parse(chk.Tag.ToString())); ModuleNodesOrginal.Add(int.Parse(chk.Tag.ToString())); if (mod != null) { chk.Checked = true; int oo = ModuleNodes.IndexOf(int.Parse(chk.Tag.ToString())); if (oo == -1) { ModuleNodes.Add(int.Parse(chk.Tag.ToString())); } } else { chk.Checked = false; int oo = ModuleNodes.IndexOf(int.Parse(chk.Tag.ToString())); if (oo == -1) { ModuleNodes.Remove(int.Parse(chk.Tag.ToString())); } } } } } }