Initial commit

This commit is contained in:
Culak-HP\Culak
2020-10-10 18:25:36 +02:00
commit cc7c23eca4
254 changed files with 67743 additions and 0 deletions

347
Mip/frmAddFirma.cs Normal file
View File

@@ -0,0 +1,347 @@
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 frmAddFirma : Form
{
Int32 IDFirma = 0;
Boolean bDelete = false;
public frmAddFirma()
{
InitializeComponent();
}
public frmAddFirma(Int32 _IDFirma)
{
InitializeComponent();
IDFirma = _IDFirma;
//button4.Tag = IDFirma;
button4.Text = "Upraviť údaje";
}
public frmAddFirma(Int32 _IDFirma, bool _delete)
{
InitializeComponent();
IDFirma = _IDFirma;
bDelete = _delete;
//button4.Tag = IDFirma;
button4.Text = "Zmazať firmu";
if (NázovFirmy.Text == NázovFirmy.Name) NázovFirmy.Enabled = false;
else NázovFirmy.ReadOnly = true;
if (Ulica.Text == Ulica.Name) Ulica.Enabled = false;
else Ulica.ReadOnly = true;
if (PopisnéČíslo.Text == PopisnéČíslo.Name) PopisnéČíslo.Enabled = false;
else PopisnéČíslo.ReadOnly = true;
if (Miesto.Text == Miesto.Name) Miesto.Enabled = false;
else Miesto.ReadOnly = true;
if (ČísloDomu.Text == ČísloDomu.Name) ČísloDomu.Enabled = false;
else ČísloDomu.ReadOnly = true;
if (PSČ.Text == PSČ.Name) PSČ.Enabled = false;
else PSČ.ReadOnly = true;
if (Krajina.Text == Krajina.Name) Krajina.Enabled = false;
else Krajina.ReadOnly = true;
if (IČO.Text == IČO.Name) IČO.Enabled = false;
else IČO.ReadOnly = true;
if (DIČ.Text == DIČ.Name) DIČ.Enabled = false;
else DIČ.ReadOnly = true;
if (Poznámka.Text == Poznámka.Name) Poznámka.Enabled = false;
else Poznámka.ReadOnly = true;
if (EMail.Text == EMail.Name) EMail.Enabled = false;
else EMail.ReadOnly = true;
if (WEB.Text == WEB.Name) WEB.Enabled = false;
else WEB.ReadOnly = true;
if (ZemepisnáDĺžka.Text == ZemepisnáDĺžka.Name) ZemepisnáDĺžka.Enabled = false;
else ZemepisnáDĺžka.ReadOnly = true;
if (ZemepisnáŠírka.Text == ZemepisnáŠírka.Name) ZemepisnáŠírka.Enabled = false;
else ZemepisnáŠírka.ReadOnly = true;
if (Info1.Text == Info1.Name) Info1.Enabled = false;
else Info1.ReadOnly = true;
if (Info2.Text == Info2.Name) Info2.Enabled = false;
else Info2.ReadOnly = true;
if (Info3.Text == Info3.Name) Info3.Enabled = false;
else Info3.ReadOnly = true;
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void tbLeave(object sender, EventArgs e)
{
TextBox tb = sender as TextBox;
tb.BackColor = Color.Empty;
if (tb.Text.Length == 0)
{
tb.Text = tb.Name;
tb.ForeColor = Color.LightGray;
}
else
{
tb.ForeColor = Color.Empty;
}
}
private void tbEnter(object sender, EventArgs e)
{
TextBox tb = sender as TextBox;
tb.BackColor = Color.LightGreen;
if (tb.Text == tb.Name)
{
tb.Text = "";
tb.ForeColor = Color.Empty;
}
}
private void frmAddFirma_Shown(object sender, EventArgs e)
{
var checkedControls = panel28.Controls.Cast<Control>()
.Concat(panel43.Controls.Cast<Control>());
if(bDelete == false)
foreach (Control tb in checkedControls)
if (tb is TextBox)
{
tb.Leave += new System.EventHandler(tbLeave);
tb.Enter += new System.EventHandler(tbEnter);
tb.TextChanged += new System.EventHandler(textBoxTextChanged);
tb.Text = tb.Name;
tb.Focus();
}
if(IDFirma != 0)
{
DataTable tabFirma;
string cmd = "";
cmd = "select * from `tabfirmy` where `IDFirma` = " + IDFirma.ToString() + ";";
classSQL.SQL(cmd, out tabFirma);
if (tabFirma.Rows[0]["FirmaMeno"].ToString() != "") NázovFirmy.Text = tabFirma.Rows[0]["FirmaMeno"].ToString();
if (tabFirma.Rows[0]["FirmaPopisneCislo"].ToString() != "") PopisnéČíslo.Text = tabFirma.Rows[0]["FirmaPopisneCislo"].ToString();
if (tabFirma.Rows[0]["FirmaUlica"].ToString() != "") Ulica.Text = tabFirma.Rows[0]["FirmaUlica"].ToString();
if (tabFirma.Rows[0]["FirmaMesto"].ToString() != "") Miesto.Text = tabFirma.Rows[0]["FirmaMesto"].ToString();
if (tabFirma.Rows[0]["FirmaCisloDomu"].ToString() != "") ČísloDomu.Text = tabFirma.Rows[0]["FirmaCisloDomu"].ToString();
if (tabFirma.Rows[0]["FirmaPSC"].ToString() != "") PSČ.Text = tabFirma.Rows[0]["FirmaPSC"].ToString();
if (tabFirma.Rows[0]["FirmaKrajina"].ToString() != "") Krajina.Text = tabFirma.Rows[0]["FirmaKrajina"].ToString();
if (tabFirma.Rows[0]["FirmaICO"].ToString() != "") IČO.Text = tabFirma.Rows[0]["FirmaICO"].ToString();
if (tabFirma.Rows[0]["FirmaDIC"].ToString() != "") DIČ.Text = tabFirma.Rows[0]["FirmaDIC"].ToString();
if (tabFirma.Rows[0]["FirmaPoznamka"].ToString() != "") Poznámka.Text = tabFirma.Rows[0]["FirmaPoznamka"].ToString();
if (tabFirma.Rows[0]["FirmaEmail"].ToString() != "") EMail.Text = tabFirma.Rows[0]["FirmaEmail"].ToString();
if (tabFirma.Rows[0]["FirmaWEB"].ToString() != "") WEB.Text = tabFirma.Rows[0]["FirmaWEB"].ToString();
if (tabFirma.Rows[0]["Lat"].ToString() != "") ZemepisnáŠírka.Text = tabFirma.Rows[0]["Lat"].ToString();
if (tabFirma.Rows[0]["Long"].ToString() != "") ZemepisnáDĺžka.Text = tabFirma.Rows[0]["Long"].ToString();
if (tabFirma.Rows[0]["Info1"].ToString() != "") Info1.Text = tabFirma.Rows[0]["Info1"].ToString();
if (tabFirma.Rows[0]["Info2"].ToString() != "") Info2.Text = tabFirma.Rows[0]["Info2"].ToString();
if (tabFirma.Rows[0]["Info3"].ToString() != "") Info3.Text = tabFirma.Rows[0]["Info3"].ToString();
}
button87.Focus();
}
private void textBoxTextChanged(object sender, EventArgs e)
{
TextBox tb = sender as TextBox;
if(tb.Text == tb.Name) { tb.ForeColor = Color.LightGray; }
else { tb.ForeColor = Color.Empty; }
}
private void button87_Click(object sender, EventArgs e)
{
this.Close();
}
private void label53_Click(object sender, EventArgs e)
{
if (panel28.Size.Height == 25)
{
panel28.Size = new Size(panel28.Size.Width, flowLayoutPanel1.Size.Height - 112);
panel29.Size = new Size(panel28.Size.Width, 25);
panel32.Size = new Size(panel28.Size.Width, 25);
panel33.Size = new Size(panel28.Size.Width, 25);
}
else panel28.Size = new Size(panel28.Size.Width, 25);
}
private void label54_Click(object sender, EventArgs e)
{
if (panel29.Size.Height == 25)
{
panel29.Size = new Size(panel29.Size.Width, flowLayoutPanel1.Size.Height - 112);
panel28.Size = new Size(panel28.Size.Width, 25);
panel32.Size = new Size(panel28.Size.Width, 25);
panel33.Size = new Size(panel28.Size.Width, 25);
}
else panel29.Size = new Size(panel29.Size.Width, 25);
}
private void label56_Click(object sender, EventArgs e)
{
if (panel32.Size.Height == 25)
{
panel32.Size = new Size(panel32.Size.Width, flowLayoutPanel1.Size.Height - 112);
panel28.Size = new Size(panel28.Size.Width, 25);
panel29.Size = new Size(panel28.Size.Width, 25);
panel33.Size = new Size(panel28.Size.Width, 25);
}
else panel32.Size = new Size(panel32.Size.Width, 25);
}
private void label57_Click(object sender, EventArgs e)
{
if (panel33.Size.Height == 25)
{
panel33.Size = new Size(panel33.Size.Width, flowLayoutPanel1.Size.Height - 112);
panel28.Size = new Size(panel28.Size.Width, 25);
panel29.Size = new Size(panel28.Size.Width, 25);
panel32.Size = new Size(panel28.Size.Width, 25);
}
else panel33.Size = new Size(panel33.Size.Width, 25);
}
private void setPanelColor(Panel pnl, Label lbl)
{
if (pnl.Size.Height == 25)
{
pnl.BackColor = Color.Transparent;
lbl.BackColor = Color.Transparent;
lbl.Font = new Font(Font.Name, 8.25F, FontStyle.Regular);
}
else
{
pnl.BackColor = Color.LightYellow;
lbl.BackColor = Color.Gold;
lbl.Font = new Font(Font.Name, 12.0F, FontStyle.Bold);
}
}
private void panel28_Resize(object sender, EventArgs e)
{
setPanelColor(panel28, label53);
}
private void panel29_Resize(object sender, EventArgs e)
{
setPanelColor(panel29, label54);
}
private void panel32_Resize(object sender, EventArgs e)
{
setPanelColor(panel32, label56);
}
private void panel33_Resize(object sender, EventArgs e)
{
setPanelColor(panel33, label57);
}
private void button4_Click(object sender, EventArgs e)
{
string cmd = "";
if (NázovFirmy.Text == NázovFirmy.Name) NázovFirmy.Text = "";
if (Ulica.Text == Ulica.Name) Ulica.Text = "";
if (PopisnéČíslo.Text == PopisnéČíslo.Name) PopisnéČíslo.Text = "";
if (Miesto.Text == Miesto.Name) Miesto.Text = "";
if (ČísloDomu.Text == ČísloDomu.Name) ČísloDomu.Text = "";
if (PSČ.Text == PSČ.Name) PSČ.Text = "";
if (Krajina.Text == Krajina.Name) Krajina.Text = "";
if (IČO.Text == IČO.Name) IČO.Text = "";
if (DIČ.Text == DIČ.Name) DIČ.Text = "";
if (Poznámka.Text == Poznámka.Name) Poznámka.Text = "";
if (EMail.Text == EMail.Name) EMail.Text = "";
if (WEB.Text == WEB.Name) WEB.Text = "";
if (ZemepisnáDĺžka.Text == ZemepisnáDĺžka.Name) ZemepisnáDĺžka.Text = "";
if (ZemepisnáŠírka.Text == ZemepisnáŠírka.Name) ZemepisnáŠírka.Text = "";
if (Info1.Text == Info1.Name) Info1.Text = "";
if (Info2.Text == Info2.Name) Info2.Text = "";
if (Info3.Text == Info3.Name) Info3.Text = "";
if (bDelete == false)
{
if (IDFirma == 0)
{
string strGPSData = "";
string strGPSDataValues = "";
if (ZemepisnáDĺžka.Text == "" || ZemepisnáŠírka.Text == "")
{
strGPSData = "";
strGPSDataValues = "'";
}
else
{
strGPSData = "`Lat`, `Long`, ";
strGPSDataValues = ZemepisnáŠírka.Text + ", " + ZemepisnáDĺžka.Text + ", '";
}
cmd = @"INSERT INTO `mip`.`tabfirmy` (
`FirmaMeno`, `FirmaPopisneCislo`, `FirmaUlica`, `FirmaMesto`, `FirmaCisloDomu`, `FirmaPSC`, `FirmaKrajina`, `FirmaICO`, `FirmaDIC`, `FirmaPoznamka`, `FirmaEmail`, `FirmaWEB`, "
+ strGPSData + "`Info1`, `Info2`, `Info3`) VALUES ('"
+ NázovFirmy.Text + "', '"
+ PopisnéČíslo.Text + "', '"
+ Ulica.Text + "', '"
+ Miesto.Text + "', '"
+ ČísloDomu.Text + "', '"
+ PSČ.Text + "', '"
+ Krajina.Text + "', '"
+ IČO.Text + "', '"
+ DIČ.Text + "', '"
+ Poznámka.Text + "', '"
+ EMail.Text + "', '"
+ WEB.Text + "', "
+ strGPSDataValues
+ Info1.Text + "', '"
+ Info2.Text + "', '"
+ Info3.Text + "');";
}
else
{
string strGPSDataValues = "";
if (ZemepisnáDĺžka.Text == "" || ZemepisnáŠírka.Text == "") { strGPSDataValues = "'"; }
else { strGPSDataValues = "', `Lat` = " + ZemepisnáŠírka.Text.Replace(",", ".") + ", `Long` = " + ZemepisnáDĺžka.Text.Replace(",", "."); }
cmd = @"UPDATE `mip`.`tabfirmy` SET
`FirmaMeno`= '" + NázovFirmy.Text +
"', `FirmaPopisneCislo` = '" + PopisnéČíslo.Text +
"', `FirmaUlica`= '" + Ulica.Text +
"', `FirmaMesto` = '" + Miesto.Text +
"', `FirmaCisloDomu` = '" + ČísloDomu.Text +
"', `FirmaPSC` = '" + PSČ.Text +
"', `FirmaKrajina` = '" + Krajina.Text +
"', `FirmaICO` = '" + IČO.Text +
"', `FirmaDIC` = '" + DIČ.Text +
"', `FirmaPoznamka` = '" + Poznámka.Text +
"', `FirmaEmail` = '" + EMail.Text +
"', `FirmaWEB` = '" + WEB.Text +
strGPSDataValues +
", `Info1` = '" + Info1.Text +
"', `Info2` = '" + Info2.Text +
"', `Info3` = '" + Info3.Text + "' WHERE `IDFirma` = " + IDFirma.ToString() + ";";
}
}
else
{
cmd = "DELETE FROM `tabfirmy` WHERE `IDFirma`=" + IDFirma.ToString() + ";";
}
classSQL.SQL(cmd);
this.Close();
}
}
}