实例介绍
【实例简介】
数据库为acccess 密码为空 ,如提示《未在本地计算机上注册"Microsoft.Jet.OLEDB.4.0"解决方案》请点击这里查看解决方案
【实例截图】
【核心代码】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | using System; using System.Data; using System.Windows.Forms; using DevComponents.DotNetBar; using System.Xml; namespace gupiao { public partial class MainFrm : Office2007Form { //是否注销 bool isZx = false ; //记录操作员 public string userId = "" ; public string userName = "" ; //记录登陆者所在表明 public string tableName = "" ; //记录登陆窗体信息 public Form loginFrm = null ; //窗体当前风格 public static eDotNetBarStyle frmdotnetstyle = eDotNetBarStyle.Office2007; public int rootnum = 0; public MainFrm() { InitializeComponent(); } //窗体加载事件 private void MainFrm_Load( object sender, EventArgs e) { try { bar1.Visible = false ; Functions.showControl = bar3; Functions.UserId = userId; Functions.UserName = userName; this .btnBeginFrm_Click( null , null ); // 根据权限绑定菜单 getQx(); setFrmStyle(); bar1.Visible = true ; } catch { MessageBox.Show( "窗体加载失败!" , "异常信息提示" , MessageBoxButtons.OK); } finally { } } //双击关闭打开界面 void DockTabControl_DoubleClick( object sender, EventArgs e) { bar3.Items.Remove(bar3.SelectedDockTab); Functions.changeDockTagIndex(); this .bar3.SelectedDockTab = Convert.ToInt32(bar3.Items[bar3.SelectedDockTab].Tag) - 1; } /// <summary> /// 设置窗体样式 /// </summary> private void setFrmStyle() { office2007.Checked = false ; VS2005.Checked = false ; windowsXP.Checked = false ; //设置窗体样式 string FrmStyle = Functions.getFrmStyle(); if (FrmStyle == "Office2007" ) { frmdotnetstyle = eDotNetBarStyle.Office2007; progressBarX1.Style = eDotNetBarStyle.Office2007; Functions.setControlsStyle(DevComponents.DotNetBar.eDotNetBarStyle.Office2007, this ); office2007.Checked = true ; } if (FrmStyle == "OfficeXP" ) { frmdotnetstyle = eDotNetBarStyle.OfficeXP; progressBarX1.Style = eDotNetBarStyle.OfficeXP; Functions.setControlsStyle(DevComponents.DotNetBar.eDotNetBarStyle.OfficeXP, this ); windowsXP.Checked = true ; } if (FrmStyle == "VS2005" ) { frmdotnetstyle = eDotNetBarStyle.VS2005; progressBarX1.Style = eDotNetBarStyle.VS2005; Functions.setControlsStyle(DevComponents.DotNetBar.eDotNetBarStyle.VS2005, this ); VS2005.Checked = true ; } //Message.Information("vs2005:" VS2005.Checked.ToString() "windowsXP:" windowsXP.Checked.ToString()); } /// <summary> /// 绑定树方法 /// </summary> /// <param name="idCount">该操作员权限</param> public void BingTree( string idCount) { panelDockContainer1.Controls.Clear(); //当前用户权限的菜单数据 DataTable dsparent = dbedit.GetDataTable( "select id,cname,parentid,frmtype,namespace,frmname,dllpath,isparameter,parametervalue,showindex from sys_menu where id in(" idCount ") order by showindex desc" ); if (dsparent != null && dsparent.Rows.Count > 0) { //一级菜单数据 DataRow[] drparent = dsparent.Select( "parentid=0" ); if (drparent.Length > 0) { rootnum = drparent.Length - 1; int j = 0; progressBarX1.Maximum = drparent.Length - 1; for ( int i = 0; i < drparent.Length;i ) { TreeView tv = Functions.BindTree(drparent[i], true , dsparent); //将树控件添加到生成的容器中 ExpandablePanel ep = makeExpandablePanel(tv.Name, tv.Name, panelDockContainer1); ep.Controls.Add(tv); //第一个默认为打开 if (i == drparent.Length - 1) { ep.Expanded = true ; } //树节点为全部展开 tv.ExpandAll(); progressBarX1.Value = j; j ; } } } progressBarX1.Visible = false ; } /// <summary> /// 绑定树方法 /// </summary> public void BingTree() { panelDockContainer1.Controls.Clear(); //生成 绑定树控件 DataTable ds = dbedit.GetDataTable( "select * from sys_menu where parentid=0 order by showindex desc" ); if (ds != null ) { Functions.showControl = bar3; int j = 0; rootnum = ds.Rows.Count - 1; progressBarX1.Maximum = rootnum; for ( int i = 0; i < ds.Rows.Count; i ) { TreeView tv = Functions.BindTree(ds.Rows[i][ "id" ].ToString(), true ); //将树控件添加到生成的容器中 ExpandablePanel ep = makeExpandablePanel(tv.Name, tv.Name, panelDockContainer1); ep.Controls.Add(tv); //第一个默认为打开 if (i == ds.Rows.Count - 1) { ep.Expanded = true ; } //树节点为全部展开 tv.ExpandAll(); progressBarX1.Value = j; j ; } } progressBarX1.Visible = false ; } /// <summary> /// 绑定outLook菜单栏 /// </summary> public void BindMenu( string id) { panelDockContainer1.Controls.Clear(); DevComponents.DotNetBar.SideBar sidebar1 = Functions.BindMenu(id, imageSmall, imageLarge); panelDockContainer1.Controls.Add(sidebar1); contextMenuBar1.SetContextMenuEx(sidebar1, CMenu); progressBarX1.Visible = false ; } /// <summary> /// 根据权限绑定树 /// </summary> public void getQx() { if (tableName == "sys_admin" ) { lblCzy.Text = userName; lbldlrq.Text = DateTime.Now.ToString(); //根据操作员获取组织机构信息 this .lblbm.Text = "管理员" ; this .lblzw.Text = "管理员" ; //BingTree(); BindMenu( null ); } else { lblCzy.Text = userName; lbldlrq.Text = DateTime.Now.ToString(); //根据操作员获取组织机构信息 DataTable dt = dbedit.GetDataTable( "select id,username,(select name from sys_bm where sys_bm.id=sys_user.bm) as bm,(select name from sys_zw where sys_zw.id=sys_user.zw) as zw from sys_user where id=" this .userId "" ); this .lblbm.Text = dt.Rows[0][ "bm" ].ToString(); this .lblzw.Text = dt.Rows[0][ "zw" ].ToString(); //根据操作员获取权限功能树编号 DataTable qxds = dbedit.GetDataTable( "select menu_id from sys_restrict where operator_id=" dt.Rows[0][ "id" ].ToString() "" ); if (qxds.Rows.Count > 0) { string strIdcount = "" ; foreach (DataRow dr in qxds.Rows) { strIdcount = dr[ "menu_id" ].ToString() "," ; } //BingTree(strIdcount.Substring(0, strIdcount.Length - 1)); BindMenu(strIdcount.Substring(0, strIdcount.Length - 1)); } } } /// <summary> /// 生成ExpandablePanel /// </summary> public ExpandablePanel makeExpandablePanel( string expandablePanelName, string expandablePanelTitleText, Control parentControl) { try { ExpandablePanel ep = new ExpandablePanel(); ep.CanvasColor = System.Drawing.SystemColors.Control; ep.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; ep.Dock = System.Windows.Forms.DockStyle.Top; ep.Location = new System.Drawing.Point(0, 0); ep.Name = expandablePanelName "ExpandablePanel" ; ep.Size = new System.Drawing.Size(209, parentControl.Height - ep.TitleHeight * rootnum); ep.Style.Alignment = System.Drawing.StringAlignment.Center; ep.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground; ep.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine; ep.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText; ep.Style.GradientAngle = 90; ep.StyleMouseDown.Alignment = System.Drawing.StringAlignment.Center; ep.StyleMouseDown.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemPressedBackground; ep.StyleMouseDown.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemPressedBorder; ep.StyleMouseDown.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemPressedText; ep.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center; ep.StyleMouseOver.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemHotBackground; ep.StyleMouseOver.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemHotBorder; ep.StyleMouseOver.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemHotText; ep.TabIndex = 0; ep.TitleStyle.Alignment = System.Drawing.StringAlignment.Center; ep.TitleStyle.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; ep.TitleStyle.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2; ep.TitleStyle.Border = DevComponents.DotNetBar.eBorderType.RaisedInner; ep.TitleStyle.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; ep.TitleStyle.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; ep.TitleStyle.GradientAngle = 90; ep.TitleText = expandablePanelTitleText; ep.Expanded = false ; //打开关闭时触发事件 ep.ExpandedChanging = new ExpandChangeEventHandler(ep_ExpandedChanging); parentControl.Controls.Add(ep); //this.panelDockContainer1.Controls.Add(ep); return ep; } catch { return null ; } finally { } } /// <summary> /// 当一个抽屉被打开时,关闭其他抽屉控件 /// </summary> public void ep_ExpandedChanging( object sender, ExpandedChangeEventArgs e) { //循环整个左侧树控件 foreach (Control pC in ((ExpandablePanel)sender).Parent.Controls) { //选出类型匹配的控件 if (pC.GetType().ToString() == "DevComponents.DotNetBar.ExpandablePanel" ) { //打开被选中的抽屉,其它的关闭 if (((ExpandablePanel)pC).Name != ((ExpandablePanel)sender).Name) { ((ExpandablePanel)pC).Expanded = false ; } } } } /// <summary> /// 起始页加载 /// </summary> private void btnBeginFrm_Click( object sender, EventArgs e) { //创建图片控件 PictureBox pictureBox1 = CreatePicture(); //创建启始页容器 PanelDockContainer panelDockContainerBegin = CreatePanelDockContainer(pictureBox1); //加载启始页 getDockItem( "dockContainerItemBegin" , "背景图" ).Control = panelDockContainerBegin; } /// <summary> /// 动态加载窗体到Dock /// </summary> /// <param name="itemName">名称</param> /// <param name="itemText">显示的文本</param> public DockContainerItem getDockItem( string itemName, string itemText) { if (bar3.Items.Count > 10) { PublicMethod.HintMessage( "窗体最多打开10个!如想继续打开,请先关闭现有窗体!" ); return null ; } else { bar3.Show(); int index = 0; //循环查看窗体是否已经加载 foreach (DockContainerItem frmdci in bar3.Items) { //重新设置item序号 frmdci.Tag = index; if (frmdci.Name == itemName) { bar3.SelectedDockTab = Convert.ToInt32(frmdci.Tag); return frmdci; } index ; } DockContainerItem dci = new DockContainerItem(itemName, itemText); bar3.Items.Add(dci); //默认打开新增Tab bar3.SelectedDockTab = bar3.Items.Count - 1; dci.Tag = bar3.SelectedDockTab; return dci; } } /// <summary> /// 创建启始页容器 /// </summary> /// <param name="pictureBox1">要显示的图片控件</param> /// <returns>启始页容器</returns> private PanelDockContainer CreatePanelDockContainer(PictureBox pictureBox1) { PanelDockContainer panelDockContainerBegin = new DevComponents.DotNetBar.PanelDockContainer(); panelDockContainerBegin.SuspendLayout(); bar3.Controls.Add(panelDockContainerBegin); panelDockContainerBegin.ColorScheme.ItemDesignTimeBorder = System.Drawing.Color.Black; panelDockContainerBegin.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; panelDockContainerBegin.Controls.Add(pictureBox1); panelDockContainerBegin.Location = new System.Drawing.Point(3, 28); panelDockContainerBegin.Name = "panelDockContainerBegin" ; panelDockContainerBegin.Size = new System.Drawing.Size(451, 333); panelDockContainerBegin.Style.Alignment = System.Drawing.StringAlignment.Center; panelDockContainerBegin.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground; panelDockContainerBegin.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground2; panelDockContainerBegin.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder; panelDockContainerBegin.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText; panelDockContainerBegin.Style.GradientAngle = 90; panelDockContainerBegin.TabIndex = 1; panelDockContainerBegin.ResumeLayout( false ); return panelDockContainerBegin; } /// <summary> /// 创建图片控件 /// </summary> /// <returns>返回图片控件</returns> private static PictureBox CreatePicture() { PictureBox pictureBox1 = new System.Windows.Forms.PictureBox(); pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; pictureBox1.ImageLocation = System.Windows.Forms.Application.StartupPath "\\Resourse\\mainPicture.jpg" ; pictureBox1.Location = new System.Drawing.Point(0, 0); pictureBox1.Name = "pictureBox1" ; pictureBox1.Size = new System.Drawing.Size(451, 333); pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; pictureBox1.TabIndex = 0; pictureBox1.TabStop = false ; pictureBox1.WaitOnLoad = true ; return pictureBox1; } //关闭打开页 private void bar3_DockTabClosing( object sender, DockTabClosingEventArgs e) { e.RemoveDockTab = true ; Functions.changeDockTagIndex(); this .bar3.SelectedDockTab =Convert.ToInt32(e.DockContainerItem.Tag) - 1; } //设置窗体风格 office2007 private void office2007_Click( object sender, EventArgs e) { office2007.Checked = true ; VS2005.Checked = false ; windowsXP.Checked = false ; frmdotnetstyle = eDotNetBarStyle.Office2007; Functions.setControlsStyle(eDotNetBarStyle.Office2007, this .Controls); //记录窗体风格 Functions.setFrmStyle(eDotNetBarStyle.Office2007.ToString()); } //设置窗体风格 vs2005 private void VS2005_Click( object sender, EventArgs e) { office2007.Checked = false ; VS2005.Checked = true ; windowsXP.Checked = false ; frmdotnetstyle = eDotNetBarStyle.VS2005; Functions.setControlsStyle(eDotNetBarStyle.VS2005, this .Controls); //记录窗体风格 Functions.setFrmStyle(eDotNetBarStyle.VS2005.ToString()); } //设置窗体风格 windowXP private void windowsXP_Click( object sender, EventArgs e) { office2007.Checked = false ; VS2005.Checked = false ; windowsXP.Checked = true ; frmdotnetstyle = eDotNetBarStyle.OfficeXP; Functions.setControlsStyle(eDotNetBarStyle.OfficeXP, this .Controls); //记录窗体风格 Functions.setFrmStyle(eDotNetBarStyle.OfficeXP.ToString()); } //设置新加载窗体风格 private void bar3_ControlAdded( object sender, ControlEventArgs e) { Functions.setControlsStyle(frmdotnetstyle, this .Controls); } private void btnLock_Click( object sender, EventArgs e) { mnuLock_Click( null , null ); } //注销 private void btnLogout_Click( object sender, EventArgs e) { mnuLogout_Click( null , null ); } //退出 private void buttonItem8_Click( object sender, EventArgs e) { Application.Exit(); } private void MainFrm_FormClosing( object sender, FormClosingEventArgs e) { if (isZx) { ((Login)loginFrm).BingCmbUserName(); ((Login)loginFrm).cmbUserName.Text = this .userName; isZx = false ; } else { Application.Exit(); } } private void btnPwd_Click( object sender, EventArgs e) { ChangePwd cpwd = new ChangePwd(); cpwd.userName = userName; cpwd.tableName = tableName; cpwd.ShowDialog(); } private void btnPwdUpdate_Click( object sender, EventArgs e) { mnuPwd_Click( null , null ); } private void btnAbout_Click( object sender, EventArgs e) { mnuAbout_Click( null , null ); } private void mnuLogout_Click( object sender, EventArgs e) { this .Hide(); ((Login)loginFrm).setFrmStyle(); loginFrm.Show(); isZx = true ; } private void mnuLock_Click( object sender, EventArgs e) { LockFrm lf = new LockFrm(userName); lf.ShowDialog(); } private void mnuPwd_Click( object sender, EventArgs e) { ChangePwd cpwd = new ChangePwd(); cpwd.userName = userName; cpwd.tableName = tableName; cpwd.ShowDialog(); } private void mnuAbout_Click( object sender, EventArgs e) { About about = new About(); about.ShowDialog(); } private void contextMenuBar1_PopupOpen( object sender, PopupOpenEventArgs e) { SideBar sidebar1 = null ; foreach (Control ctrl in panelDockContainer1.Controls) { if (ctrl is SideBar) { sidebar1 = (SideBar)ctrl; break ; } } if (sidebar1.ExpandedPanel != null ) { if (sidebar1.ExpandedPanel.ItemImageSize == DevComponents.DotNetBar.eBarImageSize.Large) { mnuLarge.Checked = true ; mnuSmall.Checked = false ; } else { mnuLarge.Checked = false ; mnuSmall.Checked = true ; } } } private void mnuLarge_Click( object sender, EventArgs e) { SideBar sidebar1 = null ; foreach (Control ctrl in panelDockContainer1.Controls) { if (ctrl is SideBar) { sidebar1 = (SideBar)ctrl; break ; } } if (sidebar1.ExpandedPanel != null ) { foreach (SideBarPanelItem spanel in sidebar1.Panels) { spanel.ItemImageSize = eBarImageSize.Large; } } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(AppDomain.CurrentDomain.BaseDirectory "userFile.xml" ); XmlNode xnode = xmlDoc.SelectSingleNode( "UserConfig/iconSize" ); xnode.InnerText = "Large" ; xmlDoc.Save(Application.StartupPath "\\userFile.xml" ); } private void mnuSmall_Click( object sender, EventArgs e) { SideBar sidebar1 = null ; foreach (Control ctrl in panelDockContainer1.Controls) { if (ctrl is SideBar) { sidebar1 = (SideBar)ctrl; break ; } } if (sidebar1.ExpandedPanel != null ) { foreach (SideBarPanelItem spanel in sidebar1.Panels) { spanel.ItemImageSize = eBarImageSize.Default; } } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(AppDomain.CurrentDomain.BaseDirectory "userFile.xml" ); XmlNode xnode = xmlDoc.SelectSingleNode( "UserConfig/iconSize" ); xnode.InnerText = "Small" ; xmlDoc.Save(Application.StartupPath "\\userFile.xml" ); } } } |
标签: C# DevComponents DotNetBar
相关软件
网友评论
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)