context: using System;
  using System.Drawing;
  using System.Collections;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Windows.Forms;
  using OpenDental.UI;
  using OpenDentBusiness;
  
  namespace OpenDental{
  	/// <summary>
  	/// Summary description for FormBasicTemplate.
  	/// </summary>
  	public class FormTransactionEdit : System.Windows.Forms.Form{
  		private OpenDental.UI.Button butCancel;
  		private OpenDental.UI.Button butOK;
  		/// <summary>
  		/// Required designer variable.
  		/// </summary>
  		private System.ComponentModel.Container components = null;
  		private OpenDental.UI.ODGrid gridMain;
  		private ValidDate textDate;
  		private Label label1;
  		private Label label2;
  		private TextBox textDateTimeEntry;
  		private OpenDental.UI.Button butAttachDep;
  		private OpenDental.UI.Button butDelete;
  		private Transaction TransCur;
  		private List<JournalEntry> JournalList;
  		private List<JournalEntry> JournalListOld;
  		private Label label3;
  		private TextBox textDebit;
  		private TextBox textCredit;
  		private CheckBox checkMemoSame;
  		private OpenDental.UI.Button butAdd;
  		private CheckBox checkSimple;
  		private Label label5;
  		private Label label4;
  		private ValidDouble textAmount;
  		private Label label6;
  		private Panel panelSimple;
  		private Panel panelCompound;
  		private TextBox textCheckNumber;
  		private Label label7;
  		private TextBox textMemo;
  		private OpenDental.UI.Button butChange;
  		private TextBox textAccount;
  		///<summary>The account where the edit originated from.  This affects how the simple version gets displayed, and the signs on debit and credit.</summary>
  		private Account AccountOfOrigin;
  		///<summary>When in simple mode, this is the 'other' account, not the one of origin.  It can be null.</summary>
  		private Account AccountPicked;
  		private GroupBox groupBox1;
  		private TextBox textSourceDeposit;
  		private Label label9;
  		private Label label8;
  		private TextBox textSourcePay;
  		private OpenDental.UI.Button butAttachPay;
  		private Label labelReconcile;
  		private TextBox textReconcile;
  		///<summary>Just used for security.</summary>
  		public bool IsNew;
  
  		///<summary></summary>
  		public FormTransactionEdit(long transNum,long accountNum)
  		{
  			//
  			// Required for Windows Form Designer support
  			//
  			InitializeComponent();
  			Lan.F(this);
  			TransCur=Transactions.GetTrans(transNum);
  			AccountOfOrigin=Accounts.GetAccount(accountNum);
  			//AccountNumOrigin=accountNumOrigin;
  		}
  
  		/// <summary>
  		/// Clean up any resources being used.
  		/// </summary>
  		protected override void Dispose( bool disposing )
  		{
  			if( disposing )
  			{
  				if(components != null)
  				{
  					components.Dispose();
  				}
  			}
  			base.Dispose( disposing );
  		}
  
  		#region Windows Form Designer generated code
  		/// <summary>
  		/// Required method for Designer support - do not modify
  		/// the contents of this method with the code editor.
  		/// </summary>
  		private void InitializeComponent()
  		{
  			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormTransactionEdit));
  			this.label1 = new System.Windows.Forms.Label();
  			this.label2 = new System.Windows.Forms.Label();
  			this.textDateTimeEntry = new System.Windows.Forms.TextBox();
  			this.label3 = new System.Windows.Forms.Label();
  			this.textDebit = new System.Windows.Forms.TextBox();
  			this.textCredit = new System.Windows.Forms.TextBox();
  			this.checkMemoSame = new System.Windows.Forms.CheckBox();
  			this.checkSimple = new System.Windows.Forms.CheckBox();
  			this.label5 = new System.Windows.Forms.Label();
  			this.label4 = new System.Windows.Forms.Label();
  			this.label6 = new System.Windows.Forms.Label();
  			this.panelSimple = new System.Windows.Forms.Panel();
  			this.butChange = new OpenDental.UI.Button();
  			this.textAccount = new System.Windows.Forms.TextBox();
  			this.textMemo = new System.Windows.Forms.TextBox();
  			this.textCheckNumber = new System.Windows.Forms.TextBox();
  			this.label7 = new System.Windows.Forms.Label();
  			this.textAmount = new OpenDental.ValidDouble();
  			this.panelCompound = new System.Windows.Forms.Panel();
  			this.butAdd = new OpenDental.UI.Button();
  			this.gridMain = new OpenDental.UI.ODGrid();
  			this.groupBox1 = new System.Windows.Forms.GroupBox();
  			this.label9 = new System.Windows.Forms.Label();
  			this.label8 = new System.Windows.Forms.Label();
  			this.textSourcePay = new System.Windows.Forms.TextBox();
  			this.butAttachPay = new OpenDental.UI.Button();
  			this.textSourceDeposit = new System.Windows.Forms.TextBox();
  			this.butAttachDep = new OpenDental.UI.Button();
  			this.butDelete = new OpenDental.UI.Button();
  			this.textDate = new OpenDental.ValidDate();
  			this.butOK = new OpenDental.UI.Button();
  			this.butCancel = new OpenDental.UI.Button();
  			this.labelReconcile = new System.Windows.Forms.Label();
  			this.textReconcile = new System.Windows.Forms.TextBox();
  			this.panelSimple.SuspendLayout();
  			this.panelCompound.SuspendLayout();
  			this.groupBox1.SuspendLayout();
  			this.SuspendLayout();
  			// 
  			// label1
  			// 
  			this.label1.Location = new System.Drawing.Point(28,34);
  			this.label1.Name = "label1";
  			this.label1.Size = new System.Drawing.Size(100,20);
  			this.label1.TabIndex = 4;
  			this.label1.Text = "Date";
  			this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
  			// 
  			// label2
  			// 
  			this.label2.Location = new System.Drawing.Point(6,10);
  			this.label2.Name = "label2";
  			this.label2.Size = new System.Drawing.Size(123,20);
  			this.label2.TabIndex = 5;
  			this.label2.Text = "Date/Time  Entered";
  			this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight;
  			// 
  			// textDateTimeEntry
  			// 
  			this.textDateTimeEntry.Location = new System.Drawing.Point(132,7);
  			this.textDateTimeEntry.Name = "textDateTimeEntry";
  			this.textDateTimeEntry.ReadOnly = true;
  			this.textDateTimeEntry.Size = new System.Drawing.Size(147,20);
  			this.textDateTimeEntry.TabIndex = 6;
  			// 
  			// label3
  			// 
  			this.label3.Location = new System.Drawing.Point(74,221);
  			this.label3.Name = "label3";
  			this.label3.Size = new System.Drawing.Size(77,20);
  			this.label3.TabIndex = 9;
  			this.label3.Text = "Totals";
  			this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight;
  			// 
  			// textDebit
  			// 
  			this.textDebit.Location = new System.Drawing.Point(153,218);
  			this.textDebit.Name = "textDebit";
  			this.textDebit.ReadOnly = true;
  			this.textDebit.Size = new System.Drawing.Size(70,20);
  			this.textDebit.TabIndex = 10;
  			// 
  			// textCredit
  			// 
  			this.textCredit.Location = new System.Drawing.Point(223,218);
  			this.textCredit.Name = "textCredit";
  			this.textCredit.ReadOnly = true;
  			this.textCredit.Size = new System.Drawing.Size(70,20);
  			this.textCredit.TabIndex = 11;
  			// 
  			// checkMemoSame
  			// 
  			this.checkMemoSame.Location = new System.Drawing.Point(328,218);
  			this.checkMemoSame.Name = "checkMemoSame";
  			this.checkMemoSame.Size = new System.Drawing.Size(165,20);
  			this.checkMemoSame.TabIndex = 12;
  			this.checkMemoSame.Text = "Memo Same For All";
  			this.checkMemoSame.UseVisualStyleBackColor = true;
  			// 
  			// checkSimple
  			// 
  			this.checkSimple.Location = new System.Drawing.Point(392,7);
  			this.checkSimple.Name = "checkSimple";
  			this.checkSimple.Size = new System.Drawing.Size(154,20);
  			this.checkSimple.TabIndex = 14;
  			this.checkSimple.Text = "Simple";
  			this.checkSimple.UseVisualStyleBackColor = true;
  			this.checkSimple.Click += new System.EventHandler(this.checkSimple_Click);
  			// 
  			// label5
  			// 
  			this.label5.Location = new System.Drawing.Point(8,37);
  			this.label5.Name = "label5";
  			this.label5.Size = new System.Drawing.Size(100,20);
  			this.label5.TabIndex = 21;
  			this.label5.Text = "Other Account";
  			this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight;
  			// 
  			// label4
  			// 
  			this.label4.Location = new System.Drawing.Point(8,65);
  			this.label4.Name = "label4";
  			this.label4.Size = new System.Drawing.Size(100,20);
  			this.label4.TabIndex = 19;
  			this.label4.Text = "Memo";
  			this.label4.TextAlign = System.Drawing.ContentAlignment.TopRight;
  			// 
  			// label6
  			// 
  			this.label6.Location = new System.Drawing.Point(7,11);
  			this.label6.Name = "label6";
  			this.label6.Size = new System.Drawing.Size(100,20);
  			this.label6.TabIndex = 17;
  			this.label6.Text = "Amount";
  			this.label6.TextAlign = System.Drawing.ContentAlignment.TopRight;
  			// 
  			// panelSimple
  			// 
  			this.panelSimple.Controls.Add(this.butChange);
  			this.panelSimple.Controls.Add(this.textAccount);
  			this.panelSimple.Controls.Add(this.textMemo);
  			this.panelSimple.Controls.Add(this.textCheckNumber);
  			this.panelSimple.Controls.Add(this.label7);
  			this.panelSimple.Controls.Add(this.textAmount);
  			this.panelSimple.Controls.Add(this.label5);
  			this.panelSimple.Controls.Add(this.label6);
  			this.panelSimple.Controls.Add(this.label4);
  			this.panelSimple.Location = new System.Drawing.Point(21,81);
  			this.panelSimple.Name = "panelSimple";
  			this.panelSimple.Size = new System.Drawing.Size(494,186);
  			this.panelSimple.TabIndex = 16;
  			// 
  			// butChange
  			// 
  			this.butChange.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butChange.Autosize = true;
  			this.butChange.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butChange.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butChange.CornerRadius = 4F;
  			this.butChange.Location = new System.Drawing.Point(347,31);
  			this.butChange.Name = "butChange";
  			this.butChange.Size = new System.Drawing.Size(75,26);
  			this.butChange.TabIndex = 28;
  			this.butChange.Text = "Change";
  			this.butChange.Click += new System.EventHandler(this.butChange_Click);
  			// 
  			// textAccount
  			// 
  			this.textAccount.Location = new System.Drawing.Point(111,34);
  			this.textAccount.Name = "textAccount";
  			this.textAccount.ReadOnly = true;
  			this.textAccount.Size = new System.Drawing.Size(230,20);
  			this.textAccount.TabIndex = 27;
  			// 
  			// textMemo
  			// 
  			this.textMemo.Location = new System.Drawing.Point(111,62);
  			this.textMemo.Multiline = true;
  			this.textMemo.Name = "textMemo";
  			this.textMemo.Size = new System.Drawing.Size(230,43);
  			this.textMemo.TabIndex = 25;
  			// 
  			// textCheckNumber
  			// 
  			this.textCheckNumber.Location = new System.Drawing.Point(111,111);
  			this.textCheckNumber.Name = "textCheckNumber";
  			this.textCheckNumber.Size = new System.Drawing.Size(133,20);
  			this.textCheckNumber.TabIndex = 24;
  			// 
  			// label7
  			// 
  			this.label7.Location = new System.Drawing.Point(8,114);
  			this.label7.Name = "label7";
  			this.label7.Size = new System.Drawing.Size(100,20);
  			this.label7.TabIndex = 23;
  			this.label7.Text = "Check Number";
  			this.label7.TextAlign = System.Drawing.ContentAlignment.TopRight;
  			// 
  			// textAmount
  			// 
  			this.textAmount.Location = new System.Drawing.Point(111,8);
  			this.textAmount.Name = "textAmount";
  			this.textAmount.Size = new System.Drawing.Size(89,20);
  			this.textAmount.TabIndex = 18;
  			// 
  			// panelCompound
  			// 
  			this.panelCompound.Controls.Add(this.butAdd);
  			this.panelCompound.Controls.Add(this.gridMain);
  			this.panelCompound.Controls.Add(this.label3);
  			this.panelCompound.Controls.Add(this.textDebit);
  			this.panelCompound.Controls.Add(this.textCredit);
  			this.panelCompound.Controls.Add(this.checkMemoSame);
  			this.panelCompound.Location = new System.Drawing.Point(42,81);
  			this.panelCompound.Name = "panelCompound";
  			this.panelCompound.Size = new System.Drawing.Size(504,262);
  			this.panelCompound.TabIndex = 17;
  			// 
  			// butAdd
  			// 
  			this.butAdd.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butAdd.Autosize = true;
  			this.butAdd.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butAdd.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butAdd.CornerRadius = 4F;
  			this.butAdd.Image = global::OpenDental.Properties.Resources.Add;
  			this.butAdd.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  			this.butAdd.Location = new System.Drawing.Point(3,216);
  			this.butAdd.Name = "butAdd";
  			this.butAdd.Size = new System.Drawing.Size(75,26);
  			this.butAdd.TabIndex = 13;
  			this.butAdd.Text = "Add";
  			this.butAdd.Click += new System.EventHandler(this.butAdd_Click);
  			// 
  			// gridMain
  			// 
  			this.gridMain.HScrollVisible = false;
  			this.gridMain.Location = new System.Drawing.Point(3,10);
  			this.gridMain.Name = "gridMain";
  			this.gridMain.ScrollValue = 0;
  			this.gridMain.Size = new System.Drawing.Size(490,199);
  			this.gridMain.TabIndex = 2;
  			this.gridMain.Title = "Splits";
  			this.gridMain.TranslationName = "TableTransSplits";
  			this.gridMain.CellDoubleClick += new OpenDental.UI.ODGridClickEventHandler(this.gridMain_CellDoubleClick);
  			// 
  			// groupBox1
  			// 
  			this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  			this.groupBox1.Controls.Add(this.label9);
  			this.groupBox1.Controls.Add(this.label8);
  			this.groupBox1.Controls.Add(this.textSourcePay);
  			this.groupBox1.Controls.Add(this.butAttachPay);
  			this.groupBox1.Controls.Add(this.textSourceDeposit);
  			this.groupBox1.Controls.Add(this.butAttachDep);
  			this.groupBox1.Location = new System.Drawing.Point(119,367);
  			this.groupBox1.Name = "groupBox1";
  			this.groupBox1.Size = new System.Drawing.Size(416,80);
  			this.groupBox1.TabIndex = 18;
  			this.groupBox1.TabStop = false;
  			this.groupBox1.Text = "Source Documents";
  			// 
  			// label9
  			// 
  			this.label9.Location = new System.Drawing.Point(6,48);
  			this.label9.Name = "label9";
  			this.label9.Size = new System.Drawing.Size(87,20);
  			this.label9.TabIndex = 12;
  			this.label9.Text = "Payment";
  			this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  			// 
  			// label8
  			// 
  			this.label8.Location = new System.Drawing.Point(6,19);
  			this.label8.Name = "label8";
  			this.label8.Size = new System.Drawing.Size(87,20);
  			this.label8.TabIndex = 11;
  			this.label8.Text = "Deposit";
  			this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  			// 
  			// textSourcePay
  			// 
  			this.textSourcePay.Location = new System.Drawing.Point(95,49);
  			this.textSourcePay.Multiline = true;
  			this.textSourcePay.Name = "textSourcePay";
  			this.textSourcePay.ReadOnly = true;
  			this.textSourcePay.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
  			this.textSourcePay.Size = new System.Drawing.Size(231,20);
  			this.textSourcePay.TabIndex = 10;
  			// 
  			// butAttachPay
  			// 
  			this.butAttachPay.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butAttachPay.Autosize = true;
  			this.butAttachPay.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butAttachPay.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butAttachPay.CornerRadius = 4F;
  			this.butAttachPay.Location = new System.Drawing.Point(329,46);
  			this.butAttachPay.Name = "butAttachPay";
  			this.butAttachPay.Size = new System.Drawing.Size(80,26);
  			this.butAttachPay.TabIndex = 9;
  			this.butAttachPay.Text = "Attach";
  			this.butAttachPay.Click += new System.EventHandler(this.butAttachPay_Click);
  			// 
  			// textSourceDeposit
  			// 
  			this.textSourceDeposit.Location = new System.Drawing.Point(95,20);
  			this.textSourceDeposit.Name = "textSourceDeposit";
  			this.textSourceDeposit.ReadOnly = true;
  			this.textSourceDeposit.Size = new System.Drawing.Size(231,20);
  			this.textSourceDeposit.TabIndex = 8;
  			// 
  			// butAttachDep
  			// 
  			this.butAttachDep.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butAttachDep.Autosize = true;
  			this.butAttachDep.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butAttachDep.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butAttachDep.CornerRadius = 4F;
  			this.butAttachDep.Location = new System.Drawing.Point(329,17);
  			this.butAttachDep.Name = "butAttachDep";
  			this.butAttachDep.Size = new System.Drawing.Size(80,26);
  			this.butAttachDep.TabIndex = 7;
  			this.butAttachDep.Text = "Attach";
  			this.butAttachDep.Click += new System.EventHandler(this.butAttachDep_Click);
  			// 
  			// butDelete
  			// 
  			this.butDelete.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  			this.butDelete.Autosize = true;
  			this.butDelete.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butDelete.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butDelete.CornerRadius = 4F;
  			this.butDelete.Image = global::OpenDental.Properties.Resources.deleteX;
  			this.butDelete.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  			this.butDelete.Location = new System.Drawing.Point(31,414);
  			this.butDelete.Name = "butDelete";
  			this.butDelete.Size = new System.Drawing.Size(75,26);
  			this.butDelete.TabIndex = 8;
  			this.butDelete.Text = "Delete";
  			this.butDelete.Click += new System.EventHandler(this.butDelete_Click);
  			// 
  			// textDate
  			// 
  			this.textDate.Location = new System.Drawing.Point(132,31);
  			this.textDate.Name = "textDate";
  			this.textDate.Size = new System.Drawing.Size(100,20);
  			this.textDate.TabIndex = 3;
  			// 
  			// butOK
  			// 
  			this.butOK.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  			this.butOK.Autosize = true;
  			this.butOK.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butOK.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butOK.CornerRadius = 4F;
  			this.butOK.Location = new System.Drawing.Point(568,384);
  			this.butOK.Name = "butOK";
  
gt: 			this.butOK.Size = new System.Drawing.Size(75,26);