/// <summary> /// 사용자가 속한 그룹의 화면들 /// </summary> /// <param name="list"></param> /// <returns></returns> public List <ScreenItem_AuthorityVO> GetUserInfoScreenItem(List <UserGroup_MappingVO> group) { List <ScreenItem_AuthorityVO> list = new List <ScreenItem_AuthorityVO>(); using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = new SqlConnection(Connstr); for (int i = 0; i < group.Count; i++) { cmd.CommandText = "GetUserInfoScreenItem"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserGroup_Code", group[i].UserGroup_Code); cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { ScreenItem_AuthorityVO item = new ScreenItem_AuthorityVO { UserGroup_Code = reader["UserGroup_Code"].ToString(), Screen_Code = reader["Screen_Code"].ToString(), Pre_Type = reader["Pre_Type"].ToString(), Use_YN = reader["Use_YN"].ToString(), }; list.Add(item); } cmd.Parameters.Clear(); cmd.Connection.Close(); } return(list); } }
private void TabControl2_MouseClick(object sender, MouseEventArgs e) { for (int i = 0; i < this.tabControl2.TabPages.Count; i++) { var tabRect = this.tabControl2.GetTabRect(i); tabRect.Inflate(-2, -2); var imageRect = new Rectangle(tabRect.Right - CloseImage.Width, tabRect.Top + (tabRect.Height - CloseImage.Height) / 2, CloseImage.Width, CloseImage.Height); if (imageRect.Contains(e.Location)) //x버튼 클릭시 폼종료 { foreach (Form childForm in Application.OpenForms) { if (childForm.Tag.ToString().Equals(tabControl2.SelectedTab.Tag.ToString())) { childForm.Close(); this.tabControl2.TabPages.RemoveAt(i); break; } } } else //x버튼을 제제외한 텝페이지클릭시 폼 앞으로 && 튤박스에 해당 권한에 맞게 튤박스아이템 사용유무 { foreach (Form childForm in Application.OpenForms) { if (childForm.Tag.ToString().Equals(tabControl2.SelectedTab.Tag.ToString())) { ScreenItem_AuthorityVO screentype = new ScreenItem_AuthorityVO(); screentype = userinfoScreenItem.Find(item => item.Screen_Code == tabControl2.SelectedTab.Tag.ToString()); if (screentype != null) { if (screentype.Pre_Type[0] == 'Y') { tsbInsert.Enabled = true; } else { tsbInsert.Enabled = false; } if (screentype.Pre_Type[2] == 'Y') { tsbtnUpdate.Enabled = true; } else { tsbtnUpdate.Enabled = false; } if (screentype.Pre_Type[3] == 'Y') { tsbtnDelete.Enabled = true; } else { tsbtnDelete.Enabled = false; } } // tabControl2.SelectedTab. = Color.Red; //텝페이지 색 childForm.Activate(); lblSubtitle.Text = screenitemlist.Find(item => item.Screen_Code == tabControl2.SelectedTab.Tag.ToString()).Screen_Path.ToString(); break; } } } } }
/// <summary> /// 새로운 폼 생성 /// </summary> /// <param name="formName">폼이름</param> public void newForm(string formName, string formText) { try { if (userinfoScreenItem.Count(item => item.Screen_Code.Trim().Equals(formName.Trim())) > 0) { string nameSpace = "Axxen"; //네임스페이스 명 Assembly cuasm = Assembly.GetExecutingAssembly(); //string Format 의 따옴표와 마침표 주의!! string childFormName = string.Format("{0}.{1}", nameSpace, formName); frm = (Form)cuasm.CreateInstance(childFormName); foreach (Form childForm in Application.OpenForms) { if (childForm.Tag.ToString().Trim().Equals(formName.Trim())) { ScreenItem_AuthorityVO screentype = new ScreenItem_AuthorityVO(); screentype = userinfoScreenItem.Find(item => item.Screen_Code == formName.Trim()); if (screentype != null) { if (screentype.Pre_Type[0] == 'Y') { tsbInsert.Enabled = true; } else { tsbInsert.Enabled = false; } if (screentype.Pre_Type[2] == 'Y') { tsbtnUpdate.Enabled = true; } else { tsbtnUpdate.Enabled = false; } if (screentype.Pre_Type[3] == 'Y') { tsbtnDelete.Enabled = true; } else { tsbtnDelete.Enabled = false; } } for (int i = 0; i < tabControl2.TabPages.Count; i++) //활성화된 메뉴의 탭페이지눌릴수 있도록 { if (tabControl2.TabPages[i].Tag.Equals(formName)) { tabControl2.SelectedIndex = i; break; } } childForm.Activate(); return; } } frm.MdiParent = this; frm.WindowState = FormWindowState.Maximized; frm.SizeChanged += Frm_SizeChanged; //frm.Text = ""; frm.Tag = formName; TabPage newTab = new TabPage(); newTab.Tag = formName; newTab.Text = formText; tabControl2.TabPages.Add(newTab); tabControl2.SelectedTab = newTab; //새로연 메뉴의 화면 텝페이지 눌릴 수 있도록 frm.Show(); /////////////////// 메뉴클릭시 foreach (Form childForm in Application.OpenForms) { ScreenItem_AuthorityVO screentype = new ScreenItem_AuthorityVO(); screentype = userinfoScreenItem.Find(item => item.Screen_Code == formName.Trim()); if (screentype != null) { if (screentype.Pre_Type[0] == 'Y') { tsbInsert.Enabled = true; } else { tsbInsert.Enabled = false; } if (screentype.Pre_Type[2] == 'Y') { tsbtnUpdate.Enabled = true; } else { tsbtnUpdate.Enabled = false; } if (screentype.Pre_Type[3] == 'Y') { tsbtnDelete.Enabled = true; } else { tsbtnDelete.Enabled = false; } break; } } ////////////////////////////////////////// // tabControl2.TabPages.Tag=formName; // MessageBox.Show(tabControl2.SelectedTab.Tag.ToString()); // SegCnt++; Login_Screen_HistoryVO loginscreen = new Login_Screen_HistoryVO() { Session_ID = UserInfo.Session_ID, // Seg =SegCnt, Open_Day = Convert.ToDateTime(DateTime.Now.ToShortDateString()), Open_Date = DateTime.Now, User_ID = UserInfo.User_ID, Screen_Code = formName }; userservice.InsertLogin_Screen_History(loginscreen); lblSubtitle.Text = screenitemlist.Find(item => item.Screen_Code == formName.ToString()).Screen_Path.ToString(); } else { MessageBox.Show("사용권한이 없는 메뉴입니다." + formName); } } catch (Exception err) { MessageBox.Show("사용할 수 없는 메뉴" + err.Message + formName); throw; } }