98 lines
3.1 KiB
C#
98 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mip
|
|
{
|
|
public partial class frmAddPomUdaje : Form
|
|
{
|
|
public frmAddPomUdaje()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void frmAddPomUdaje_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void frmAddPomUdaje_Shown(object sender, EventArgs e)
|
|
{
|
|
button1.Text = this.Text;
|
|
|
|
if (button1.Text == "Pridať krabicu")
|
|
{
|
|
string max;
|
|
string cmd = "SELECT MAX(`hodnota`) FROM `tabpomocnychudajov` WHERE `kategoria` = 'Pridať krabicu'";
|
|
classSQL.SQL(cmd, out max);
|
|
//Int32 maxKrabica = Convert.ToInt32(max);
|
|
this.Text = "Pridať krabicu (Číslo poslednej krabice: " + max + ")";
|
|
}
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
string strKategoria="", strHodnota;
|
|
|
|
/*switch (this.Text )
|
|
{
|
|
case "Pridať zákazníka":
|
|
strKategoria = "Zákazník";
|
|
break;
|
|
case "Pridať materiál":
|
|
strKategoria = "Materiál";
|
|
break;
|
|
case "Pridať úpravu materiálu":
|
|
strKategoria = "Úprava materiálu";
|
|
break;
|
|
case "Pridať iný názov":
|
|
strKategoria = "Iný názov";
|
|
break;
|
|
}
|
|
*/
|
|
strHodnota = textBox1.Text;
|
|
strKategoria = button1.Text;
|
|
|
|
DataTable tabkontrola = new DataTable();
|
|
string cmd = "SELECT * FROM `mip`.`tabpomocnychudajov` WHERE (`Kategoria` = '" + strKategoria + "' AND `Hodnota` = '" + strHodnota + "');";
|
|
classSQL.SQL(cmd, out tabkontrola);
|
|
|
|
if (tabkontrola.Rows.Count == 0)
|
|
{
|
|
cmd = "INSERT INTO `mip`.`tabpomocnychudajov` (`Kategoria`, `Hodnota`) VALUES ('" + strKategoria + "', '" + strHodnota + "')";
|
|
classSQL.SQL(cmd);
|
|
classGlobal.strNovyPomocnyUdaj = textBox1.Text;
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Zadaná hodnota v systeme už existuje!");
|
|
textBox1.Text = "";
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (button1.Text == "Pridať krabicu")
|
|
{
|
|
int intResult;
|
|
if (!(int.TryParse(textBox1.Text + e.KeyChar, out intResult)) && (int)e.KeyChar != 8) e.KeyChar = '\0';
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|