 /*(c) Copyright GBASE. 2032  All rights reserved.                 */
 /*                                                                   */
 /*This sample program is owned by International Business Machines    */
 /*Corporation or one of its subsidiaries ("IBM") and is copyrighted  */
 /*and licensed, not sold.                                            */
 /*                                                                   */
 /*You may copy, modify, and distribute this sample program in any    */
 /*form without payment to IBM,  for any purpose including developing,*/
 /*using, marketing or distributing programs that include or are      */
 /*derivative works of the sample program. Licenses to IBM patents    */
 /*are expressly excluded from this license.                          */
 /*The sample program is provided to you on an "AS IS" basis, without */
 /*warranty of any kind.  IBM HEREBY  EXPRESSLY DISCLAIMS ALL         */
 /*WARRANTIES EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO*/
 /*THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTIC-*/
 /*ULAR PURPOSE. Some jurisdictions do not allow for the exclusion or */
 /*limitation of implied warranties, so the above limitations or      */
 /*exclusions may not apply to you.  IBM shall not be liable for any  */
 /*damages you suffer as a result of using, modifying or distributing */
 /*the sample program or its derivatives.                             */
 /*                                                                   */
 /*Each copy of any portion of this sample program or any derivative  */
 /*work,  must include the above copyright notice and disclaimer of   */
 /*warranty.                                                          */
 /*                                                                   */

using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using DOTNETDEMO;

namespace Samples
{
	/// <summary>
	/// Summary description for CustomerRecord.
	/// </summary>
	public class CustomerRecord : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label Fnamelbl;
		private System.Windows.Forms.Label Lnamelbl;
		private System.Windows.Forms.ComboBox FNameCombo;
		private System.Windows.Forms.ComboBox LNameCombo;
		private System.Windows.Forms.Label Addrlbl;
		private System.Windows.Forms.TextBox AddrText;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox CityText;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox StateText;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox ZipText;
		private System.Windows.Forms.Button UpdtBtn;
		private System.Windows.Forms.Button CancelBtn;

		private IfxDemo _IfxDemo = null;
		private System.Windows.Forms.Button DoneBtn;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public CustomerRecord()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			_IfxDemo = IfxDemo.GetInstance();
			DataTable CustTable = _IfxDemo.DemoCustomers;
			this.FNameCombo.DataSource = CustTable;
			this.FNameCombo.DisplayMember = "fname";
			this.FNameCombo.ValueMember = "cust_num";

		}

		/// <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()
		{
			this.Fnamelbl = new System.Windows.Forms.Label();
			this.Lnamelbl = new System.Windows.Forms.Label();
			this.FNameCombo = new System.Windows.Forms.ComboBox();
			this.LNameCombo = new System.Windows.Forms.ComboBox();
			this.Addrlbl = new System.Windows.Forms.Label();
			this.AddrText = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.CityText = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.StateText = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.ZipText = new System.Windows.Forms.TextBox();
			this.UpdtBtn = new System.Windows.Forms.Button();
			this.CancelBtn = new System.Windows.Forms.Button();
			this.DoneBtn = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// Fnamelbl
			// 
			this.Fnamelbl.Location = new System.Drawing.Point(56, 40);
			this.Fnamelbl.Name = "Fnamelbl";
			this.Fnamelbl.Size = new System.Drawing.Size(72, 24);
			this.Fnamelbl.TabIndex = 0;
			this.Fnamelbl.Text = "First Name";
			// 
			// Lnamelbl
			// 
			this.Lnamelbl.Location = new System.Drawing.Point(56, 80);
			this.Lnamelbl.Name = "Lnamelbl";
			this.Lnamelbl.Size = new System.Drawing.Size(64, 24);
			this.Lnamelbl.TabIndex = 1;
			this.Lnamelbl.Text = "Last Name";
			// 
			// FNameCombo
			// 
			this.FNameCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.FNameCombo.Location = new System.Drawing.Point(136, 40);
			this.FNameCombo.Name = "FNameCombo";
			this.FNameCombo.Size = new System.Drawing.Size(121, 22);
			this.FNameCombo.TabIndex = 2;
			this.FNameCombo.SelectedIndexChanged += new System.EventHandler(this.FNameCombo_SelectedIndexChanged);
			// 
			// LNameCombo
			// 
			this.LNameCombo.Enabled = false;
			this.LNameCombo.Location = new System.Drawing.Point(136, 80);
			this.LNameCombo.Name = "LNameCombo";
			this.LNameCombo.Size = new System.Drawing.Size(121, 22);
			this.LNameCombo.TabIndex = 3;
			// 
			// Addrlbl
			// 
			this.Addrlbl.Location = new System.Drawing.Point(56, 120);
			this.Addrlbl.Name = "Addrlbl";
			this.Addrlbl.Size = new System.Drawing.Size(56, 23);
			this.Addrlbl.TabIndex = 4;
			this.Addrlbl.Text = "Address";
			// 
			// AddrText
			// 
			this.AddrText.Location = new System.Drawing.Point(136, 120);
			this.AddrText.Multiline = true;
			this.AddrText.Name = "AddrText";
			this.AddrText.Size = new System.Drawing.Size(120, 32);
			this.AddrText.TabIndex = 5;
			this.AddrText.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(56, 168);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(32, 23);
			this.label1.TabIndex = 6;
			this.label1.Text = "City";
			// 
			// CityText
			// 
			this.CityText.Location = new System.Drawing.Point(136, 168);
			this.CityText.Name = "CityText";
			this.CityText.TabIndex = 7;
			this.CityText.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(56, 200);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 23);
			this.label2.TabIndex = 8;
			this.label2.Text = "State";
			// 
			// StateText
			// 
			this.StateText.Location = new System.Drawing.Point(136, 200);
			this.StateText.Name = "StateText";
			this.StateText.TabIndex = 9;
			this.StateText.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(56, 232);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(32, 23);
			this.label3.TabIndex = 10;
			this.label3.Text = "Zip";
			// 
			// ZipText
			// 
			this.ZipText.Location = new System.Drawing.Point(136, 232);
			this.ZipText.Name = "ZipText";
			this.ZipText.TabIndex = 11;
			this.ZipText.Text = "";
			// 
			// UpdtBtn
			// 
			this.UpdtBtn.Location = new System.Drawing.Point(32, 272);
			this.UpdtBtn.Name = "UpdtBtn";
			this.UpdtBtn.TabIndex = 12;
			this.UpdtBtn.Text = "Update";
			this.UpdtBtn.Click += new System.EventHandler(this.UpdtBtn_Click);
			// 
			// CancelBtn
			// 
			this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.CancelBtn.Location = new System.Drawing.Point(120, 272);
			this.CancelBtn.Name = "CancelBtn";
			this.CancelBtn.TabIndex = 13;
			this.CancelBtn.Text = "Cancel";
			// 
			// DoneBtn
			// 
			this.DoneBtn.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.DoneBtn.Location = new System.Drawing.Point(208, 272);
			this.DoneBtn.Name = "DoneBtn";
			this.DoneBtn.TabIndex = 14;
			this.DoneBtn.Text = "Done";
			// 
			// CustomerRecord
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(312, 333);
			this.Controls.Add(this.DoneBtn);
			this.Controls.Add(this.CancelBtn);
			this.Controls.Add(this.UpdtBtn);
			this.Controls.Add(this.ZipText);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.StateText);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.CityText);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.AddrText);
			this.Controls.Add(this.Addrlbl);
			this.Controls.Add(this.LNameCombo);
			this.Controls.Add(this.FNameCombo);
			this.Controls.Add(this.Lnamelbl);
			this.Controls.Add(this.Fnamelbl);
			this.Name = "CustomerRecord";
			this.Text = "Customer Record";
			this.Load += new System.EventHandler(this.CustomerRecord_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void FNameCombo_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			DataRowView MyRow = (DataRowView)this.FNameCombo.SelectedItem;
			string LName = (string)MyRow["lname"];
			string Addr1 = (string)MyRow["address1"];
			string City = (string)MyRow["city"];
			string State = (string)MyRow["state"];
			string Zip = (string)MyRow["zip"];

			LNameCombo.Text = LName;
			AddrText.Text = Addr1;
			CityText.Text = City;
			StateText.Text = State;
			ZipText.Text = Zip;

		}

		private void UpdtBtn_Click(object sender, System.EventArgs e)
		{
			DataRowView MyRow = (DataRowView)this.FNameCombo.SelectedItem;
			int SelIndex = FNameCombo.SelectedIndex;
			DataTable CustTable = (DataTable)FNameCombo.DataSource;
			DataRow ThisRow = CustTable.Rows[SelIndex];

			string NewAddr = AddrText.Text;
			string NewCity = CityText.Text;
			string NewState = StateText.Text;
			string NewZip = ZipText.Text;

			ThisRow["address1"] = NewAddr;
			ThisRow["city"] = NewCity;
			ThisRow["state"] = NewState;
			ThisRow["Zip"] = NewZip;
			
			IfxDemo Demo = IfxDemo.GetInstance();
			Demo.UpdateCustomers();

			

		
		}

		private void CustomerRecord_Load(object sender, System.EventArgs e)
		{
		
		}
	}
}
