Initial commit
This commit is contained in:
168
Mip/frmPriraditZamestnancaStroju.cs
Normal file
168
Mip/frmPriraditZamestnancaStroju.cs
Normal file
@@ -0,0 +1,168 @@
|
||||
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 frmPriraditZamestnancaStroju : Form
|
||||
{
|
||||
Int32 Idstroj;
|
||||
DataTable tblStrojZamest = new DataTable();
|
||||
|
||||
public frmPriraditZamestnancaStroju(Int32 _IDStroj)
|
||||
{
|
||||
InitializeComponent();
|
||||
Idstroj = _IDStroj;
|
||||
string cmd = "select * from `pohladstroje-zaradenie` where `IDStrojZaradenie` =" + Idstroj.ToString() + ";";
|
||||
classSQL.SQL(cmd, out tblStrojZamest);
|
||||
|
||||
foreach (DataRow dr in tblStrojZamest.Rows)
|
||||
{
|
||||
FlowLayoutPanel panelS = new FlowLayoutPanel();
|
||||
panelS.Name = dr["IDZaradenie"].ToString();
|
||||
panelS.Tag = dr["IDUser"].ToString();
|
||||
panelS.Size = new System.Drawing.Size(20, 12);
|
||||
panelS.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
panelS.Margin = new Padding(1, 1, 1, 1);
|
||||
panelS.BackColor = Color.LightGreen;
|
||||
panelS.AutoSize = true;
|
||||
|
||||
Label labelMeno = new Label();
|
||||
labelMeno.Text = dr["Meno"].ToString();
|
||||
labelMeno.Font = new Font(labelMeno.Font.FontFamily,11);
|
||||
labelMeno.Margin = new Padding(1, 1, 0, 1);
|
||||
labelMeno.AutoSize = true;
|
||||
labelMeno.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelMeno.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
panelS.Controls.Add(labelMeno);
|
||||
|
||||
Label labelDelete = new Label();
|
||||
labelDelete.Image = global::Mip.Properties.Resources.delete2;
|
||||
labelDelete.Margin = new Padding(1, 1, 1, 1);
|
||||
labelDelete.Size = new System.Drawing.Size(20, 20);
|
||||
labelDelete.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelDelete.Click += new EventHandler(DeleteZaradenie);
|
||||
panelS.Controls.Add(labelDelete);
|
||||
|
||||
flowLayoutPanel1.Controls.Add(panelS);
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteZaradenie(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Naozaj vymazať zamestnanca?", "Upozornenie!", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
||||
using (Control c = sender as Control)
|
||||
{
|
||||
if (c.Parent.Name == "new") c.Parent.Parent.Controls.Remove(c.Parent);
|
||||
else c.Parent.Visible = false;
|
||||
//tabSpecifikacie.Rows[Convert.ToInt32(c.Parent.Name.ToString())].SetField("Vymazaný", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBox1.Visible == false) { comboBox1.Visible = true; button4.Visible = true; }
|
||||
else { comboBox1.Visible = false; button4.Visible = false; }
|
||||
}
|
||||
|
||||
private void comboBox1_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBox1.Visible == true)
|
||||
{
|
||||
string cmd = "select concat(ifnull(`Titul`,''),' ',`Meno`,' ',`Priezvisko`) as Meno, `IDUsers` from `tabusers` where `Status` = 'Aktívny' and `Zaradenie` = 'Výroba';";
|
||||
DataTable tblOsoby;
|
||||
classSQL.SQL(cmd, out tblOsoby);
|
||||
|
||||
comboBox1.DataSource = tblOsoby;
|
||||
comboBox1.ValueMember = "IDUsers";
|
||||
comboBox1.DisplayMember = "Meno";
|
||||
// comboBox1.SelectedIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBox1.DataSource = null;
|
||||
comboBox1.Items.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(comboBox1.DataSource != null)
|
||||
{
|
||||
bool addItem = true;
|
||||
foreach (Control cn in flowLayoutPanel1.Controls) if (cn.Tag.ToString() == comboBox1.SelectedValue.ToString()) addItem = false;
|
||||
|
||||
if (addItem == false) button4.Enabled = false;
|
||||
else button4.Enabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool addItem = true;
|
||||
foreach (Control cn in flowLayoutPanel1.Controls) if (cn.Tag.ToString() == comboBox1.SelectedValue.ToString()) addItem = false;
|
||||
|
||||
if (addItem == false) { MessageBox.Show("Zamestnanec je už pridaný!"); button4.Enabled = false; }
|
||||
else button4.Enabled = true;
|
||||
|
||||
if(addItem == true)
|
||||
{
|
||||
FlowLayoutPanel panelS = new FlowLayoutPanel();
|
||||
panelS.Name = "new";
|
||||
panelS.Tag = comboBox1.SelectedValue.ToString();
|
||||
panelS.Size = new System.Drawing.Size(20, 12);
|
||||
panelS.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
panelS.Margin = new Padding(1, 1, 1, 1);
|
||||
panelS.BackColor = Color.LightYellow;
|
||||
panelS.AutoSize = true;
|
||||
|
||||
Label labelMeno = new Label();
|
||||
labelMeno.Text = comboBox1.Text;
|
||||
labelMeno.Font = new Font(labelMeno.Font.FontFamily, 11);
|
||||
labelMeno.Margin = new Padding(1, 1, 0, 1);
|
||||
labelMeno.AutoSize = true;
|
||||
labelMeno.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelMeno.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
panelS.Controls.Add(labelMeno);
|
||||
|
||||
Label labelDelete = new Label();
|
||||
labelDelete.Image = global::Mip.Properties.Resources.delete2;
|
||||
labelDelete.Margin = new Padding(1, 1, 1, 1);
|
||||
labelDelete.Size = new System.Drawing.Size(20, 20);
|
||||
labelDelete.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelDelete.Click += new EventHandler(DeleteZaradenie);
|
||||
panelS.Controls.Add(labelDelete);
|
||||
|
||||
flowLayoutPanel1.Controls.Add(panelS);
|
||||
button4.Enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
string cmd = "";
|
||||
|
||||
foreach(Control ctrl in flowLayoutPanel1.Controls)
|
||||
{
|
||||
if (ctrl.Visible == false) cmd = "DELETE FROM `tabstroje-zaradenie` WHERE `IDZaradenie`=" + ctrl.Name + ";";
|
||||
if (ctrl.Name == "new") cmd = @"insert into `tabstroje-zaradenie` (`IDStrojZaradenie`, `IDUserZaradenie`) VALUES(" + Idstroj.ToString() + "," + ctrl.Tag.ToString() + ");";
|
||||
if (cmd != "") classSQL.SQL(cmd);
|
||||
}
|
||||
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user