188 lines
7.4 KiB
C#
188 lines
7.4 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 frmPrijemDoSkladu : Form
|
|
{
|
|
Int32 intIDSkladOperacia = 0;
|
|
public frmPrijemDoSkladu(Int32 _intIDSkladOperacia)
|
|
{
|
|
intIDSkladOperacia = _intIDSkladOperacia;
|
|
InitializeComponent();
|
|
}
|
|
|
|
DataTable tblForGridView = new DataTable();
|
|
private void frmPrijemDoSkladu_Load(object sender, EventArgs e)
|
|
{
|
|
comboBox1.Items.Clear();
|
|
classGlobal.FillCBSklad(comboBox1, "tabpomocnychudajov", "Hodnota", "Kategoria", "Pridať krabicu");
|
|
|
|
string cmd = "";
|
|
cmd = "SELECT * FROM `tabskladvyrobkov` WHERE `IDOperacia` = " + intIDSkladOperacia + ";";
|
|
DataTable PrijemDoSkladu = new DataTable();
|
|
classSQL.SQL(cmd, out PrijemDoSkladu);
|
|
DataRow dr0 = PrijemDoSkladu.Rows[0];
|
|
|
|
Int32 idnajdivyrobok = Convert.ToInt32(dr0["IDvyr"].ToString());
|
|
string cmd2 = "";
|
|
cmd2 = "SELECT * FROM `tabvyrobok` WHERE `IDVyrobok` = " + idnajdivyrobok + ";";
|
|
DataTable tblnajdivyrobok = new DataTable();
|
|
classSQL.SQL(cmd2, out tblnajdivyrobok);
|
|
DataRow rownajdivyrobok = tblnajdivyrobok.Rows[0];
|
|
|
|
label2.Text = rownajdivyrobok["NazovVyrobku"].ToString();
|
|
label3.Text = dr0["Pocet"].ToString();
|
|
label4.Text = dr0["Pocet"].ToString();
|
|
label5.Text = "0";
|
|
label9.Text = dr0["MaterialSUpravouMat"].ToString();
|
|
|
|
if (tblForGridView.Columns.Contains("Krabica") == false)
|
|
{
|
|
DataColumn tblColumn = new DataColumn("Krabica", typeof(string));
|
|
tblForGridView.Columns.Add(tblColumn);
|
|
}
|
|
else tblForGridView.Clear();
|
|
if (tblForGridView.Columns.Contains("Počet kusov") == false)
|
|
{
|
|
DataColumn tblColumn2 = new DataColumn("Počet kusov", typeof(string));
|
|
tblForGridView.Columns.Add(tblColumn2);
|
|
}
|
|
else tblForGridView.Clear();
|
|
|
|
tblForGridView.AcceptChanges();
|
|
dataGridView1.DataSource = tblForGridView;
|
|
dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
|
dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
|
dataGridView1.AutoResizeColumns();
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
Form Add = new frmAddPomUdaje();
|
|
Add.Text = "Pridať krabicu";
|
|
DialogResult dr = Add.ShowDialog();
|
|
if (dr == DialogResult.OK)
|
|
{
|
|
comboBox1.Items.Clear();
|
|
classGlobal.FillCBSklad(comboBox1, "tabpomocnychudajov", "Hodnota", "Kategoria", "Pridať krabicu");
|
|
comboBox1.Text = classGlobal.strNovyPomocnyUdaj;
|
|
}
|
|
}
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
private void textBox1_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (textBox1.Text != "")
|
|
{
|
|
if (Convert.ToInt32(textBox1.Text.ToString()) > Convert.ToInt32(label3.Text.ToString())) textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1);
|
|
textBox1.Select(textBox1.Text.Length, 0);
|
|
|
|
if (comboBox1.Text != "" && textBox1.Text != "") button2.Enabled = true;
|
|
else button2.Enabled = false;
|
|
}
|
|
else button2.Enabled = false;
|
|
}
|
|
|
|
private void button5_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (comboBox1.Text != "" && textBox1.Text != "") button2.Enabled = true;
|
|
else button2.Enabled = false;
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
DataRow dr = tblForGridView.NewRow();
|
|
dr["Krabica"] = comboBox1.Text;
|
|
dr["Počet kusov"] = textBox1.Text;
|
|
label3.Text = (Convert.ToInt32(label3.Text) - Convert.ToInt32(textBox1.Text)).ToString();
|
|
label5.Text = (Convert.ToInt32(label5.Text) + Convert.ToInt32(textBox1.Text)).ToString();
|
|
if (label3.Text == "0")
|
|
{
|
|
button2.Enabled = false;
|
|
button3.Enabled = true;
|
|
textBox1.Enabled = false;
|
|
comboBox1.Enabled = false;
|
|
}
|
|
comboBox1.Items.RemoveAt(comboBox1.SelectedIndex);
|
|
textBox1.Text = "";
|
|
tblForGridView.Rows.Add(dr);
|
|
tblForGridView.AcceptChanges();
|
|
dataGridView1.DataSource = tblForGridView;
|
|
label12.Text = tblForGridView.Rows.Count.ToString();
|
|
label13.Text = label5.Text;
|
|
if (label5.Text == "0") button4.Enabled = false;
|
|
else button4.Enabled = true;
|
|
}
|
|
|
|
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
DataRow dr;
|
|
dr = tblForGridView.Rows[dataGridView1.CurrentRow.Index];
|
|
|
|
label3.Text = (Convert.ToInt32(label3.Text) + Convert.ToInt32(dr["Počet kusov"].ToString())).ToString();
|
|
label5.Text = (Convert.ToInt32(label5.Text) - Convert.ToInt32(dr["Počet kusov"].ToString())).ToString();
|
|
comboBox1.Items.Add(dr["Krabica"].ToString());
|
|
tblForGridView.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
|
|
dataGridView1.DataSource = tblForGridView;
|
|
button2.Enabled = true;
|
|
button3.Enabled = false;
|
|
textBox1.Enabled = true;
|
|
comboBox1.Enabled = true;
|
|
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
string cmd = "UPDATE `mip`.`tabskladvyrobkov` SET `StatusSkladOperacie`= 'Vybavený', `DatumVykonania`= DATE(NOW()) WHERE `IDOperacia`=" + intIDSkladOperacia.ToString() + ";";
|
|
classSQL.SQL(cmd);
|
|
|
|
for (int i = 0; i < tblForGridView.Rows.Count ; i++)
|
|
{
|
|
cmd = @"INSERT INTO `mip`.`tabskladkrabice` (`CisloKrabice`, `IDSkladovaOperacia`, `PocetKusov`) VALUES ("
|
|
+ tblForGridView.Rows[i].ItemArray[0].ToString() + ", "
|
|
+ intIDSkladOperacia.ToString() + ", "
|
|
+ tblForGridView.Rows[i].ItemArray[1].ToString() + ");";
|
|
classSQL.SQL(cmd);
|
|
|
|
}
|
|
tblForGridView.Rows.Clear();
|
|
dataGridView1.DataSource = tblForGridView;
|
|
MessageBox.Show("Všetky kusy úspešne prijaté do skladu!");
|
|
this.Close();
|
|
}
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
label12.Text = "0";
|
|
label13.Text = "0";
|
|
frmPrijemDoSkladu_Load(null,null);
|
|
comboBox1.Enabled = true;
|
|
textBox1.Enabled = true;
|
|
button3.Enabled = false;
|
|
button4.Enabled = false;
|
|
}
|
|
|
|
}
|
|
}
|