/*********************************************************************************************
 * Copyright 2004 - Volian Enterprises, Inc. All rights reserved.
 * Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
 * ------------------------------------------------------------------------------
 * $Workfile: ProcedureSelectionList.cs $     $Revision: 1 $
 * $Author: Kathy $   $Date: 7/27/04 8:39a $
 *
 * $History: ProcedureSelectionList.cs $
 * 
 * *****************  Version 1  *****************
 * User: Kathy        Date: 7/27/04    Time: 8:39a
 * Created in $/LibSource/VDB
 *********************************************************************************************/
using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows.Forms;
using System.Text;
using VDB;
namespace VDB_Set
{
	/// 
	/// Summary description for ProcedureSelectionList.
	/// 
	public class ProcedureSelectionList : System.Windows.Forms.Form
	{
		private System.Windows.Forms.CheckedListBox checkedListBox1;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancel;
		/// 
		/// Required designer variable.
		/// 
		private System.ComponentModel.Container components = null;
		public ProcedureSelectionList()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			// Changes the selection mode from double-click to single click.
			checkedListBox1.CheckOnClick = true;
		}
		public void Add(DataRow rw)
		{
			SetRecordObj SetRec = new SetRecordObj(rw);
			checkedListBox1.Items.Add(SetRec);
		}
		/// 
		/// Clean up any resources being used.
		/// 
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#region Windows Form Designer generated code
		/// 
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// 
		private void InitializeComponent()
		{
			this.checkedListBox1 = new System.Windows.Forms.CheckedListBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// checkedListBox1
			// 
			this.checkedListBox1.Location = new System.Drawing.Point(16, 8);
			this.checkedListBox1.Name = "checkedListBox1";
			this.checkedListBox1.Size = new System.Drawing.Size(528, 274);
			this.checkedListBox1.TabIndex = 0;
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(136, 296);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(80, 32);
			this.btnOK.TabIndex = 1;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.Location = new System.Drawing.Point(272, 296);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(96, 32);
			this.btnCancel.TabIndex = 2;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// ProcedureSelectionList
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(560, 342);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.checkedListBox1);
			this.Name = "ProcedureSelectionList";
			this.Text = "Select Procedures";
			this.Load += new System.EventHandler(this.ProcedureSelectionList_Load);
			this.ResumeLayout(false);
		}
		#endregion
		private void ProcedureSelectionList_Load(object sender, System.EventArgs e)
		{
		
		}
		public StringCollection GetListOfSelectedProcs_Files()
		{
			StringCollection RtnStrings = new StringCollection();
			for (int i=0; i< checkedListBox1.CheckedItems.Count; i++)
			{
				SetRecordObj tmpObj = (SetRecordObj)checkedListBox1.CheckedItems[i];
				RtnStrings.Add(tmpObj.DatabaseTable);
			}
			return RtnStrings;
		}
		private void btnOK_Click(object sender, System.EventArgs e)
		{
			DialogResult=DialogResult.OK;
			this.Close();
		}
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			DialogResult=DialogResult.Cancel;
			this.Close();
		}
	}
	public class SetRecordObj
	{
		public string ProcTitle;
		public string ProcNumber;
		public string RECID;
		public string DatabaseTable;
		public string Format;
		public string ApprvDate;
		public string ApprvTime;
		public string Initials;
		public DataRow ProcSetRow;
		public SetRecordObj(DataRow Rw)
		{
			ProcSetRow = Rw;
			ProcTitle = ProcSetRow.ItemArray[0].ToString();
			ProcNumber = ProcSetRow.ItemArray[1].ToString();
			Format = ProcSetRow.ItemArray[2].ToString();
			DatabaseTable = ProcSetRow.ItemArray[4].ToString();
			RECID = ProcSetRow.ItemArray[5].ToString();
			ApprvDate = ProcSetRow.ItemArray[7].ToString();
			ApprvTime = ProcSetRow.ItemArray[8].ToString();
			Initials = ProcSetRow.ItemArray[9].ToString();
		}
		public override string ToString()
		{
			StringBuilder rtnStr = new StringBuilder();
			
			rtnStr.Append(ProcNumber);
			rtnStr.Append(" ");
			rtnStr.Append(ProcTitle);
			return rtnStr.ToString();
		}
	}
}