198 lines
7.0 KiB
C#
198 lines
7.0 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mip
|
|
{
|
|
public partial class frmUlozPolotovarZVyroby : Form
|
|
{
|
|
Int32 idVyrobok;
|
|
Int32 idPolotovar;
|
|
bool enableUpdate = false;
|
|
DataTable tblPolotovar;
|
|
DataTable tblVyrobok;
|
|
Int32 IDpolotovar;
|
|
|
|
string rozmertvarVyrobku;
|
|
decimal rozmer1Vyrobku;
|
|
decimal rozmer2Vyrobku;
|
|
decimal rozmer3Vyrobku;
|
|
|
|
string rozmerTvarPotovaru = "Ø";
|
|
decimal rozmer1Potovaru;
|
|
decimal rozmer2Potovaru;
|
|
decimal rozmer3Potovaru;
|
|
Int32 pocetKusovVpolotovare;
|
|
|
|
public string VelkostPolotovaru { get; set; }
|
|
|
|
public frmUlozPolotovarZVyroby(int _idVyrobok = 0, int _idPolotovar = 0)
|
|
{
|
|
idVyrobok = _idVyrobok;
|
|
idPolotovar = _idPolotovar;
|
|
|
|
string cmdPolotovar;
|
|
cmdPolotovar = $"SELECT * FROM `tabpolotovar` WHERE IDVyrobok = {idVyrobok.ToString()};";
|
|
classSQL.SQL(cmdPolotovar, out tblPolotovar);
|
|
|
|
if (tblPolotovar.Rows.Count > 0)
|
|
{
|
|
rozmerTvarPotovaru = tblPolotovar.Rows[0]["RozmerTvar"].ToString();
|
|
rozmer1Potovaru = Convert.ToInt32(tblPolotovar.Rows[0]["Rozmer1"]);
|
|
rozmer2Potovaru = Convert.ToInt32(tblPolotovar.Rows[0]["Rozmer2"]);
|
|
rozmer3Potovaru = Convert.ToInt32(tblPolotovar.Rows[0]["Rozmer3"]);
|
|
pocetKusovVpolotovare = Convert.ToInt32(tblPolotovar.Rows[0]["PocetKusovVPolotovare"]);
|
|
IDpolotovar = Convert.ToInt32(tblPolotovar.Rows[0]["IDPolotovar"].ToString());
|
|
|
|
enableUpdate = true;
|
|
}
|
|
//else
|
|
//{
|
|
// rozmerTvarPotovaru = "Ø";
|
|
//}
|
|
|
|
string cmdVyrobok;
|
|
cmdVyrobok = $"SELECT * FROM `tabvyrobok` WHERE IDVyrobok = {idVyrobok.ToString()};";
|
|
classSQL.SQL(cmdVyrobok, out tblVyrobok);
|
|
|
|
if (tblVyrobok.Rows.Count > 0)
|
|
{
|
|
rozmertvarVyrobku = tblVyrobok.Rows[0]["RozmerTvar"].ToString();
|
|
rozmer1Vyrobku = Convert.ToInt32(tblVyrobok.Rows[0]["Rozmer1"]);
|
|
rozmer2Vyrobku = Convert.ToInt32(tblVyrobok.Rows[0]["Rozmer2"]);
|
|
rozmer3Vyrobku = Convert.ToInt32(tblVyrobok.Rows[0]["Rozmer3"]);
|
|
}
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
string cmd;
|
|
if (enableUpdate == true)
|
|
{
|
|
cmd = $@"UPDATE `tabpolotovar` SET
|
|
`RozmerTvar` = '{label7.Text}',
|
|
`Rozmer1` = {numericUpDown2.Value},
|
|
`Rozmer2` = {numericUpDown3.Value},
|
|
`Rozmer3` = {numericUpDown4.Value},
|
|
`PocetKusovVPolotovare` = {numericUpDown5.Value}
|
|
WHERE IDpolotovar = {IDpolotovar.ToString()};";
|
|
classSQL.SQL(cmd);
|
|
}
|
|
else
|
|
{
|
|
cmd = $@"INSERT INTO `tabpolotovar` (`IDVyrobok`, `RozmerTvar`, `Rozmer1`, `Rozmer2`, `Rozmer3`, `PocetKusovVPolotovare`) VALUES (
|
|
{idVyrobok.ToString()},
|
|
'{label7.Text}',
|
|
{numericUpDown2.Value},
|
|
{numericUpDown3.Value},
|
|
{numericUpDown4.Value},
|
|
{numericUpDown5.Value});";
|
|
classSQL.SQL(cmd);
|
|
enableUpdate = true;
|
|
}
|
|
this.Close();
|
|
}
|
|
|
|
private void frmUlozPolotovar_Shown(object sender, EventArgs e)
|
|
{
|
|
numericUpDown2.Focus();
|
|
RefreshPolotovar();
|
|
}
|
|
|
|
private void RefreshPolotovar()
|
|
{
|
|
var oddelovac = rozmertvarVyrobku == "Ø" ? "/" : "x";
|
|
label12.Text = $"Rozmery výrobku: {rozmertvarVyrobku}{rozmer1Vyrobku}{oddelovac}{rozmer2Vyrobku}{"x"}{rozmer3Vyrobku}";
|
|
label7.Text = rozmerTvarPotovaru;
|
|
numericUpDown2.Value = rozmer1Potovaru;
|
|
numericUpDown3.Value = rozmer2Potovaru;
|
|
numericUpDown4.Value = rozmer3Potovaru;
|
|
numericUpDown5.Value = pocetKusovVpolotovare;
|
|
|
|
var oddelovacPolotor = rozmerTvarPotovaru == "Ø" ? "/" : "x";
|
|
label6.Text = $"Rozmery polotovaru: {rozmerTvarPotovaru}{rozmer1Potovaru}{oddelovacPolotor}{rozmer2Potovaru}{"x"}{rozmer3Potovaru}";
|
|
VelkostPolotovaru = $"{rozmerTvarPotovaru}{rozmer1Potovaru}{oddelovacPolotor}{rozmer2Potovaru}{"x"}{rozmer3Potovaru} ({pocetKusovVpolotovare}-Ks)";
|
|
}
|
|
|
|
private void numericUpDown2_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
var nud = sender as NumericUpDown;
|
|
rozmer1Potovaru = nud.Value;
|
|
RefreshPolotovar();
|
|
}
|
|
|
|
private void numericUpDown3_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
var nud = sender as NumericUpDown;
|
|
rozmer2Potovaru = nud.Value;
|
|
RefreshPolotovar();
|
|
}
|
|
|
|
private void numericUpDown4_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
var nud = sender as NumericUpDown;
|
|
rozmer3Potovaru = nud.Value;
|
|
RefreshPolotovar();
|
|
}
|
|
|
|
private void numericUpDown5_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
var nud = sender as NumericUpDown;
|
|
pocetKusovVpolotovare = Convert.ToInt32(nud.Value);
|
|
RefreshPolotovar();
|
|
}
|
|
|
|
private void label7_Click(object sender, EventArgs e)
|
|
{
|
|
if (label7.Text == "Ø")
|
|
{
|
|
rozmerTvarPotovaru = "□";
|
|
}
|
|
else
|
|
{
|
|
rozmerTvarPotovaru = "Ø";
|
|
}
|
|
RefreshPolotovar();
|
|
}
|
|
|
|
private void label12_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
label7.Text = rozmertvarVyrobku;
|
|
numericUpDown2.Value = rozmer1Vyrobku;
|
|
numericUpDown3.Value = rozmer2Vyrobku;
|
|
numericUpDown4.Value = rozmer3Vyrobku;
|
|
}
|
|
|
|
private void numericUpDown2_Enter(object sender, EventArgs e)
|
|
{
|
|
var numeric = sender as NumericUpDown;
|
|
numeric.Select(0, numeric.Text.Length);
|
|
}
|
|
|
|
private void numericUpDown3_Enter(object sender, EventArgs e)
|
|
{
|
|
var numeric = sender as NumericUpDown;
|
|
numeric.Select(0, numeric.Text.Length);
|
|
}
|
|
|
|
private void numericUpDown4_Enter(object sender, EventArgs e)
|
|
{
|
|
var numeric = sender as NumericUpDown;
|
|
numeric.Select(0, numeric.Text.Length);
|
|
}
|
|
|
|
private void numericUpDown5_Enter(object sender, EventArgs e)
|
|
{
|
|
var numeric = sender as NumericUpDown;
|
|
numeric.Select(0, numeric.Text.Length);
|
|
}
|
|
}
|
|
}
|