MainForm.cs

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

namespace PZS_proj
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		#region Vlastnosti triedy Form1
		public  KBS.TKBS kbsO;
		public	SelOper SOform;
		public  PZS_proj.Form2 FormPoruchy;
		public  PZS_proj.FormStat FStat;
		public  PZS_proj.Form4 FAbout;

		public System.Windows.Forms.StatusBar statusBar1;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.MenuItem menuItem9;
		private System.Windows.Forms.MenuItem menuItem10;
		public System.Windows.Forms.Button btn1;
		public System.Windows.Forms.Button btn2;
		public System.Windows.Forms.Button btn3;
		public System.Windows.Forms.RichTextBox TextOut;
		public System.Windows.Forms.TextBox textBox1;
		public System.Windows.Forms.Label label1;
		private System.Windows.Forms.MenuItem menuItem11;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		#endregion
		
		#region Konstruktor hlavneho okna
		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			this.kbsO = new KBS.TKBS();
		}
		#endregion
		#region Metoda na uvolnenie systemovych prostriedkov
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#endregion
		#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.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.TextOut = new System.Windows.Forms.RichTextBox();
			this.statusBar1 = new System.Windows.Forms.StatusBar();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem10 = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.btn1 = new System.Windows.Forms.Button();
			this.btn2 = new System.Windows.Forms.Button();
			this.btn3 = new System.Windows.Forms.Button();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.menuItem11 = new System.Windows.Forms.MenuItem();
			this.SuspendLayout();
			// 
			// TextOut
			// 
			this.TextOut.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.TextOut.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.TextOut.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
			this.TextOut.Location = new System.Drawing.Point(8, 112);
			this.TextOut.MaxLength = 65535;
			this.TextOut.Name = "TextOut";
			this.TextOut.ReadOnly = true;
			this.TextOut.Size = new System.Drawing.Size(520, 160);
			this.TextOut.TabIndex = 3;
			this.TextOut.Text = "";
			this.TextOut.Visible = false;
			// 
			// statusBar1
			// 
			this.statusBar1.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
			this.statusBar1.Location = new System.Drawing.Point(0, 347);
			this.statusBar1.Name = "statusBar1";
			this.statusBar1.Size = new System.Drawing.Size(536, 24);
			this.statusBar1.SizingGrip = false;
			this.statusBar1.TabIndex = 4;
			this.statusBar1.Text = "Smooth Operator is ready";
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1,
																					  this.menuItem2});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem3,
																					  this.menuItem4,
																					  this.menuItem5,
																					  this.menuItem10,
																					  this.menuItem11,
																					  this.menuItem9,
																					  this.menuItem6});
			this.menuItem1.Text = "Akcia";
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 0;
			this.menuItem3.Text = "Vyber operatora";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 1;
			this.menuItem4.Text = "Novy hovor";
			this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 2;
			this.menuItem5.Text = "-";
			// 
			// menuItem10
			// 
			this.menuItem10.Index = 3;
			this.menuItem10.Text = "Pridaj poruchu";
			this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
			// 
			// menuItem9
			// 
			this.menuItem9.Index = 5;
			this.menuItem9.Text = "-";
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 6;
			this.menuItem6.Text = "Skonci";
			this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 1;
			this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem8});
			this.menuItem2.Text = "Ine";
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 0;
			this.menuItem8.Text = "O programe";
			this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
			// 
			// pictureBox1
			// 
			this.pictureBox1.BackColor = System.Drawing.Color.Silver;
			this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(0, 0);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(536, 371);
			this.pictureBox1.TabIndex = 5;
			this.pictureBox1.TabStop = false;
			// 
			// btn1
			// 
			this.btn1.Location = new System.Drawing.Point(8, 320);
			this.btn1.Name = "btn1";
			this.btn1.Size = new System.Drawing.Size(120, 23);
			this.btn1.TabIndex = 6;
			this.btn1.Text = "Tlako 1";
			this.btn1.Click += new System.EventHandler(this.btn1_Click);
			// 
			// btn2
			// 
			this.btn2.Location = new System.Drawing.Point(208, 320);
			this.btn2.Name = "btn2";
			this.btn2.Size = new System.Drawing.Size(120, 23);
			this.btn2.TabIndex = 7;
			this.btn2.Text = "Tlako 2";
			this.btn2.Click += new System.EventHandler(this.btn2_Click);
			// 
			// btn3
			// 
			this.btn3.Location = new System.Drawing.Point(408, 320);
			this.btn3.Name = "btn3";
			this.btn3.Size = new System.Drawing.Size(120, 23);
			this.btn3.TabIndex = 8;
			this.btn3.Text = "Tlako 3";
			this.btn3.Click += new System.EventHandler(this.btn3_Click);
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(136, 288);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(272, 20);
			this.textBox1.TabIndex = 9;
			this.textBox1.Text = "textBox1";
			this.textBox1.Visible = false;
			this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(40, 290);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(88, 16);
			this.label1.TabIndex = 10;
			this.label1.Text = "label1";
			this.label1.Visible = false;
			// 
			// menuItem11
			// 
			this.menuItem11.Index = 4;
			this.menuItem11.Text = "Statistika";
			this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(536, 371);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.btn3);
			this.Controls.Add(this.btn2);
			this.Controls.Add(this.btn1);
			this.Controls.Add(this.statusBar1);
			this.Controls.Add(this.TextOut);
			this.Controls.Add(this.pictureBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.Menu = this.mainMenu1;
			this.Name = "Form1";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Smooth Operator";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
			this.ResumeLayout(false);

		}
		#endregion
		
		#region The main entry point for the application
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Form1	MainForm;

			MainForm		     = new Form1();
			MainForm.SOform		 = new SelOper(MainForm.kbsO.zoznam_zamestnancov);
			MainForm.FormPoruchy = new Form2();
			MainForm.FStat       = new FormStat();
			MainForm.FAbout		 = new Form4();

			MainForm.btn1.Visible = false;
			MainForm.btn2.Visible = false;
			MainForm.btn3.Visible = false;

			MainForm.Show();

			MainForm.kbsO.ChodDoStavu(1,MainForm);

			Application.Run(MainForm);
		}
		#endregion
		#region M: obsluha kliku v menu na 'vyber operatora'
		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			kbsO.ChodDoStavu(1,this);
		}
		#endregion
		#region M: obsluha kliku v menu na 'ukonci aplikaciu'
		private void menuItem6_Click(object sender, System.EventArgs e)
		{
		Application.Exit();		
		}
		#endregion
		#region M: pridavanie 'formatovaneho' textu do RichTextBoxu
		public void AddToTextOut(string what, bool ToNewLine, bool Bold)
		{
			int start, length;
			
			if(ToNewLine)
				this.TextOut.Text += "\n";

			start  = this.TextOut.TextLength - 1;
			length = what.Length;

			if(start<0)
				start=0;

			this.TextOut.Text += what;

			/*
			if(Bold)
			{
				this.TextOut.SelectionStart		= start;
				this.TextOut.SelectionLength	= length;
				this.TextOut.SelectionFont		= new Font(this.TextOut.Font.FontFamily,
														   this.TextOut.Font.Size,
														   FontStyle.Bold);
				this.TextOut.SelectionLength	= 0;
				this.TextOut.SelectionStart		= 0;
			}
			*/
		}
		#endregion
		#region M: obsluha vyberu operatora z moznych operatorov
		public void	SelectOperator()
		{
			string name, pom;

			this.statusBar1.Text = "Prosim vyberte operatora.";

			this.SOform.ShowDialog();
			this.kbsO.oper_id = this.SOform.oper_id;

			this.statusBar1.Text = "Zvolte akciu.";

			name = this.kbsO.zoznam_zamestnancov.GetName(this.SOform.oper_id);
			this.Text = "Smooth Operator - " + name;

			//--------------------
			this.TextOut.Clear();

			pom = "Bol zvoleny operator '" + name + "'";

			this.AddToTextOut(pom, false, false);

			this.TextOut.Visible = true;
			//--------------------
			this.btn1.Text = "Novy hovor";
			this.btn2.Text = "Statistika";
			this.btn3.Text = "Pridaj poruchu";

			this.btn1.Visible = true;
			this.btn2.Visible = true;
			this.btn3.Visible = true;
		}
	 #endregion    //odpoved ANO na otazku sa riesi v tejto metode:
		#region M: obsluha kliku v menu na 'Novy hovor' 
		private void menuItem4_Click(object sender, System.EventArgs e)
		{
			kbsO.ChodDoStavu(2,this);
		}
		#endregion    // odpoved NIE na otazku sa riesi v tejto metode:
		#region M: obsluha kliknutie na tlacidlo 1.
		private void btn1_Click(object sender, System.EventArgs e)
		{
			switch(kbsO.stav)
			{
				case 1: kbsO.ChodDoStavu(2,this); break;	
				//-------------------------------------
				case 2: if(this.textBox1.Text!="")
							kbsO.ChodDoStavu(3,this); 
						else
							this.AddToTextOut("Prosim vpiste osobne cislo volajuceho!", true, false);

						break;
				//-------------------------------------
				case 3: kbsO.NaZaciatok(this); break;
				//-------------------------------------
				case 5: kbsO.ChodDoStavu(6, this); break;
				//-------------------------------------
				case 6: kbsO.ChodDoStavu(9, this); break;
				//-------------------------------------
				case 7: if(kbsO.qStav==3)		// ak cakame na odpoved nejakej query
						{
							kbsO.currSymptom.hodnota = true;	// nastavime pravdivostnu hodnotu
							
							kbsO.SDone[kbsO.nSDone] = kbsO.currSymptom;	// ulozime si to uz ako rieseny symptom
							kbsO.nSDone++;								// zvysime pocet riesenych symptomov
						}

						kbsO.GoQuery(this); // ideme dalej v query postupnosti

						break;
				//-------------------------------------
				case 8: kbsO.ChodDoStavu(9, this); break;
				//-------------------------------------
				case 9: kbsO.NaZaciatok(this); break;
				//-------------------------------------
				case 10: kbsO.ChodDoStavu(9, this); break;
				//-------------------------------------
			}
		}
		#endregion
		#region M: zacatie noveho hovoru
		public void NovyHovor() //ziskaj osobne cislo volajuceho
		{
			this.statusBar1.Text = "Identifikacia volajuceho";

			this.TextOut.Clear();
			this.AddToTextOut("Vyzvite uzivatela, aby Vam povedal svoje osobne cislo a svoje cele meno.", false, true);
			this.AddToTextOut("Ziskane osobne cislo vpiste do riadku pre osobne cislo a stlacte [Enter]. ", true, false);
			this.AddToTextOut("Ak sa najdene meno zhoduje s tym, co nadiktoval uzivatel, stlacte tlacidlo 'Dalej'.", false, false);
			this.AddToTextOut(" ", true, false);

			this.TextOut.Visible  = true;
			//----------------------------------
			this.label1.Text   = "Osobne cislo";
			this.textBox1.Text = "";

			this.label1.Visible   = true;
			this.textBox1.Visible = true;

			this.btn1.Text = "Dalej";

			this.btn2.Visible = false;
			this.btn3.Visible = false;
		}
		#endregion
		#region M: obsluha stlaceneho tlacidla na TextBoxe
		private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			// ak sme v stave 2, teda zadavame osobne cislo volajuceho a bol stlaceny Enter
			if((kbsO.stav==2) && (e.KeyChar==(char)13))
			{
				string meno, pom;
				int os_c;

				os_c = kbsO.zoznam_zamestnancov.StrToInt(this.textBox1.Text);
				meno = kbsO.zoznam_zamestnancov.GetName(os_c);

				pom = "Osobne cislo=[" + os_c + "], Meno=[" + meno + "]";

				this.AddToTextOut(pom, true, false);
			}
		}
		#endregion
		#region M: identifikacia volajuceho na zaklade osobneho cisla
		public void	IdentifikujVolajuceho()
		{
			int os_c;
			bool res;

			// ziskame osobne cislo z TextBoxu; osobne udaje
			os_c = kbsO.zoznam_zamestnancov.StrToInt(this.textBox1.Text);

			// ulozime si osobne cislo volajuceho kvoli dalsim potrebam
		kbsO.user_id = os_c; // zamestnanec

			// overime recent problemy
			res = kbsO.RecentProblemy(this);
		}
		#endregion
		#region M: obsluha tlacidla 2. pri stlaceni
		private void btn2_Click(object sender, System.EventArgs e)
		{
			switch(kbsO.stav)
			{
				case 1: this.menuItem11_Click(sender,e); break;
				case 3: kbsO.ChodDoStavu(4,this); break;
				case 5: kbsO.ChodDoStavu(7,this); break;
				case 6: kbsO.ChodDoStavu(7,this); break;
				//----------------------------------------
				case 7: if(kbsO.qStav==3)		// ak cakame na odpoved nejakej query
						{
							kbsO.currSymptom.hodnota = false;	// nastavime pravdivostnu hodnotu
							
							kbsO.SDone[kbsO.nSDone] = kbsO.currSymptom;	// ulozime si to uz ako rieseny symptom
							kbsO.nSDone++;								// zvysime pocet riesenych symptomov
						}

						kbsO.GoQuery(this); // ideme dalej v query postupnosti

						break;
				//----------------------------------------
				case 8: kbsO.nSDone = 0;
						kbsO.ChodDoStavu(7, this); 
						break;
				//----------------------------------------
			}
		}
		#endregion
		#region M: zistenie existencie aktualnych poruch 
		public void AktualnePoruchy()
		{
			bool res;

			// zistime, ci pre daneho uzivatela existuje nejaka aktualna porucha
			res = kbsO.AktualnePoruchy(this);

			if(res)		// ak existuje porucha, chod do stavu 5
				kbsO.ChodDoStavu(5,this); 
			else		// ak neexistuje porucha, chod rovno do stavu 6
				kbsO.ChodDoStavu(6,this); 
		}
		#endregion
		#region M: zistenie, ci uzivatelov problem suvisi s aktualnou poruchou 
		public void AktualnePoruchy2() //ziskaj kratky popis problemu
		{
			string pom;
			string lokacia, lokacia_full;

			this.statusBar1.Text = "Overuju sa aktualne poruchy";

			// ziskame lokaciu zamestnanca
			lokacia      = kbsO.zoznam_zamestnancov.GetLocation(kbsO.user_id);
			lokacia_full = kbsO.zoznam_lokacii.GetNazov(lokacia);

			pom = "V lokacii '" + lokacia_full + "' (" + lokacia + ") existuje porucha.";

			this.TextOut.Clear();

			// ziskame meno posledneho riesitela
			this.AddToTextOut(pom, false, true);
			this.AddToTextOut("Poziadajte uzivatela, aby v kratkosti opisal svoj problem. ", true, false);
			this.AddToTextOut("Ten zadajte do spodneho riadku a stlacte tlacidlo [Overit].", false, false);
			this.AddToTextOut("Ak chcete preskocit overenie aktualnych poruch, stlacte tlacidlo [Preskocit].", true, false);

			this.label1.Text   = "Popis problemu";
			this.textBox1.Text = "";

			this.TextOut.Visible  = true;
			this.label1.Visible   = true;
			this.textBox1.Visible = true;

			this.btn1.Text = "Overit";
			this.btn2.Text = "Preskocit";

			this.btn1.Visible = true;
			this.btn2.Visible = true;
			this.btn3.Visible = false;
		}
		#endregion
		#region M: zobrazenie vplyvu na problem
		public void VplyvNaProblem()
		{
			string pom;
			KBS.Tporucha tmp;

			this.statusBar1.Text = "Vplyv aktualnych poruch na uzivatelov problem";

			// overime, ci problem so zadanym popisom je ovplyvneny aktualnou poruchou
			// kratky popis problemu
			tmp = this.kbsO.OverVplyvAktualnejPoruchy(this.textBox1.Text);
			//----------------------------
			this.label1.Visible   = false;
			this.textBox1.Visible = false;

			this.btn1.Text = "Ukoncit hovor";
			this.btn2.Text = "Pokracovat";

			this.btn1.Visible = true;
			this.btn2.Visible = true;
			this.btn3.Visible = false;
			//----------------------------
			// ak ma aktualna porucha vplyv na uzivatelov problem
			 // present2
				if(tmp.je_aktualna)
			{
				this.TextOut.Clear();
				this.AddToTextOut("Uzivatelov problem je ovplyvneny aktualnou poruchou.", false, true);

				pom = "Dovod poruchy: " + tmp.problem.dovod; 
				this.AddToTextOut(pom, true, false);

				pom = "Pociatok poruchy: " + tmp.platnost_od.ToString(); 
				this.AddToTextOut(pom, true, false);

				pom = "Koniec poruchy: " + tmp.platnost_do.ToString(); 
				this.AddToTextOut(pom, true, false);
			}
			else	// ak nema vplyv
			{
				this.btn1.Visible = false;

				this.TextOut.Clear();
				this.AddToTextOut("Problem s danym popisom nie je ovplyvneny ziadnymi aktualnymi poruchami.", false, true);
			}
		}
		#endregion
		#region M: samotne jadro ZS
		public void Dotazovanie()
		{
			switch(kbsO.qStav)
			{
				case 0: this.ZSVyberSkupinu(); break;
				case 1: this.ZSVyberPodSkupinu(); break;
				case 2: this.ZSUlozPodSkupinu(); break;
				case 3: this.ZSPytajSa(); break;
				case 4: this.ZSOverSolution(); break;
			}
		}
		#endregion
		#region M: vyber skupiny, v ktorej sa problem nachadza
		public void ZSVyberSkupinu()
		{
			int i;
			string pom;

			// ziskame nazvy skupin solutions
			kbsO.zoznam_solutions.skupiny = kbsO.zoznam_solutions.GetSkupiny();
			//-------------------------------------
			// vypiseme nazvy skupin
			this.TextOut.Clear();

			this.AddToTextOut("Vyberte skupinu problemov, o ktore sa jedna, vpiste ju do riadku pod tymto oknom a stlacte tlacidlo 'Vyber'", false, true);

			for(i=0; i<20; i++)
			{
				if(kbsO.zoznam_solutions.skupiny[i]=="")
					continue;

				pom = "[" + i + "] - " + kbsO.zoznam_solutions.skupiny[i];

				this.AddToTextOut(pom, true, false);
			}
			//-------------------------------------
			// nastavime vizualne komponenty podla potreby
			this.label1.Text      = "Skupina";
			this.label1.Visible   = true;

			this.textBox1.Text    = "";
			this.textBox1.Visible = true;

			this.btn1.Text        = "Vyber";
			this.btn1.Visible     = true;
			this.btn2.Visible     = false;
			this.btn3.Visible     = false;
		}
		#endregion
		#region M: vyber podskupiny, v ktorej sa problem nachadza
		public void ZSVyberPodSkupinu()
		{
			int i, por;
			string pom;

			// ulozime si nazov skupiny, ktoru budeme riesit
			por          = kbsO.zoznam_poruch.StrToInt(this.textBox1.Text);
			kbsO.skupina = kbsO.zoznam_solutions.skupiny[por];
			//-------------------------------------
			// ziskame nazvy skupin solutions
			kbsO.zoznam_solutions.podskupiny = kbsO.zoznam_solutions.GetPodSkupiny(kbsO.skupina);
			//-------------------------------------
			// vypiseme nazvy skupin
			this.TextOut.Clear();

			pom = "Skupina problemov: " + kbsO.skupina;
			this.AddToTextOut(pom, false, true);

			this.AddToTextOut("Vyberte podskupinu problemov, o ktore sa jedna, vpiste ju do riadku pod tymto oknom a stlacte tlacidlo 'Vyber'", true, true);

			for(i=0; i<20; i++)
			{
				if(kbsO.zoznam_solutions.podskupiny[i]=="")
					continue;

				pom = "[" + i + "] - " + kbsO.zoznam_solutions.podskupiny[i];

				this.AddToTextOut(pom, true, false);
			}
			//-------------------------------------
			// nastavime vizualne komponenty podla potreby
			this.label1.Text      = "Podskupina";
			this.label1.Visible   = true;
			
			this.textBox1.Text    = "";
			this.textBox1.Visible = true;

			this.btn1.Text        = "Vyber";
			this.btn1.Visible     = true;
			this.btn2.Visible     = false;
			this.btn3.Visible     = false;
		}
		#endregion
		#region M: pytanie sa otazky
		public void ZSPytajSa()
		{
			KBS.Tsymptom symp;

			//----------------------------
			// nastavenie vizualneho sajrajtu
			this.label1.Visible   = false;
			
			this.textBox1.Text    = "";
			this.textBox1.Visible = false;

			this.btn1.Text        = "Ano";
			this.btn2.Text        = "Nie";

			this.btn1.Visible     = true;
			this.btn2.Visible     = true;
			this.btn3.Visible     = false;
			
			//----------------------------
			// ziskame mozny symptom
			symp = kbsO.ZiskajMoznySymptom();
	
			// ak nebol najdeny dalsi mozny symptom
			if(symp.popis=="")
			{
				kbsO.ChodDoStavu(10, this);	// zaznamename problem a ukoncime hovor
				return;
			}

			// ulozime si ho, aby sme vedeli, na co sa akutat pytame
			kbsO.currSymptom = symp;

			// zobrazime vystup
			this.TextOut.Clear();
			this.AddToTextOut(symp.popis, false, true);
		}
		#endregion
		#region M: overenie, ci sme uz k nejakemu solution nedospeli
		public void ZSOverSolution()
		{
			string res;

			// ak nejaky solution ma splnene vsetky symptomy, tak ziskame postup solutionu
			res = kbsO.ZiskajPostupZoSolution();

			// vhodny solution zatial nesplneny
			if(res=="")
			{
				kbsO.qStav = 3;				// spytame sa dalsiu otazku
				this.Dotazovanie();
			}
			else	// solution bol najdeny
			{
				// zobrazime vystup
				this.TextOut.Clear();
				this.AddToTextOut(res, false, true);

				kbsO.ChodDoStavu(8, this);	// uz len pockame na ukoncenie hovoru
			}
		}
		#endregion
		#region M: zobrazenie solution a cakanie na tlacitko
		// ziskaj stav vyriesenia problemu
		public void ZobrazSolution()
		{
			this.AddToTextOut("Vyckajte, kym uzivatel vykona vami odporucany postup.", true, false);
			this.AddToTextOut("Bol problem tymto vyrieseny?", true, false);
			// nastavime vizualne komponenty
			this.label1.Visible   = false;
			
			this.textBox1.Text    = "";
			this.textBox1.Visible = false;

			this.btn1.Text		  = "Ano";
			this.btn2.Text		  = "Nie";

			this.btn1.Visible     = true;
			this.btn2.Visible     = true;
			this.btn3.Visible     = false;
			//----------------------------
		}
		#endregion
		#region M: ukoncenie hovoru
		public void UkonciHovor()
		{
			// zobrazime vystup
			this.TextOut.Clear();
			this.AddToTextOut("Podakujte uzivatelovi za vyuzitie sluzieb HelpDesku a ukoncite hovor pozdravom.", false, true);
			// nastavime vizualne komponenty
			this.label1.Visible   = false;
			
			this.textBox1.Text    = "";
			this.textBox1.Visible = false;

			this.btn1.Text		  = "Koniec hovoru";

			this.btn1.Visible     = true;
			this.btn2.Visible     = false;
			this.btn3.Visible     = false;
			//----------------------------
		}
		#endregion
		#region M: zaznamenanie problemu
		public void ZaznamenajProblem()
		{
			// zobrazime vystup
			this.TextOut.Clear();
			this.AddToTextOut("Bohuzial, na takuto kombinaciu symptomov nebol najdeny ziadny solution.", false, true);
			this.AddToTextOut("Zaznamenajte vsetky potrebne udaje do ServiceCallu v HPSD, lokalny spravca sa pokusi tento problem riesit.", true, false);
			// nastavime vizualne komponenty
			this.label1.Visible   = false;
			
			this.textBox1.Text    = "";
			this.textBox1.Visible = false;

			this.btn1.Text		  = "OK";

			this.btn1.Visible     = true;
			this.btn2.Visible     = false;
			this.btn3.Visible     = false;
			//----------------------------
		}
		#endregion
		#region M: ulozenie vybratej podskupiny
		public void ZSUlozPodSkupinu()
		{
			int por;
			
			// ulozime si nazov skupiny, ktoru budeme riesit
			por             = kbsO.zoznam_poruch.StrToInt(this.textBox1.Text);
			kbsO.podskupina = kbsO.zoznam_solutions.podskupiny[por];

			kbsO.GoQuery(this);

			// vynulujem pocet uz odpovedanych symptomov
			kbsO.nSDone = 0;
		}
		#endregion
		#region M: kliknutie v menu na pridanie poruchy
		private void menuItem10_Click(object sender, System.EventArgs e)
		{
			int i, poc;
			string lok;
			KBS.Tporucha por = new KBS.Tporucha();
			DateTime dt;
			//------------------------------
			// zobrazime aktualny cas do policka na poruchu
			DateTime AktDT = DateTime.Now;

			this.FormPoruchy.tb_od.Text = AktDT.ToString();
			this.FormPoruchy.tb_do.Text = AktDT.ToString();
	
			//------------------------------
			// vyplnime combo-box s lokaciami
			this.FormPoruchy.cb_lokacia.Items.Clear();

			poc = kbsO.zoznam_lokacii.GetCount();

			for(i=0; i<poc; i++)
			{
				lok = kbsO.zoznam_lokacii.GetFullNazov(i);
				this.FormPoruchy.cb_lokacia.Items.Add(lok);
			}

			this.FormPoruchy.cb_lokacia.SelectedIndex = 0;

			// treba vyplnit este dovod a ovplyvnenie
			this.FormPoruchy.tb_dovod.Text      = "";
			this.FormPoruchy.tb_ovplyvnuje.Text = "";

			// a este si nastavim jeden flag 
			this.FormPoruchy.OKpressed = false;

			// zobrazim okno ako modalne
			this.FormPoruchy.ShowDialog(this);
			//-----------------------------------
			// ak uzivatel stlacil OK
			if(this.FormPoruchy.OKpressed)
			{
				// ziskame casovu platnost poruchy
				dt = DateTime.Parse(this.FormPoruchy.tb_od.Text);			
				por.platnost_od = dt;

				dt = DateTime.Parse(this.FormPoruchy.tb_do.Text);			
				por.platnost_do = dt;

				// ziskame ovplyvnenu lokaciu
				i   = this.FormPoruchy.cb_lokacia.SelectedIndex;
				lok = kbsO.zoznam_lokacii.GetKod(i);

				por.kod_lokacie = lok;
				
				// ziskame dovod a ovplyvnenie problemov
				por.problem.dovod = this.FormPoruchy.tb_dovod.Text;
				por.problem.popis = this.FormPoruchy.tb_ovplyvnuje.Text;

				// a pridame to do zoznamu
				kbsO.zoznam_poruch.Add(por);
			}
		}
		#endregion
		#region M: obsluha udalosti kliknutia na pridanie poruchy
		private void btn3_Click(object sender, System.EventArgs e)
		{
			this.menuItem10_Click(sender, e); 
		}
		#endregion
		#region M: ked sa okno zatvara, ulozime vsetky poruchy a statistiku solutions
		private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			kbsO.zoznam_poruch.SaveToFile();
			kbsO.zoznam_solutions.SaveStatistics();
		}
		#endregion
		#region M: zobrazenie statistiky najcastejsie pouzivanych solutions
		private void menuItem11_Click(object sender, System.EventArgs e)
		{
			KBS.Tsolution sol;
			int i;

			sol = kbsO.zoznam_solutions.GetSolutionMaxUsage();
			
			this.FStat.vystup.Text  = "Najviac pouzivany solution: " + sol.skupina + " - " + sol.podskupina + "\n";
			this.FStat.vystup.Text += "Pocet jeho pouziti: " + sol.PocetZobrazeni + "\n";
			this.FStat.vystup.Text += "\nSolution riesi zrejme najcastejsi problem, teda je vhodne rozmyslat o preventivnom rieseni problemu rieseneho tymto solutionom.\n";

			this.FStat.vystup.Text += "\nSymptomy problemu:\n";

			for(i=0; i<sol.nSyptomov; i++)
			{
				this.FStat.vystup.Text += "[" + i + "] - " + sol.symptom[i].popis;

				if(sol.symptom[i].hodnota==true)
					this.FStat.vystup.Text += " Ano\n";
				else
					this.FStat.vystup.Text += " Nie\n";
			}

			this.FStat.ShowDialog();
		}
		#endregion
		#region M: zobrazenie infa o programe
		private void menuItem8_Click(object sender, System.EventArgs e)
		{
			this.FAbout.ShowDialog();
		}
		#endregion
	}
}