source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/BMX41000/IHS BMX Framework/IndianHealthService.BMXNet.Tools.SchemaBuilder/MainWindow.cs@ 1561

Last change on this file since 1561 was 1146, checked in by Sam Habiel, 14 years ago

Initial Import of BMX4

File size: 31.0 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Data;
7using IndianHealthService.BMXNet;
8using System.Diagnostics;
9using IndianHealthService.BMXNet.WinForm;
10using IndianHealthService.BMXNet.Services;
11using IndianHealthService.BMXNet.WinForm.Configuration;
12
13namespace IndianHealthService.BMXNet.Tools.SchemaBuilder
14{
15 public class MainWindow : System.Windows.Forms.Form
16 {
17 private System.Windows.Forms.MainMenu mnuMain;
18 private System.Windows.Forms.MenuItem menuItem1;
19 private System.Windows.Forms.MenuItem changeServer;
20 private System.Windows.Forms.MenuItem changeRpmsLogion;
21 private System.Windows.Forms.MenuItem menuItem4;
22 private System.Windows.Forms.MenuItem menuItem9;
23 private System.Windows.Forms.MenuItem menuItem11;
24 private System.Windows.Forms.MenuItem mnuHelpAbout;
25 private System.Windows.Forms.Panel pnlStatusBar;
26 private System.Windows.Forms.Panel pnlMain;
27 private System.Windows.Forms.Splitter spltHorizontal;
28 private System.Windows.Forms.Panel pnlFileField;
29 private System.Windows.Forms.StatusBar statusBar1;
30 private System.Windows.Forms.Panel pnlFile;
31 private System.Windows.Forms.Splitter spltFileField;
32 private System.Windows.Forms.Panel pnlField;
33 private System.Windows.Forms.TreeView tvFile;
34 private System.Windows.Forms.Label lblTreeView;
35 private System.Windows.Forms.MenuItem menuItem12;
36 private System.Windows.Forms.MenuItem mnuViewFiles;
37 private System.Windows.Forms.MenuItem mnuViewStatusBar;
38 private System.Windows.Forms.Panel pnlFieldGrid;
39 private System.Windows.Forms.DataGrid grdFieldList;
40 private System.Windows.Forms.MenuItem mnuFileNewSchema;
41 private System.Windows.Forms.MenuItem mnuFileOpenSchema;
42 private System.Windows.Forms.MenuItem mnuFileSave;
43 private System.Windows.Forms.MenuItem mnuFileSaveAs;
44 private System.Windows.Forms.MenuItem mnuFileExit;
45 private System.Windows.Forms.ContextMenu mnuTreeNode;
46 private System.Windows.Forms.MenuItem mnuSetSchemaFile;
47 private Infragistics.Win.UltraWinGrid.UltraGrid ugrdSchemaFields;
48 private IContainer components;
49
50 #region Windows Form Designer generated code
51 /// <summary>
52 /// Required method for Designer support - do not modify
53 /// the contents of this method with the code editor.
54 /// </summary>
55 private void InitializeComponent()
56 {
57 this.components = new System.ComponentModel.Container();
58 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
59 this.mnuMain = new System.Windows.Forms.MainMenu(this.components);
60 this.menuItem1 = new System.Windows.Forms.MenuItem();
61 this.changeServer = new System.Windows.Forms.MenuItem();
62 this.changeRpmsLogion = new System.Windows.Forms.MenuItem();
63 this.menuItem4 = new System.Windows.Forms.MenuItem();
64 this.mnuFileOpenSchema = new System.Windows.Forms.MenuItem();
65 this.mnuFileNewSchema = new System.Windows.Forms.MenuItem();
66 this.mnuFileSave = new System.Windows.Forms.MenuItem();
67 this.mnuFileSaveAs = new System.Windows.Forms.MenuItem();
68 this.menuItem9 = new System.Windows.Forms.MenuItem();
69 this.mnuFileExit = new System.Windows.Forms.MenuItem();
70 this.menuItem12 = new System.Windows.Forms.MenuItem();
71 this.mnuViewFiles = new System.Windows.Forms.MenuItem();
72 this.mnuViewStatusBar = new System.Windows.Forms.MenuItem();
73 this.menuItem11 = new System.Windows.Forms.MenuItem();
74 this.mnuHelpAbout = new System.Windows.Forms.MenuItem();
75 this.pnlFileField = new System.Windows.Forms.Panel();
76 this.pnlField = new System.Windows.Forms.Panel();
77 this.grdFieldList = new System.Windows.Forms.DataGrid();
78 this.spltFileField = new System.Windows.Forms.Splitter();
79 this.pnlFile = new System.Windows.Forms.Panel();
80 this.tvFile = new System.Windows.Forms.TreeView();
81 this.mnuTreeNode = new System.Windows.Forms.ContextMenu();
82 this.mnuSetSchemaFile = new System.Windows.Forms.MenuItem();
83 this.lblTreeView = new System.Windows.Forms.Label();
84 this.spltHorizontal = new System.Windows.Forms.Splitter();
85 this.pnlStatusBar = new System.Windows.Forms.Panel();
86 this.statusBar1 = new System.Windows.Forms.StatusBar();
87 this.pnlMain = new System.Windows.Forms.Panel();
88 this.pnlFieldGrid = new System.Windows.Forms.Panel();
89 this.ugrdSchemaFields = new Infragistics.Win.UltraWinGrid.UltraGrid();
90 this.pnlFileField.SuspendLayout();
91 this.pnlField.SuspendLayout();
92 ((System.ComponentModel.ISupportInitialize)(this.grdFieldList)).BeginInit();
93 this.pnlFile.SuspendLayout();
94 this.pnlStatusBar.SuspendLayout();
95 this.pnlMain.SuspendLayout();
96 this.pnlFieldGrid.SuspendLayout();
97 ((System.ComponentModel.ISupportInitialize)(this.ugrdSchemaFields)).BeginInit();
98 this.SuspendLayout();
99 //
100 // mnuMain
101 //
102 this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
103 this.menuItem1,
104 this.menuItem12,
105 this.menuItem11});
106 //
107 // menuItem1
108 //
109 this.menuItem1.Index = 0;
110 this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
111 this.changeServer,
112 this.changeRpmsLogion,
113 this.menuItem4,
114 this.mnuFileOpenSchema,
115 this.mnuFileNewSchema,
116 this.mnuFileSave,
117 this.mnuFileSaveAs,
118 this.menuItem9,
119 this.mnuFileExit});
120 this.menuItem1.Text = "&File";
121 //
122 // changeServer
123 //
124 this.changeServer.Index = 0;
125 this.changeServer.Text = "Change RPMS Ser&ver";
126 //
127 // changeRpmsLogion
128 //
129 this.changeRpmsLogion.Index = 1;
130 this.changeRpmsLogion.Text = "Change RPMS &Login";
131 this.changeRpmsLogion.Click += new System.EventHandler(this.changeRpmsLogion_Click);
132 //
133 // menuItem4
134 //
135 this.menuItem4.Index = 2;
136 this.menuItem4.Text = "-";
137 //
138 // mnuFileOpenSchema
139 //
140 this.mnuFileOpenSchema.Index = 3;
141 this.mnuFileOpenSchema.Text = "&Open Schema...";
142 this.mnuFileOpenSchema.Click += new System.EventHandler(this.mnuFileOpenSchema_Click);
143 //
144 // mnuFileNewSchema
145 //
146 this.mnuFileNewSchema.Index = 4;
147 this.mnuFileNewSchema.Text = "&New Schema...";
148 this.mnuFileNewSchema.Click += new System.EventHandler(this.mnuFileNewSchema_Click);
149 //
150 // mnuFileSave
151 //
152 this.mnuFileSave.Index = 5;
153 this.mnuFileSave.Text = "&Save";
154 this.mnuFileSave.Click += new System.EventHandler(this.mnuFileSave_Click);
155 //
156 // mnuFileSaveAs
157 //
158 this.mnuFileSaveAs.Index = 6;
159 this.mnuFileSaveAs.Text = "Save &As";
160 //
161 // menuItem9
162 //
163 this.menuItem9.Index = 7;
164 this.menuItem9.Text = "-";
165 //
166 // mnuFileExit
167 //
168 this.mnuFileExit.Index = 8;
169 this.mnuFileExit.Text = "E&xit";
170 //
171 // menuItem12
172 //
173 this.menuItem12.Index = 1;
174 this.menuItem12.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
175 this.mnuViewFiles,
176 this.mnuViewStatusBar});
177 this.menuItem12.Text = "&View";
178 //
179 // mnuViewFiles
180 //
181 this.mnuViewFiles.Checked = true;
182 this.mnuViewFiles.Index = 0;
183 this.mnuViewFiles.Text = "&File and Fields";
184 this.mnuViewFiles.Click += new System.EventHandler(this.mnuViewFiles_Click);
185 //
186 // mnuViewStatusBar
187 //
188 this.mnuViewStatusBar.Checked = true;
189 this.mnuViewStatusBar.Index = 1;
190 this.mnuViewStatusBar.Text = "&Status bar";
191 this.mnuViewStatusBar.Click += new System.EventHandler(this.mnuViewStatusBar_Click);
192 //
193 // menuItem11
194 //
195 this.menuItem11.Index = 2;
196 this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
197 this.mnuHelpAbout});
198 this.menuItem11.Text = "&Help";
199 //
200 // mnuHelpAbout
201 //
202 this.mnuHelpAbout.Index = 0;
203 this.mnuHelpAbout.Text = "&About";
204 this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click);
205 //
206 // pnlFileField
207 //
208 this.pnlFileField.Controls.Add(this.pnlField);
209 this.pnlFileField.Controls.Add(this.spltFileField);
210 this.pnlFileField.Controls.Add(this.pnlFile);
211 this.pnlFileField.Dock = System.Windows.Forms.DockStyle.Top;
212 this.pnlFileField.Location = new System.Drawing.Point(0, 0);
213 this.pnlFileField.Name = "pnlFileField";
214 this.pnlFileField.Size = new System.Drawing.Size(656, 300);
215 this.pnlFileField.TabIndex = 0;
216 //
217 // pnlField
218 //
219 this.pnlField.Controls.Add(this.grdFieldList);
220 this.pnlField.Dock = System.Windows.Forms.DockStyle.Fill;
221 this.pnlField.Location = new System.Drawing.Point(255, 0);
222 this.pnlField.Name = "pnlField";
223 this.pnlField.Size = new System.Drawing.Size(401, 300);
224 this.pnlField.TabIndex = 3;
225 //
226 // grdFieldList
227 //
228 this.grdFieldList.AccessibleName = "DataGrid";
229 this.grdFieldList.AccessibleRole = System.Windows.Forms.AccessibleRole.Table;
230 this.grdFieldList.CaptionBackColor = System.Drawing.SystemColors.Control;
231 this.grdFieldList.CaptionForeColor = System.Drawing.SystemColors.ControlText;
232 this.grdFieldList.CaptionText = "Fields:";
233 this.grdFieldList.DataMember = "";
234 this.grdFieldList.Dock = System.Windows.Forms.DockStyle.Fill;
235 this.grdFieldList.HeaderForeColor = System.Drawing.SystemColors.ControlText;
236 this.grdFieldList.ImeMode = System.Windows.Forms.ImeMode.NoControl;
237 this.grdFieldList.Location = new System.Drawing.Point(0, 0);
238 this.grdFieldList.Name = "grdFieldList";
239 this.grdFieldList.ReadOnly = true;
240 this.grdFieldList.Size = new System.Drawing.Size(401, 300);
241 this.grdFieldList.TabIndex = 0;
242 this.grdFieldList.MouseUp += new System.Windows.Forms.MouseEventHandler(this.grdFieldList_MouseUp);
243 this.grdFieldList.MouseMove += new System.Windows.Forms.MouseEventHandler(this.grdFieldList_MouseMove);
244 this.grdFieldList.MouseDown += new System.Windows.Forms.MouseEventHandler(this.grdFieldList_MouseDown);
245 //
246 // spltFileField
247 //
248 this.spltFileField.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
249 this.spltFileField.Location = new System.Drawing.Point(250, 0);
250 this.spltFileField.Name = "spltFileField";
251 this.spltFileField.Size = new System.Drawing.Size(5, 300);
252 this.spltFileField.TabIndex = 2;
253 this.spltFileField.TabStop = false;
254 //
255 // pnlFile
256 //
257 this.pnlFile.Controls.Add(this.tvFile);
258 this.pnlFile.Controls.Add(this.lblTreeView);
259 this.pnlFile.Dock = System.Windows.Forms.DockStyle.Left;
260 this.pnlFile.Location = new System.Drawing.Point(0, 0);
261 this.pnlFile.Name = "pnlFile";
262 this.pnlFile.Size = new System.Drawing.Size(250, 300);
263 this.pnlFile.TabIndex = 1;
264 //
265 // tvFile
266 //
267 this.tvFile.ContextMenu = this.mnuTreeNode;
268 this.tvFile.Dock = System.Windows.Forms.DockStyle.Fill;
269 this.tvFile.Location = new System.Drawing.Point(0, 16);
270 this.tvFile.Name = "tvFile";
271 this.tvFile.Size = new System.Drawing.Size(250, 284);
272 this.tvFile.TabIndex = 0;
273 this.tvFile.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvFile_BeforeExpand);
274 this.tvFile.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvFile_AfterSelect);
275 //
276 // mnuTreeNode
277 //
278 this.mnuTreeNode.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
279 this.mnuSetSchemaFile});
280 //
281 // mnuSetSchemaFile
282 //
283 this.mnuSetSchemaFile.Index = 0;
284 this.mnuSetSchemaFile.Text = "Set Schema File";
285 this.mnuSetSchemaFile.Click += new System.EventHandler(this.mnuSetSchemaFile_Click);
286 //
287 // lblTreeView
288 //
289 this.lblTreeView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
290 this.lblTreeView.Dock = System.Windows.Forms.DockStyle.Top;
291 this.lblTreeView.Location = new System.Drawing.Point(0, 0);
292 this.lblTreeView.Name = "lblTreeView";
293 this.lblTreeView.Size = new System.Drawing.Size(250, 16);
294 this.lblTreeView.TabIndex = 1;
295 this.lblTreeView.Text = "FileMan File:";
296 //
297 // spltHorizontal
298 //
299 this.spltHorizontal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
300 this.spltHorizontal.Dock = System.Windows.Forms.DockStyle.Top;
301 this.spltHorizontal.Location = new System.Drawing.Point(0, 300);
302 this.spltHorizontal.Name = "spltHorizontal";
303 this.spltHorizontal.Size = new System.Drawing.Size(656, 5);
304 this.spltHorizontal.TabIndex = 1;
305 this.spltHorizontal.TabStop = false;
306 //
307 // pnlStatusBar
308 //
309 this.pnlStatusBar.Controls.Add(this.statusBar1);
310 this.pnlStatusBar.Dock = System.Windows.Forms.DockStyle.Bottom;
311 this.pnlStatusBar.Location = new System.Drawing.Point(0, 521);
312 this.pnlStatusBar.Name = "pnlStatusBar";
313 this.pnlStatusBar.Size = new System.Drawing.Size(656, 24);
314 this.pnlStatusBar.TabIndex = 2;
315 //
316 // statusBar1
317 //
318 this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
319 this.statusBar1.Location = new System.Drawing.Point(0, 0);
320 this.statusBar1.Name = "statusBar1";
321 this.statusBar1.Size = new System.Drawing.Size(656, 24);
322 this.statusBar1.TabIndex = 0;
323 this.statusBar1.Text = "statusBar1";
324 //
325 // pnlMain
326 //
327 this.pnlMain.AutoScroll = true;
328 this.pnlMain.Controls.Add(this.pnlFieldGrid);
329 this.pnlMain.Dock = System.Windows.Forms.DockStyle.Fill;
330 this.pnlMain.Location = new System.Drawing.Point(0, 305);
331 this.pnlMain.Name = "pnlMain";
332 this.pnlMain.Size = new System.Drawing.Size(656, 216);
333 this.pnlMain.TabIndex = 3;
334 //
335 // pnlFieldGrid
336 //
337 this.pnlFieldGrid.Controls.Add(this.ugrdSchemaFields);
338 this.pnlFieldGrid.Dock = System.Windows.Forms.DockStyle.Fill;
339 this.pnlFieldGrid.Location = new System.Drawing.Point(0, 0);
340 this.pnlFieldGrid.Name = "pnlFieldGrid";
341 this.pnlFieldGrid.Size = new System.Drawing.Size(656, 216);
342 this.pnlFieldGrid.TabIndex = 2;
343 //
344 // ugrdSchemaFields
345 //
346 this.ugrdSchemaFields.AllowDrop = true;
347 this.ugrdSchemaFields.Cursor = System.Windows.Forms.Cursors.Default;
348 this.ugrdSchemaFields.Dock = System.Windows.Forms.DockStyle.Fill;
349 this.ugrdSchemaFields.Location = new System.Drawing.Point(0, 0);
350 this.ugrdSchemaFields.Name = "ugrdSchemaFields";
351 this.ugrdSchemaFields.Size = new System.Drawing.Size(656, 216);
352 this.ugrdSchemaFields.TabIndex = 1;
353 this.ugrdSchemaFields.Text = "Schema File:";
354 this.ugrdSchemaFields.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.ugrdSchemaFields_InitializeLayout);
355 this.ugrdSchemaFields.DragDrop += new System.Windows.Forms.DragEventHandler(this.ugrdSchemaFields_DragDrop);
356 this.ugrdSchemaFields.DragEnter += new System.Windows.Forms.DragEventHandler(this.ugrdSchemaFields_DragEnter);
357 //
358 // MainWindow
359 //
360 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
361 this.ClientSize = new System.Drawing.Size(656, 545);
362 this.Controls.Add(this.pnlMain);
363 this.Controls.Add(this.pnlStatusBar);
364 this.Controls.Add(this.spltHorizontal);
365 this.Controls.Add(this.pnlFileField);
366 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
367 this.Menu = this.mnuMain;
368 this.Name = "MainWindow";
369 this.Text = "BMX Schema Builder";
370 this.Load += new System.EventHandler(this.frmMain_Load);
371 this.pnlFileField.ResumeLayout(false);
372 this.pnlField.ResumeLayout(false);
373 ((System.ComponentModel.ISupportInitialize)(this.grdFieldList)).EndInit();
374 this.pnlFile.ResumeLayout(false);
375 this.pnlStatusBar.ResumeLayout(false);
376 this.pnlMain.ResumeLayout(false);
377 this.pnlFieldGrid.ResumeLayout(false);
378 ((System.ComponentModel.ISupportInitialize)(this.ugrdSchemaFields)).EndInit();
379 this.ResumeLayout(false);
380
381 }
382 #endregion
383
384 #region Fields
385
386 private BMXSchemaDoc _document;
387
388 public BMXSchemaDoc Document
389 {
390 get { return _document; }
391 set { _document = value; }
392 }
393
394 private string _appName = "BMXSchemaBuilder";
395
396 public string AppName
397 {
398 get { return _appName; }
399 set { _appName = value; }
400 }
401 private bool m_bMouseDown;
402 private bool m_bDragDropStart;
403
404 #endregion Fields
405
406 #region Methods
407
408
409 protected override void Dispose( bool disposing )
410 {
411 if( disposing )
412 {
413 if (components != null)
414 {
415 components.Dispose();
416 }
417 }
418 base.Dispose( disposing );
419 }
420
421
422
423 private WinFramework _framework = null;
424
425 public WinFramework Framework
426 {
427 get { return _framework; }
428 set { _framework = value; }
429 }
430
431 private RemoteSession _remoteSession = null;
432
433 public RemoteSession RemoteSession
434 {
435 get { return _remoteSession; }
436 set { _remoteSession = value; }
437 }
438
439
440 private void frmMain_Load(object sender, System.EventArgs e)
441 {
442 this.Login(false);
443
444 }
445
446 public void Login(bool isSwitchServer)
447 {
448 if (this.Framework == null)
449 {
450 this.Framework = WinFramework.CreateWithNetworkBroker(true);
451 this.Framework.LoadConnectionSpecs(LocalPersistentStore.CreateDefaultStorage(true), "SchemaBuilder");
452
453 LoginProcess login = this.Framework.CreateLoginProcess();
454 login.IsSwitchServerModeEnabled = isSwitchServer;
455
456 if (login.HasDefaultConnectionWithUseWindowsAuth && login.AttemptWindowsAuthLogin())
457 {
458 login.AttemptWindowsAuthLogin();
459 }
460
461 if (!login.WasLoginAttempted || !login.WasSuccessful)
462 {
463 login.AttemptUserInputLogin("Schema Builder Login", 3, true, this);
464 }
465
466 if (!login.WasSuccessful)
467 {
468 this.Close();
469 return;
470 }
471 LocalSession local = this.Framework.LocalSession;
472
473 if (!this.Framework.AttemptUserInputSetDivision("Set Initial Division", this))
474 {
475 this.Close();
476 return;
477 }
478
479 this.RemoteSession = this.Framework.PrimaryRemoteSession;
480
481 this.UpdateTitle();
482 this.SetGridStyle();
483 this.LoadFileTree();
484 this.LoadNewSchema();
485 this.FormatSchemaFieldsGrid();
486 }
487 }
488
489 private void UpdateTitle()
490 {
491
492 }
493
494 private void LoadFileTree()
495 {
496 try
497 {
498 tvFile.BeginUpdate();
499 tvFile.Nodes.Clear();
500
501 DataTable dtFile = this.RemoteSession.TableFromCommand("BMX ADO SS^FILEMAN FILES^^B~A~ZZZ~5000");
502
503 //DataView dvFile = new DataView(dtFile);
504
505 this.AddSubFileNodes(tvFile.Nodes, dtFile);
506 }
507 catch (Exception ex)
508 {
509 throw ex;
510 }
511 finally
512 {
513 tvFile.EndUpdate();
514 }
515 }
516
517 private DataTable GetSubfiles(string sFileNum)
518 {
519 return this.RemoteSession.TableFromCommand("BMX ADO SS^SUBFILES^^~~~~~SFIT~BMXADOS1~" + sFileNum + "~");
520 }
521
522 public void LoadNewSchema()
523 {
524 this.Document.NewSchema();
525 this.ugrdSchemaFields.DataSource = this.Document.SchemaFields;
526 this.Text = this.AppName + " - " + this.Document.SchemaName;
527 string sGridText = "Schema File: ";
528 this.ugrdSchemaFields.Text = sGridText;
529 }
530
531
532 #endregion Methods
533
534 #region TreeNode
535
536 private void AddSubFileNodes(TreeNodeCollection nodParentColl, DataTable dt)
537 {
538 string sFileName;
539 string sExpand;
540 string sFileNumber;
541 DataView dvFile = new DataView(dt);
542 DataRowView drv;
543 TreeNode tn;
544 for (int j=0; j < dvFile.Count; j++)
545 {
546 drv = dvFile[j];
547 sFileName = drv["NAME"].ToString();
548 sFileNumber = drv["BMXIEN"].ToString();
549 sExpand = drv["SUBFILES PRESENT?"].ToString();
550 tn = new TreeNode(sFileName);
551 tn.Text = sFileName;
552 tn.Tag = sFileNumber;
553 if (sExpand == "+")
554 {
555 tn.Nodes.Add(".");
556 }
557 nodParentColl.Add(tn);
558 }
559 }
560
561 private void tvFile_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
562 {
563 try
564 {
565 string sNode = e.Node.Text;
566 string sFileNumber = e.Node.Tag.ToString();
567 string sCmd = "BMX ADO SS^FIELDS^^~~~~~FLDIT~BMXADOS1~" + sFileNumber + "~";
568 //DataTable dtFields = this.Bmx.TableFromAdoRPC(sCmd, "FIELDS", new DataSet(), "BMXRPC");
569
570 //this.grdFieldList.DataSource = dtFields;
571 }
572 catch (Exception ex)
573 {
574 this.Framework.LocalSession.Notify("Error in " + this.AppName, ex);
575 }
576
577 }
578
579 private void tvFile_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
580 {
581 try
582 {
583 string sNode = e.Node.Text;
584 string sFileNumber = e.Node.Tag.ToString();
585 e.Node.Nodes.Clear();
586 DataTable dtSubFiles = this.GetSubfiles(sFileNumber);
587 AddSubFileNodes(e.Node.Nodes, dtSubFiles);
588 }
589 catch (Exception ex)
590 {
591 this.Framework.LocalSession.Notify("Error in " + this.AppName, ex);
592 }
593 }
594
595
596 #endregion TreeNode
597
598 #region MouseHandlers
599
600 private void grdFieldList_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
601 {
602 m_bMouseDown = true;
603 m_bDragDropStart = false;
604 Debug.WriteLine("MouseDown" + e.Button.ToString());
605 }
606
607 private void grdFieldList_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
608 {
609 if (m_bMouseDown == true)
610 {
611 if (m_bDragDropStart == false)
612 {
613 string[] sData = new string[2];
614 DataGridCell dCell = grdFieldList.CurrentCell;
615 dCell.ColumnNumber = 0;
616 sData[0] = grdFieldList[dCell].ToString();
617 dCell.ColumnNumber = 1;
618 sData[1] = grdFieldList[dCell].ToString();
619 DragDropEffects effect = DoDragDrop(sData, DragDropEffects.Move);
620 m_bDragDropStart = true;
621 }
622 }
623 }
624
625 private void grdFieldList_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
626 {
627 Debug.WriteLine("MouseUp" + e.Button.ToString());
628 m_bMouseDown = false;
629 }
630
631 #endregion MouseHandlers
632
633
634
635 #region UltraGrid
636
637 private void SetGridStyle()
638 {
639 //Fileman Fields Grid
640 DataGridTableStyle tsFields = new DataGridTableStyle();
641 tsFields.MappingName = "FIELDS";
642 tsFields.ReadOnly = true;
643 tsFields.RowHeadersVisible = false;
644
645 // Add FIELD NUMBER column style.
646 DataGridColumnStyle colFieldNumber = new DataGridTextBoxColumn();
647 colFieldNumber.MappingName = "BMXIEN";
648 colFieldNumber.HeaderText = "Field Number";
649 colFieldNumber.Width = 100;
650 tsFields.GridColumnStyles.Add(colFieldNumber);
651 // Add FIELD NAME column style.
652 DataGridColumnStyle colFieldName = new DataGridTextBoxColumn();
653 colFieldName.MappingName = "NAME";
654 colFieldName.HeaderText = "Field Name";
655 colFieldName.Width = 290;
656 tsFields.GridColumnStyles.Add(colFieldName);
657
658 this.grdFieldList.TableStyles.Add(tsFields);
659 }
660
661 private void FormatSchemaFieldsGrid()
662 {
663 Infragistics.Win.ValueListsCollection vlSchemaFields;
664 Infragistics.Win.UltraWinGrid.UltraGridBand bndSchemaFields;
665
666 vlSchemaFields = ugrdSchemaFields.DisplayLayout.ValueLists;
667 vlSchemaFields.Add("YesNo");
668 vlSchemaFields["YesNo"].ValueListItems.Add("YES");
669 vlSchemaFields["YesNo"].ValueListItems.Add("NO");
670 vlSchemaFields.Add("DataType");
671 vlSchemaFields["DataType"].ValueListItems.Add("TEXT");
672 vlSchemaFields["DataType"].ValueListItems.Add("DATE");
673 vlSchemaFields["DataType"].ValueListItems.Add("INTEGER");
674 vlSchemaFields["DataType"].ValueListItems.Add("NUMBER");
675
676 bndSchemaFields = ugrdSchemaFields.DisplayLayout.Bands[0];
677 bndSchemaFields.Columns["READ ONLY"].ValueList = vlSchemaFields["YesNo"];
678 bndSchemaFields.Columns["KEY FIELD"].ValueList = vlSchemaFields["YesNo"];
679 bndSchemaFields.Columns["NULL ALLOWED"].ValueList = vlSchemaFields["YesNo"];
680 bndSchemaFields.Columns["IEN AUTOMATICALLY INCLUDED"].ValueList = vlSchemaFields["YesNo"];
681 bndSchemaFields.Columns["DATA TYPE"].ValueList = vlSchemaFields["DataType"];
682
683 bndSchemaFields.Columns["BMXIEN"].Hidden = true;
684 bndSchemaFields.Columns["BMXIEN1"].Hidden = true;
685
686 }
687
688 private void ugrdSchemaFields_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
689 {
690 try
691 {
692 string[] sData = (string[]) e.Data.GetData(typeof(string[]));
693 m_bDragDropStart = false;
694 DataTable dt = (DataTable) ugrdSchemaFields.DataSource;
695 DataRow dr = dt.NewRow();
696 double nField = Convert.ToDouble(sData[0]);
697 string sField = nField.ToString(".#####");
698 dr["FIELD NUMBER"] =sField ;
699 dr["COLUMN HEADER"] = sData[1];
700 dt.Rows.Add(dr);
701 Document.SchemaFields = dt;
702 ugrdSchemaFields.DataSource = Document.SchemaFields;
703 ugrdSchemaFields.Refresh();
704 }
705 catch (Exception ex)
706 {
707 this.Framework.LocalSession.Notify("Error in " + this.AppName, ex);
708 }
709 }
710
711 private void ugrdSchemaFields_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
712 {
713 bool b = e.Data.GetDataPresent(typeof(string[]));
714 if (b == true)
715 {
716 if ((e.KeyState & 8) == 8) //CTRL key
717 {
718 e.Effect = DragDropEffects.Copy;
719 }
720 else
721 {
722 e.Effect = DragDropEffects.Move;
723 }
724 }
725 else
726 {
727 e.Effect = DragDropEffects.None;
728 }
729 }
730
731 private void ugrdSchemaFields_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
732 {
733 e.Layout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
734 }
735 #endregion UltraGrid
736
737 #region MenuHandlers
738
739 private void mnuHelpAbout_Click(object sender, System.EventArgs e)
740 {
741 new AboutDialog().ShowDialog();
742 }
743
744 private void mnuViewFiles_Click(object sender, System.EventArgs e)
745 {
746 mnuViewFiles.Checked = !(mnuViewFiles.Checked);
747 pnlFileField.Visible = mnuViewFiles.Checked;
748 }
749
750 private void mnuViewStatusBar_Click(object sender, System.EventArgs e)
751 {
752 mnuViewStatusBar.Checked = !(mnuViewStatusBar.Checked);
753 this.statusBar1.Visible = mnuViewStatusBar.Checked;
754 }
755
756 private void mnuFileNewSchema_Click(object sender, System.EventArgs e)
757 {
758 LoadNewSchema();
759 }
760
761 private void mnuFileSave_Click(object sender, System.EventArgs e)
762 {
763 try
764 {
765 if (Document.SchemaIEN == 0)
766 {
767 //prompt for a name
768 DSaveSchema dSave = new DSaveSchema();
769 if (dSave.ShowDialog() == DialogResult.Cancel)
770 return;
771 this.Document.SaveSchema(dSave.SchemaName);
772 this.Text = this.AppName + " - " + Document.SchemaName;
773
774 }
775 else
776 {
777 this.Document.SaveSchema();
778 }
779 }
780 catch (Exception ex)
781 {
782 this.Framework.LocalSession.Notify("Error in " + this.AppName, ex);
783 }
784 }
785
786 private void mnuFileOpenSchema_Click(object sender, System.EventArgs e)
787 {
788 //Display a dialog to select from existing schemas
789 DSelectSchema dss = new DSelectSchema();
790 // dss.InitializePage(this);
791 if (dss.ShowDialog() == DialogResult.Cancel)
792 return;
793
794 Document.OpenSchema(dss.SchemaIEN, dss.SchemaName, dss.FileNumber);
795 ugrdSchemaFields.DataSource = Document.SchemaFields;
796 ugrdSchemaFields.Refresh();
797
798 string sGridText = "Schema File: " + Document.SchemaFileName + " (Number "+ Document.SchemaFileNumber.ToString() + ")";
799 if (Document.SchemaReadOnlyDataset == true)
800 sGridText += " [Dataset is ReadOnly]";
801 this.ugrdSchemaFields.Text = sGridText;
802 this.Text = this.AppName + " - " + Document.SchemaName;
803 }
804
805 private void mnuSetSchemaFile_Click(object sender, System.EventArgs e)
806 {
807 Document.SchemaFileName = this.tvFile.SelectedNode.Text;
808 Document.SchemaFileNumber = Convert.ToDouble(this.tvFile.SelectedNode.Tag);
809 ugrdSchemaFields.Text = "Schema File: " + Document.SchemaFileName;
810 ugrdSchemaFields.Text += " (Number " + Document.SchemaFileNumber.ToString() + ")";
811 }
812
813
814 #endregion MenuHandlers
815
816 private void changeRpmsLogion_Click(object sender, EventArgs e)
817 {
818 this.Framework.Close();
819 this.Framework = null;
820 this.Login(true);
821
822 }
823
824
825
826 }
827}
Note: See TracBrowser for help on using the repository browser.