127 lines
4.0 KiB
C#
127 lines
4.0 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 frmInventar : Form
|
|
{
|
|
public frmInventar()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
string typVstupu;
|
|
string cmd;
|
|
|
|
string strMat = comboBox3.Text;
|
|
string strUMat = comboBox4.Text;
|
|
string strMatUMat;
|
|
if (strUMat == "") strMatUMat = strMat;
|
|
else strMatUMat = strMat + " + " + strUMat;
|
|
|
|
if (this.Text == "Inventárny príjem") typVstupu = "Inventárny príjem";
|
|
else typVstupu = "Inventárny výdaj";
|
|
|
|
cmd = @"INSERT INTO `mip`.`tabskladvyrobkov` (`SkladOperacia`, `StatusSkladOperacie`, `IDvyr`, `IDExpedicia`, `IDDopyt`, `MaterialSUpravouMat`, `Pocet`, `DatumVytvorenia`) VALUES ('"
|
|
+ typVstupu + "', "
|
|
+ "'Nevybavený'" + ", "
|
|
+ _IDVyrobok.ToString() + ", "
|
|
+ "0" + ", "
|
|
+ "0" + ", '"
|
|
+ strMatUMat + "', "
|
|
+ textBox1.Text.ToString() + ", "
|
|
+ "DATE(NOW()) );";
|
|
classSQL.SQL(cmd);
|
|
|
|
comboBox2.SelectedIndex = -1;
|
|
comboBox3.SelectedIndex = -1;
|
|
comboBox4.SelectedIndex = -1;
|
|
textBox1.Clear();
|
|
comboBox3.Enabled = false;
|
|
comboBox4.Enabled = false;
|
|
textBox1.Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
private void frmInventar_Shown(object sender, EventArgs e)
|
|
{
|
|
button1.Text = this.Text;
|
|
classGlobal.FillCB(comboBox1, "tabpomocnychudajov", "Hodnota", "Kategoria", "Pridať zákazníka");
|
|
classGlobal.FillCB(comboBox3, "tabpomocnychudajov", "Hodnota", "Kategoria", "Pridať materiál");
|
|
classGlobal.FillCB(comboBox4, "tabpomocnychudajov", "Hodnota", "Kategoria", "Pridať úpravu materiálu");
|
|
}
|
|
|
|
DataTable dttbINV = new DataTable();
|
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
comboBox2.Items.Clear();
|
|
comboBox3.SelectedIndex = -1;
|
|
comboBox4.SelectedIndex = -1;
|
|
|
|
string cmd;
|
|
cmd = "SELECT * FROM `mip`.`tabvyrobok` WHERE `Zakaznik` = '"
|
|
+ comboBox1.Text + "' ORDER BY `NazovVyrobku`;";
|
|
|
|
classSQL.SQL(cmd, out dttbINV);
|
|
foreach (DataRow row in dttbINV.Rows)
|
|
{
|
|
comboBox2.Items.Add(row["NazovVyrobku"].ToString());
|
|
|
|
}
|
|
|
|
comboBox2.Enabled = true;
|
|
comboBox3.Enabled = false;
|
|
comboBox4.Enabled = false;
|
|
textBox1.Enabled = false;
|
|
}
|
|
|
|
Int32 _IDVyrobok;
|
|
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
if (comboBox2.SelectedIndex >= 0)
|
|
{
|
|
DataRow r1 = dttbINV.Rows[comboBox2.SelectedIndex];
|
|
_IDVyrobok = Convert.ToInt32(r1["IDVyrobok"].ToString());
|
|
comboBox3.Enabled = true;
|
|
}
|
|
|
|
}
|
|
|
|
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
comboBox4.Enabled = true;
|
|
textBox1.Enabled = true;
|
|
}
|
|
|
|
private void textBox1_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (textBox1.Text != "") button1.Enabled = true;
|
|
else button1.Enabled = false;
|
|
}
|
|
|
|
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
int intResult;
|
|
if (!(int.TryParse(textBox1.Text + e.KeyChar, out intResult)) && (int)e.KeyChar != 8) e.KeyChar = '\0';
|
|
}
|
|
|
|
}
|
|
}
|