Editácia výrovku s pdf

This commit is contained in:
roman6791
2021-03-30 12:15:29 +02:00
parent 5798fd69a7
commit 3096d0881b
7 changed files with 9407 additions and 9515 deletions

View File

@@ -1,15 +1,8 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Management;
using System.Net.NetworkInformation;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
@@ -18,7 +11,7 @@ namespace Mip
class classGlobal
{
private static char Disk = 'W';
/// <summary>
/// Vytvorí v RAM disk W:
/// </summary>
@@ -34,7 +27,7 @@ namespace Mip
/// <summary>
/// Vymaže RAM disk W:
/// </summary>
public static void DeleteRamDisk()
{
classDiskOperations.CreatePath();
@@ -85,7 +78,7 @@ namespace Mip
}
*/
public static string strNovyPomocnyUdaj;
/// <summary>
@@ -108,7 +101,7 @@ namespace Mip
{
cb.Items.Add(row[strCollumn].ToString());
}
}
/// <summary>
@@ -137,25 +130,25 @@ namespace Mip
cb.Items.Add(row[strCollumn].ToString());
}
}
/*
/// <summary>
/// Naplna comboBox cb udajmi z SQL servera (viac stlpcov a vrati datasource)
/// </summary>
/// <param name="cb"> nazov naplnaneho comboBoxu</param>
/// <param name="strTab"> nazov tabulky z ktorej comboBox naplname</param>
/// <param name="strCollumn"> nazov stlpca (stlpcov) z tabulky z ktorého data naplname do comboBoxu</param>
public static void FillCBMultiColumn(ComboBox cb, string strTab, string strCollumn)
{
DataTable dtbl = new DataTable();
string c = "SELECT DISTINCT `" + strCollumn
+ "` FROM `mip`.`" + strTab + "`;";
classSQL.SQL(c, out dtbl);
cb.Items.Clear();
cb.DataSource = dtbl;
}
*/
/*
/// <summary>
/// Naplna comboBox cb udajmi z SQL servera (viac stlpcov a vrati datasource)
/// </summary>
/// <param name="cb"> nazov naplnaneho comboBoxu</param>
/// <param name="strTab"> nazov tabulky z ktorej comboBox naplname</param>
/// <param name="strCollumn"> nazov stlpca (stlpcov) z tabulky z ktorého data naplname do comboBoxu</param>
public static void FillCBMultiColumn(ComboBox cb, string strTab, string strCollumn)
{
DataTable dtbl = new DataTable();
string c = "SELECT DISTINCT `" + strCollumn
+ "` FROM `mip`.`" + strTab + "`;";
classSQL.SQL(c, out dtbl);
cb.Items.Clear();
cb.DataSource = dtbl;
}
*/
/// <summary>
/// Naplna comboBox cb udajmi z SQL servera (Urceny pre comboboxy na vydaj a prijem do skladu vyrobkov, konvertuje nazvy krabic(string na integer))
@@ -169,7 +162,7 @@ namespace Mip
{
//select convert(`hodnota`,int) as num from `tabpomocnychudajov` where `kategoria` = 'Pridat krabicu' order by num
DataTable dtbl = new DataTable();
string c = "SELECT DISTINCT CONVERT (`" + strCollumn + "`,int) as NUMBER "
string c = "SELECT DISTINCT CONVERT (`" + strCollumn + "`,int) as NUMBER "
+ " FROM `mip`.`" + strTab
+ "` WHERE `" + strCollumnWhere
+ "` = '" + strHodnotaWhere
@@ -457,10 +450,10 @@ namespace Mip
break;
}
}
if(_cI>-1) _dgv.Columns[_cI].DefaultCellStyle.BackColor = Color.GreenYellow;
if (_cI > -1) _dgv.Columns[_cI].DefaultCellStyle.BackColor = Color.GreenYellow;
break;
}
}
@@ -486,14 +479,14 @@ namespace Mip
}
}
public static void SetServerIP ()
public static void SetServerIP()
{
System.Net.NetworkInformation.Ping pingIP = new System.Net.NetworkInformation.Ping();
string IPaddress = "";
PingReply pingReply;
IPaddress = Debugger.IsAttached ? "192.168.2.12" : "192.168.1.12"; //IP Adresa MariaDB pre VLAN1
//ked sa programuje mino firmu aby to hned naslo staticku ip
//IPaddress = "87.197.164.107";
@@ -504,8 +497,8 @@ namespace Mip
}
else
{
IPaddress = Debugger.IsAttached? "192.168.2.13" : "192.168.1.13"; //IP Adresa MariaDB pre VLAN2
IPaddress = Debugger.IsAttached ? "192.168.2.13" : "192.168.1.13"; //IP Adresa MariaDB pre VLAN2
pingReply = pingIP.Send(IPaddress);
if (pingReply.Status.ToString() == "Success")
{
@@ -513,8 +506,9 @@ namespace Mip
}
else
{
IPaddress = "127.0.0.1";
//IPaddress = "127.0.0.1";
IPaddress = "192.168.1.11";
pingReply = pingIP.Send(IPaddress);
if (pingReply.Status.ToString() == "Success")
{
@@ -523,10 +517,10 @@ namespace Mip
else
{
classUser.MariaDBServerIPAddress = "0.0.0.0";
MessageBox.Show("Žiadny lokálny ani internetový MariaDB server nebol nájdený!"
MessageBox.Show("Žiadny lokálny ani internetový MariaDB server nebol nájdený!"
+ Environment.NewLine
+ "Program Mip bude ukončený! ");
Environment.Exit(0);
}
//IPaddress = "87.197.164.107";
@@ -604,7 +598,7 @@ namespace Mip
xlWorkBook.Save();
xlWorkBook.Close(false, null, null);
xlApp.Quit();
}
@@ -617,12 +611,12 @@ namespace Mip
else cf.Cursor = System.Windows.Forms.Cursors.Default;
*/
if (_switch) Application.UseWaitCursor = true;
else Application.UseWaitCursor = false;
}
@@ -666,11 +660,11 @@ namespace Mip
break;
case "Ziadanka-zobrazit vsetky":
switch(_IDUSER)
switch (_IDUSER)
{
case 1:
case 4:
case 9:
case 1:
case 4:
case 9:
case 13:
case 26:
case 28:
@@ -724,12 +718,12 @@ namespace Mip
}
break;
default :
default:
bReturnValue = false;
break;
}
return bReturnValue;
}

View File

@@ -98,9 +98,9 @@
this.groupBox3.Controls.Add(this.label4);
this.groupBox3.Controls.Add(this.numericUpDown1);
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Location = new System.Drawing.Point(234, 2);
this.groupBox3.Location = new System.Drawing.Point(236, 7);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(239, 140);
this.groupBox3.Size = new System.Drawing.Size(251, 146);
this.groupBox3.TabIndex = 18;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Tvar a rozmery výrobku";
@@ -109,7 +109,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(116, 121);
this.label1.Location = new System.Drawing.Point(124, 121);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(93, 13);
this.label1.TabIndex = 15;
@@ -117,7 +117,7 @@
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(212, 118);
this.textBox7.Location = new System.Drawing.Point(219, 118);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(25, 20);
this.textBox7.TabIndex = 16;
@@ -144,7 +144,7 @@
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(177, 54);
this.textBox4.Location = new System.Drawing.Point(181, 54);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(60, 20);
this.textBox4.TabIndex = 13;
@@ -153,14 +153,14 @@
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(34, 118);
this.textBox5.Location = new System.Drawing.Point(37, 118);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(83, 20);
this.textBox5.TabIndex = 3;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(112, 54);
this.textBox3.Location = new System.Drawing.Point(116, 54);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(60, 20);
this.textBox3.TabIndex = 12;
@@ -169,7 +169,7 @@
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(47, 54);
this.textBox2.Location = new System.Drawing.Point(51, 54);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(60, 20);
this.textBox2.TabIndex = 11;
@@ -180,7 +180,7 @@
//
this.textBox1.Location = new System.Drawing.Point(3, 94);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(234, 20);
this.textBox1.Size = new System.Drawing.Size(241, 20);
this.textBox1.TabIndex = 10;
this.textBox1.TextAlignChanged += new System.EventHandler(this.textBox1_TextAlignChanged);
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
@@ -207,7 +207,7 @@
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(189, 38);
this.label6.Location = new System.Drawing.Point(193, 38);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(35, 13);
this.label6.TabIndex = 4;
@@ -217,7 +217,7 @@
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(126, 38);
this.label5.Location = new System.Drawing.Point(130, 38);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(31, 13);
this.label5.TabIndex = 3;
@@ -227,7 +227,7 @@
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(60, 38);
this.label4.Location = new System.Drawing.Point(64, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(34, 13);
this.label4.TabIndex = 2;
@@ -325,7 +325,7 @@
//
this.btnVymazVykres.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnVymazVykres.Enabled = false;
this.btnVymazVykres.Location = new System.Drawing.Point(103, 115);
this.btnVymazVykres.Location = new System.Drawing.Point(103, 123);
this.btnVymazVykres.Name = "btnVymazVykres";
this.btnVymazVykres.Size = new System.Drawing.Size(58, 23);
this.btnVymazVykres.TabIndex = 8;
@@ -339,14 +339,14 @@
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Location = new System.Drawing.Point(3, 17);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(815, 390);
this.panel1.Size = new System.Drawing.Size(1170, 402);
this.panel1.TabIndex = 9;
//
// pictureBox1
@@ -364,8 +364,8 @@
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(2, 14);
@@ -378,7 +378,7 @@
this.dataGridView1.ShowCellToolTips = false;
this.dataGridView1.ShowEditingIcon = false;
this.dataGridView1.ShowRowErrors = false;
this.dataGridView1.Size = new System.Drawing.Size(274, 100);
this.dataGridView1.Size = new System.Drawing.Size(599, 108);
this.dataGridView1.TabIndex = 4;
this.dataGridView1.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_RowEnter);
this.dataGridView1.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView1_RowPostPaint);
@@ -388,7 +388,7 @@
// btnAddVykres
//
this.btnAddVykres.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnAddVykres.Location = new System.Drawing.Point(46, 115);
this.btnAddVykres.Location = new System.Drawing.Point(46, 123);
this.btnAddVykres.Name = "btnAddVykres";
this.btnAddVykres.Size = new System.Drawing.Size(58, 23);
this.btnAddVykres.TabIndex = 5;
@@ -399,9 +399,9 @@
// button7
//
this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.button7.Location = new System.Drawing.Point(180, 108);
this.button7.Location = new System.Drawing.Point(180, 119);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(51, 34);
this.button7.Size = new System.Drawing.Size(51, 28);
this.button7.TabIndex = 26;
this.button7.Text = "Zoom -";
this.button7.UseVisualStyleBackColor = true;
@@ -410,7 +410,7 @@
// button3
//
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button3.Location = new System.Drawing.Point(752, 117);
this.button3.Location = new System.Drawing.Point(1100, 128);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 23;
@@ -422,7 +422,7 @@
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button5.Enabled = false;
this.button5.Location = new System.Drawing.Point(752, 95);
this.button5.Location = new System.Drawing.Point(1100, 102);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 24;
@@ -432,17 +432,16 @@
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.panel1);
this.groupBox1.Location = new System.Drawing.Point(2, 145);
this.groupBox1.Location = new System.Drawing.Point(2, 151);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(825, 413);
this.groupBox1.Size = new System.Drawing.Size(1180, 425);
this.groupBox1.TabIndex = 19;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Zobraziť výkres";
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// groupBox5
//
@@ -454,14 +453,14 @@
this.groupBox5.Controls.Add(this.label7);
this.groupBox5.Location = new System.Drawing.Point(1, 44);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(232, 62);
this.groupBox5.Size = new System.Drawing.Size(232, 74);
this.groupBox5.TabIndex = 22;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Názov výrobku";
//
// groupBox4
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.btnAktualVykres);
this.groupBox4.Controls.Add(this.btnIndexDwn);
@@ -469,9 +468,9 @@
this.groupBox4.Controls.Add(this.dataGridView1);
this.groupBox4.Controls.Add(this.btnAddVykres);
this.groupBox4.Controls.Add(this.btnVymazVykres);
this.groupBox4.Location = new System.Drawing.Point(474, 2);
this.groupBox4.Location = new System.Drawing.Point(489, 7);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(278, 140);
this.groupBox4.Size = new System.Drawing.Size(603, 148);
this.groupBox4.TabIndex = 21;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Načítané výkresy";
@@ -479,7 +478,7 @@
// btnAktualVykres
//
this.btnAktualVykres.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnAktualVykres.Location = new System.Drawing.Point(160, 115);
this.btnAktualVykres.Location = new System.Drawing.Point(160, 123);
this.btnAktualVykres.Name = "btnAktualVykres";
this.btnAktualVykres.Size = new System.Drawing.Size(72, 23);
this.btnAktualVykres.TabIndex = 28;
@@ -491,7 +490,7 @@
//
this.btnIndexDwn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnIndexDwn.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.btnIndexDwn.Location = new System.Drawing.Point(24, 115);
this.btnIndexDwn.Location = new System.Drawing.Point(24, 123);
this.btnIndexDwn.Name = "btnIndexDwn";
this.btnIndexDwn.Size = new System.Drawing.Size(23, 23);
this.btnIndexDwn.TabIndex = 29;
@@ -503,7 +502,7 @@
//
this.btnIndexUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnIndexUp.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.btnIndexUp.Location = new System.Drawing.Point(2, 115);
this.btnIndexUp.Location = new System.Drawing.Point(2, 123);
this.btnIndexUp.Name = "btnIndexUp";
this.btnIndexUp.Size = new System.Drawing.Size(23, 23);
this.btnIndexUp.TabIndex = 28;
@@ -514,7 +513,7 @@
// groupBox2
//
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Location = new System.Drawing.Point(1, 2);
this.groupBox2.Location = new System.Drawing.Point(2, 7);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(232, 41);
this.groupBox2.TabIndex = 20;
@@ -524,9 +523,9 @@
// button6
//
this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.button6.Location = new System.Drawing.Point(130, 108);
this.button6.Location = new System.Drawing.Point(130, 119);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(51, 34);
this.button6.Size = new System.Drawing.Size(51, 28);
this.button6.TabIndex = 25;
this.button6.Text = "Zoom +";
this.button6.UseVisualStyleBackColor = true;
@@ -536,7 +535,8 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(829, 562);
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(1184, 574);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.button7);

View File

@@ -1,22 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
//using Syncfusion.Pdf.Parsing;
using Syncfusion.Pdf.Parsing;
//using System.Windows.Media.Imaging;
using System;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Windows.Forms;
namespace Mip
{
public partial class frmEditVyrobok : Form
{
string IDVyrobok;
DataTable pomocnaDT = new DataTable();
//Point poinPosition;
@@ -63,19 +61,19 @@ namespace Mip
public void VypisSpojenyRozmer()
{
string strSpojeny = "";
string strKonZnak ="";
string strKonZnak = "";
if (textBox2.Text != "")
{
if(textBox1.Text =="") strKonZnak = "";
else strKonZnak = " -" + textBox1.Text ;
if (textBox1.Text == "") strKonZnak = "";
else strKonZnak = " -" + textBox1.Text;
if (numericUpDown1.Value == 0)
{
if (textBox3.Text != "" && textBox3.Text != "0") strSpojeny = label10.Text + textBox2.Text + "/" + textBox3.Text + "x" + textBox4.Text + strKonZnak ;
else strSpojeny = label10.Text + textBox2.Text + "x" + textBox4.Text + strKonZnak ;
if (textBox3.Text != "" && textBox3.Text != "0") strSpojeny = label10.Text + textBox2.Text + "/" + textBox3.Text + "x" + textBox4.Text + strKonZnak;
else strSpojeny = label10.Text + textBox2.Text + "x" + textBox4.Text + strKonZnak;
}
else strSpojeny = label10.Text + textBox2.Text + "x" + textBox3.Text + "x" + textBox4.Text + strKonZnak ;
else strSpojeny = label10.Text + textBox2.Text + "x" + textBox3.Text + "x" + textBox4.Text + strKonZnak;
}
else strSpojeny = "";
label12.Text = strSpojeny;
@@ -85,16 +83,16 @@ namespace Mip
private void frmEditVyrobok_Load(object sender, EventArgs e)
{
pomocnaDT.Columns.Add("Nazov_suboru", typeof(string));
pomocnaDT.Columns.Add("Velkost_suboru", typeof(string));
pomocnaDT.Columns.Add("Cesta", typeof(string));
classGlobal.FillCB(comboBox2, "tabpomocnychudajov", "Hodnota", "Kategoria", "Pridať iný názov");
DataTable DTEditVyrobok = new DataTable();
//dGVZoznamVyrobkov.CurrentRow.Cells["IDVyrobok"].Value.ToString()
@@ -132,7 +130,7 @@ namespace Mip
private void dataGridView1_Paint(object sender, PaintEventArgs e)
{
dataGridView1.Columns["IDVyrobok"].Visible = false;
dataGridView1.Columns["IndexVykresu"].HeaderText = "Index";
dataGridView1.Columns["OldIndexVykresu"].Visible = false;
@@ -140,16 +138,16 @@ namespace Mip
dataGridView1.Columns["Cesta"].Visible = false;
dataGridView1.Columns["IDVykres"].Visible = false;
dataGridView1.Columns["StatusVykresu"].HeaderText = "Status";
dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.AutoResizeColumns();
}
@@ -159,9 +157,11 @@ namespace Mip
DataRow[] foundRows;
openFileDialog1.Multiselect = false;
openFileDialog1.DefaultExt = "jpg";
openFileDialog1.Filter = "Obrázky (*.BMP;*.JPG;*.JPEG;*.GIF;*.PNG;*.EXIF;*.TIFF)|*.BMP;*.JPG;*.JPEG;*.GIF;*.PNG;*.EXIF;*.TIFF|" + "Pdf súbory (*.pdf)|*.pdf";
openFileDialog1.FilterIndex = 1;
openFileDialog1.FileName = "";
openFileDialog1.ShowDialog();
int _index=0;
int _index = 0;
if (openFileDialog1.FileNames != null && openFileDialog1.FileName != "")
{
foreach (string FN in openFileDialog1.FileNames)
@@ -182,14 +182,14 @@ namespace Mip
FN.CopyTo(FN.LastIndexOf("\\") + 1, help, 0, (help.Length));
string hlp = new string(help);
foundRows =
foundRows =
DTVykresy.Select("IndexVykresu<100", "IndexVykresu DESC");
//ŠTVRTOK
_index=Convert.ToInt16(foundRows[0].ItemArray[1].ToString())+1;
_index = Convert.ToInt16(foundRows[0].ItemArray[1].ToString()) + 1;
DTVykresy.Rows.Add(dataGridView1.Rows[0].Cells["IDVyrobok"].Value.ToString(), //IDVyrobok
_index.ToString(), //index //Index vykresu
0,// OLDINDEX
@@ -202,30 +202,16 @@ namespace Mip
dataGridView1.DataSource = DTVykresy;
dataGridView1.AutoResizeColumns();
dataGridView1.AutoResizeRows();
//dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
//obrazok_Refresh(dataGridView1.Rows.Count - 1);
if (dataGridView1.Rows.Count > 4) dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.Rows.Count - 4;
}
else
{
MessageBox.Show("Súbor: " + FN + "\n už v zozname figuruje!", "Upozornenie ...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//MessageBox.Show(
}
//Zoradiť tabulku po pridani noveho výkresu a nastavenie selectu nan (POZOR môžu tam byť neaktívne výkresy)
DataTable pomocDTable = new DataTable();
pomocDTable = DTVykresy.Copy();
/*foreach (DataRow DT in DTVykresy.Rows)
{
DataRow pomocDT = DT;
pomocDTable.ImportRow(pomocDT);
}
*/
dataGridView1.DataSource = pomocDTable;
foundRows = pomocDTable.Select("", "IndexVykresu");
@@ -233,19 +219,16 @@ namespace Mip
DTVykresy = foundRows.CopyToDataTable();
dataGridView1.DataSource = DTVykresy;
//Nastavenie selectu na pridaný rows
int a=0;
for (int p1 = 0; p1 < DTVykresy.Rows.Count;p1++ )
int a = 0;
for (int p1 = 0; p1 < DTVykresy.Rows.Count; p1++)
{
DataRow DT;
DT = DTVykresy.Rows[p1];
if (Convert.ToInt32(DT["IndexVykresu"].ToString()) == _index) a=p1;
if (Convert.ToInt32(DT["IndexVykresu"].ToString()) == _index) a = p1;
}
dataGridView1.Rows[a].Selected = true;
@@ -253,52 +236,19 @@ namespace Mip
pictureBox1.Visible = true;
btnIndexDwn.Enabled = false; btnAktualVykres.Enabled = false;
}
}
//dataGridView1_SelectionChanged(sender,e);
}//
}
private void obrazok_Refresh(int index)
{
obrazok_Refresh2(index);
/*
FileStream fs;
int fileSize;
byte[] fileData;
//DataRow dRow;
//fs = new FileStream(dRow["Cesta"].ToString(), FileMode.Open, FileAccess.Read);//
fileSize = (int)fs.Length;
fileData = new byte[fileSize];
fs.Read(fileData, 0, fileSize);
fs.Close();
Bitmap obrazok;
//using (MemoryStream stream = new MemoryStream(fileData)) obrazok = new Bitmap(stream);
MemoryStream stream = new MemoryStream(fileData);
obrazok = new Bitmap(stream);
pictureBox1.Image = obrazok;
pictureBox1.Height = obrazok.Height;
pictureBox1.Width = obrazok.Width;
sizeH = pictureBox1.Image.Size.Height;
sizeW = pictureBox1.Image.Size.Width;
z = 1;
* */
}
private void obrazok_Refresh2(int _index)
{
DataRow dRow;
int indexvSQL=0;
string typ="";
dRow = DTVykresy.Rows[_index];
int indexvSQL = 0;
string typ = "";
dRow = DTVykresy.Rows[index];
typ = dRow["Názov"].ToString();
if (typ == "Z databázy SQL")
@@ -313,28 +263,42 @@ namespace Mip
sizeH = pictureBox1.Image.Size.Height;
sizeW = pictureBox1.Image.Size.Width;
z = 1;
}
if (typ != "Z databázy SQL" && typ!="")
if (typ != "Z databázy SQL" && typ != "")
{
FileStream fs;
int fileSize;
byte[] fileData;
//DataRow dRow;
//dRow = DTVykresy.Rows[_index];
var ExtensionStart = typ.LastIndexOf(".") + 1;
var Extension = typ.Substring(ExtensionStart, typ.Length - ExtensionStart);
fs = new FileStream(dRow["Cesta"].ToString(), FileMode.Open, FileAccess.Read);//
fileSize = (int)fs.Length;
fileData = new byte[fileSize];
fs.Read(fileData, 0, fileSize);
var fileToShow = new byte[fileSize];
if (Extension.ToLower() == "pdf")
{
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileData);
Bitmap pdfToJpeg = loadedDocument.ExportAsImage(0);
loadedDocument.Close(true);
fileToShow = SaveAsJpeg(pdfToJpeg);
}
else
{
fileToShow = fileData;
}
fs.Close();
Bitmap obrazok;
//using (MemoryStream stream = new MemoryStream(fileData)) obrazok = new Bitmap(stream);
MemoryStream stream = new MemoryStream(fileData);
obrazok = new Bitmap(stream);
MemoryStream stream = new MemoryStream(fileToShow);
var obrazok = new Bitmap(stream);
pictureBox1.Image = obrazok;
pictureBox1.Height = obrazok.Height;
pictureBox1.Width = obrazok.Width;
@@ -344,24 +308,36 @@ namespace Mip
}
}
private byte[] SaveAsJpeg(Bitmap image)
{
byte[] returnImageData;
using (var stream = new MemoryStream())
{
image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
returnImageData = stream.ToArray();
}
return returnImageData;
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (dataGridView1.DataSource != null && dataGridView1.SelectedRows.Count>0 && deleteRow!=true )
if (dataGridView1.DataSource != null && dataGridView1.SelectedRows.Count > 0 && deleteRow != true)
{
if (textBox6.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && dataGridView1.Rows.Count != 0) button5.Enabled = true;
else button5.Enabled = false; //kontrola naplnenia povinných dát
DataGridViewRow Row;
//Row = dataGridView1.Rows[dataGridView1.CurrentRow.Index];
Row = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index];
Row = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index];
int indexLastActiv;
DataRow[] foundRows;
foundRows = DTVykresy.Select("IndexVykresu<100", "IndexVykresu DESC");
indexLastActiv = DTVykresy.Rows.Count - foundRows.Length;
if (indexLastActiv == 0) indexLastActiv = DTVykresy.Rows.Count - 1; //Ak nie sú neaktívne výkresy, tak posledný aktivindex=posledny index
@@ -373,9 +349,9 @@ namespace Mip
btnVymazVykres.Enabled = false;
btnAktualVykres.Enabled = true;
//if(Row.Cells["StatusVykresu"].Value.ToString() == "AKTUÁLNY" btnAktualVykres.Text="Nastav ako neaktuálny" )
}
else // File výkres
{
btnVymazVykres.Enabled = true;
@@ -404,13 +380,13 @@ namespace Mip
}//ENDIF DT.Rows.Count!=0
}
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
}
private void zoradDTGView()
@@ -434,31 +410,24 @@ namespace Mip
//dataGridView1.DataSource=DTVykresy();
for (int p1 = 0; p1 < DTVykresy.Rows.Count; p1++)
{
if (Convert.ToInt32( dataGridView1.Rows[p1].Cells["IndexVykresu"].Value.ToString())== indexvykresu)
if (Convert.ToInt32(dataGridView1.Rows[p1].Cells["IndexVykresu"].Value.ToString()) == indexvykresu)
{
dataGridView1.Rows[p1].Selected=true;
dataGridView1.Rows[p1].Selected = true;
break;
}
}
}
private void btnAktualVykres_Click(object sender, EventArgs e)
{
if (dataGridView1.DataSource != null && dataGridView1.SelectedRows.Count > 0)
{
DataGridViewRow Row;
//Row = dataGridView1.Rows[dataGridView1.CurrentRow.Index];
Row = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index];
//Pre aktuálne výkresy nastav NEAKTUÁLNY
@@ -466,21 +435,21 @@ namespace Mip
{
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index]["StatusVykresu"] = "Neaktuálny";
int indexLastNeActiv;
DataRow[] foundRows;
foundRows = DTVykresy.Select("IndexVykresu>100", "IndexVykresu DESC");
if (foundRows.Length > 0) indexLastNeActiv = Convert.ToInt32(foundRows[0]["IndexVykresu"].ToString());
else indexLastNeActiv = 100;
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index]["IndexVykresu"] = indexLastNeActiv + 1;
zoradDTGView();
}
else
else
{
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index]["StatusVykresu"] = "Aktuálny";
int indexLastActiv;
@@ -492,32 +461,15 @@ namespace Mip
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index]["IndexVykresu"] = indexLastActiv + 1;
zoradDTGView();
}
}
/*
DataRow[] foundRows;
foundRows = DTVykresy.Select("IndexVykresu>100", "IndexVykresu DESC");
if (foundRows.Length == 0) DTVykresy.Rows[dataGridView1.CurrentRow.Index]["IndexVykresu"] = 101;
else DTVykresy.Rows[dataGridView1.CurrentRow.Index]["IndexVykresu"] = Convert.ToInt32(foundRows[0].ItemArray[1].ToString()) + 1;
DTVykresy.Rows[dataGridView1.CurrentRow.Index]["StatusVykresu"] = "NEAKTUÁLNY";
foundRows = DTVykresy.Select("", "IndexVykresu");
*/
}
private void btnIndexUp_Click(object sender, EventArgs e)
{
int oldindexvykresu;
oldindexvykresu = Convert.ToInt32(dataGridView1["IndexVykresu", (dataGridView1.SelectedRows[0].Index)].Value);
//dataGridView1["IndexVykresu", (dataGridView1.SelectedRows[0].Index)].Value = dataGridView1["IndexVykresu", (dataGridView1.SelectedRows[0].Index) - 1].Value;
//dataGridView1["IndexVykresu", (dataGridView1.SelectedRows[0].Index) - 1].Value = oldindexvykresu;
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index]["IndexVykresu"] = DTVykresy.Rows[dataGridView1.SelectedRows[0].Index-1]["IndexVykresu"];
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index]["IndexVykresu"] = DTVykresy.Rows[dataGridView1.SelectedRows[0].Index - 1]["IndexVykresu"];
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index - 1]["IndexVykresu"] = oldindexvykresu;
zoradDTGView();
@@ -526,10 +478,7 @@ namespace Mip
private void btnIndexDwn_Click(object sender, EventArgs e)
{
int oldindexvykresu;
oldindexvykresu = Convert.ToInt32(dataGridView1["IndexVykresu", (dataGridView1.SelectedRows[0].Index)].Value);
//dataGridView1["IndexVykresu", (dataGridView1.SelectedRows[0].Index)].Value = dataGridView1["IndexVykresu", (dataGridView1.SelectedRows[0].Index) + 1].Value;
//dataGridView1["IndexVykresu", (dataGridView1.SelectedRows[0].Index) + 1].Value = oldindexvykresu;
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index]["IndexVykresu"] = DTVykresy.Rows[dataGridView1.SelectedRows[0].Index + 1]["IndexVykresu"];
DTVykresy.Rows[dataGridView1.SelectedRows[0].Index + 1]["IndexVykresu"] = oldindexvykresu;
@@ -548,7 +497,7 @@ namespace Mip
{
if (dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor != Color.White) dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;
}
}
@@ -561,101 +510,52 @@ namespace Mip
{
string cmd;
DataTable dtbl;
classGlobal.strNovyPomocnyUdaj = textBox6.Text; //pomocný údaj pre naplnenie comboboxu po zavreti okna
if (textBox7.Text == "") textBox7.Text = "1"; // Ak je pocet segmentov "" tak potom je 1
/* MENIME NA UPDATE
cmd = "INSERT INTO `mip`.`tabvyrobok` (`NazovVyrobku`, `RozmerTvar`, `Rozmer1`, `Rozmer2`, `Rozmer3`, `SpojeneRozmery`, `Zakaznik`, `InyNazov`, `RozlisZnakKonecnaOp`, `Alias`,`PocetSegmentov`) VALUES ('"
+ textBox6.Text.ToString() + "', '" //NazovVyrobku*
+ label10.Text.ToString() + "', " //RozmerTvar
+ textBox2.Text.ToString().Replace(",",".") + ", " //rozmer1
+ textBox3.Text.ToString().Replace(",", ".") + "," //rozmer2
+ textBox4.Text.ToString().Replace(",", ".") + ", '" //rozmer3
+ label12.Text.ToString() + "', '" //spojene rozmery*
+ label2.Text.ToString() + "', '" //zakaznik*
+ comboBox2.Text.ToString() + "', '" //Iny nazov*
+ textBox1.Text.ToString() + "', '" //rozlis znak alebo konecna operacia*
+ textBox5.Text.ToString() + "', " //alias*
+ textBox7.Text.ToString() + ");"; //Pocet segmetnov
cmd = @"UPDATE `mip`.`tabvyrobok` SET "
+ "`NazovVyrobku`='" + textBox6.Text.ToString() + "'," //NazovVyrobku*
+ "`RozmerTvar`='" + label10.Text.ToString() + "'," //RozmerTvar
+ "`Rozmer1`=" + textBox2.Text.ToString().Replace(",", ".") + "," //rozmer1
+ "`Rozmer2`=" + textBox3.Text.ToString().Replace(",", ".") + "," //rozmer2
+ "`Rozmer3`=" + textBox4.Text.ToString().Replace(",", ".") + "," //rozmer3
+ "`SpojeneRozmery`='" + label12.Text.ToString() + "'," //Spojené rozmery*
+ "`Zakaznik`='" + label2.Text.ToString() + "'," //zakaznik*
+ "`InyNazov`='" + comboBox2.Text.ToString() + "'," //Iny nazov*
+ "`RozlisZnakKonecnaOp`='" + textBox1.Text.ToString() + "'," //rozlis znak alebo konecna operacia*
+ "`Alias`='" + textBox5.Text.ToString() + "'," //alias*
+ "`PocetSegmentov`=" + textBox7.Text.ToString() //pocet segmentnov
+ " WHERE (`IDVyrobok`="
+ IDVyrobok + ");";
dtbl=classSQL.commandSQL(cmd,1);
*/
cmd = @"UPDATE `mip`.`tabvyrobok` SET "
+ "`NazovVyrobku`='" + textBox6.Text.ToString() + "'," //NazovVyrobku*
+ "`RozmerTvar`='" + label10.Text.ToString() + "'," //RozmerTvar
+"`Rozmer1`=" + textBox2.Text.ToString().Replace(",", ".") + "," //rozmer1
+"`Rozmer2`=" + textBox3.Text.ToString().Replace(",", ".") + "," //rozmer2
+"`Rozmer3`=" + textBox4.Text.ToString().Replace(",", ".") + "," //rozmer3
+ "`SpojeneRozmery`='" + label12.Text.ToString() + "'," //Spojené rozmery*
+ "`Zakaznik`='" + label2.Text.ToString() + "'," //zakaznik*
+ "`InyNazov`='" + comboBox2.Text.ToString() + "'," //Iny nazov*
+ "`RozlisZnakKonecnaOp`='" + textBox1.Text.ToString() + "'," //rozlis znak alebo konecna operacia*
+ "`Alias`='" + textBox5.Text.ToString() + "'," //alias*
+"`PocetSegmentov`=" + textBox7.Text.ToString() //pocet segmentnov
+ " WHERE (`IDVyrobok`="
+ IDVyrobok+");";
classSQL.SQL(cmd,out dtbl);
//================== Zistuje IDVykresu podla PridatVykres ======================================
/*
// <Pridať výkresovú dokumentáciu do tabvykresy>
int intIDVyrobok;
//classSQL.commandSQL("SELECT `IDVyrobok` FROM `mip`.`tabvyrobok` WHERE `Zakaznik`= '" + label2.Text + "';");
// IDVyrobok = (int)classSQL.dTable.Rows[0]["IDVyrobok"];
string ccmmdd = "SELECT `NazovVyrobku`,`IDVyrobok` FROM `mip`.`tabvyrobok` WHERE `Zakaznik`= '" + label2.Text
+ "' AND `NazovVyrobku` = '" + textBox6.Text + "';";
dtbl=classSQL.commandSQL(ccmmdd,1);
DataRow dtrw = dtbl.Rows[0];
intIDVyrobok = Convert.ToInt32(dtrw["IDVyrobok"].ToString());
*/
classSQL.SQL(cmd, out dtbl);
int intIDVyrobok;
DataRow dtrw;
intIDVyrobok = Convert.ToInt32(IDVyrobok);
/*
string ccmmdd = "SELECT `NazovVyrobku`,`IDVyrobok` FROM `mip`.`tabvyrobok` WHERE `Zakaznik`= '" + label2.Text
+ "' AND `NazovVyrobku` = '" + textBox6.Text + "';";
dtbl = classSQL.commandSQL(ccmmdd, 1);
DataRow dtrw = dtbl.Rows[0];
*/
for (int p1=0; p1 < DTVykresy.Rows.Count; p1++)
for (int p1 = 0; p1 < DTVykresy.Rows.Count; p1++)
{
FileStream fs;
int fileSize;
byte[] VykresData;
dtrw = DTVykresy.Rows[p1];
//=== Zistiť či sa jedná o súbor alebo SQL výkres
if (dtrw["Cesta"].ToString() == "-")
{
if (dtrw["IndexVykresu"].ToString() != dtrw["OldIndexVykresu"].ToString())
{
cmd = @"UPDATE `mip`.`tabvykres` SET "
+ "`IndexVykresu`=" + Convert.ToInt32(dtrw["IndexVykresu"].ToString())
+ " WHERE (`IDVykres`="
+ Convert.ToInt32(dtrw["IDVykres"].ToString()) + ");" ;
cmd = @"UPDATE `mip`.`tabvykres` SET "
+ "`IndexVykresu`=" + Convert.ToInt32(dtrw["IndexVykresu"].ToString())
+ " WHERE (`IDVykres`="
+ Convert.ToInt32(dtrw["IDVykres"].ToString()) + ");";
classSQL.SQL(cmd, out dtbl);
classSQL.SQL(cmd, out dtbl);
}
}
else
{
@@ -663,20 +563,34 @@ namespace Mip
fileSize = (int)fs.Length;
VykresData = new byte[fileSize];
fs.Read(VykresData, 0, fileSize);
var ExtensionStart = dtrw["Cesta"].ToString().LastIndexOf(".") + 1;
var Extension = dtrw["Cesta"].ToString().Substring(ExtensionStart, dtrw["Cesta"].ToString().Length - ExtensionStart);
var fileToShow = new byte[fileSize];
if (Extension.ToLower() == "pdf")
{
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(VykresData);
Bitmap pdfToJpeg = loadedDocument.ExportAsImage(0);
loadedDocument.Close(true);
fileToShow = SaveAsJpeg(pdfToJpeg);
}
else
{
fileToShow = VykresData;
}
fs.Close();
classSQL.SaveVykresToSQL(intIDVyrobok, Convert.ToInt32(dtrw["IndexVykresu"].ToString()), VykresData);
classSQL.SaveVykresToSQL(intIDVyrobok, Convert.ToInt32(dtrw["IndexVykresu"].ToString()), fileToShow);
}
}
MessageBox.Show("Výrobok úspešne aktualizovaný!");
this.DialogResult = DialogResult.OK;
this.Close();
MessageBox.Show("Výrobok úspešne aktualizovaný!");
this.DialogResult = DialogResult.OK;
this.Close();
// </Pridať výkresovú dokumentáciu do tabvykresy>
// </Pridať výkresovú dokumentáciu do tabvykresy>
}
@@ -686,7 +600,7 @@ namespace Mip
int currentRowIndex = dataGridView1.SelectedRows[0].Index;
DTVykresy.Rows[currentRowIndex].Delete();
DTVykresy.Rows[currentRowIndex].AcceptChanges();
if (DTVykresy.Rows.Count == 0)
{
btnVymazVykres.Enabled = false;
@@ -802,7 +716,7 @@ namespace Mip
}
VypisSpojenyRozmer();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Syncfusion.Pdf.Parsing;
using System;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using Syncfusion.Pdf.Parsing;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace Mip
@@ -18,29 +12,29 @@ namespace Mip
{
DataTable pomocnaDT = new DataTable();
Point poinPosition;
bool deleteRow=false;
Single z=1;
bool deleteRow = false;
Single z = 1;
int sizeH;
int sizeW;
string IDVyrobok;
DataTable DTVykresy = new DataTable();
public frmPridatVyrobok(string strZakaznik, string idVyrobok = null)
{
InitializeComponent();
label2.Text = strZakaznik;
IDVyrobok = idVyrobok;
this.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel);
}
private void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
{
if(pictureBox1.Image != null)
if (pictureBox1.Image != null)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
z += (Convert.ToSingle(0.1) * (e.Delta / Math.Abs(e.Delta)));
pictureBox1.Height = Convert.ToInt32(sizeH * z);
pictureBox1.Height = Convert.ToInt32(sizeH * z);
pictureBox1.Width = Convert.ToInt32(sizeW * z);
if (dataGridView1.RowCount != 0)
{
@@ -53,52 +47,52 @@ namespace Mip
private void frmPridatVyrobok_Load(object sender, EventArgs e)
{
pomocnaDT.Columns.Add("Nazov_suboru",typeof (string));
pomocnaDT.Columns.Add("Velkost_suboru",typeof (string));
pomocnaDT.Columns.Add("Nazov_suboru", typeof(string));
pomocnaDT.Columns.Add("Velkost_suboru", typeof(string));
pomocnaDT.Columns.Add("Typ_suboru", typeof(string));
pomocnaDT.Columns.Add("Cesta",typeof (string));
pomocnaDT.Columns.Add("Cesta", typeof(string));
pomocnaDT.Columns.Add("Data", typeof(string));
pomocnaDT.Columns.Add("Valid", typeof(int));
VypisSpojenyRozmer();
classGlobal.FillCB(comboBox2, "tabpomocnychudajov", "Hodnota", "Kategoria", "Pridať iný názov");
if (IDVyrobok != null)
{
LoadEditData();
}
//if (IDVyrobok != null)
//{
// LoadEditData();
//}
}
private void LoadEditData()
{
DataTable DTEditVyrobok = new DataTable();
//dGVZoznamVyrobkov.CurrentRow.Cells["IDVyrobok"].Value.ToString()
//private void LoadEditData()
//{
// DataTable DTEditVyrobok = new DataTable();
// //dGVZoznamVyrobkov.CurrentRow.Cells["IDVyrobok"].Value.ToString()
classSQL.SQL("SELECT * FROM tabvyrobok WHERE `IDVyrobok` = " + IDVyrobok + ";", out DTEditVyrobok);
label2.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Zakaznik"].Ordinal].ToString();
textBox6.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["NazovVyrobku"].Ordinal].ToString();
comboBox2.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["InyNazov"].Ordinal].ToString();
// classSQL.SQL("SELECT * FROM tabvyrobok WHERE `IDVyrobok` = " + IDVyrobok + ";", out DTEditVyrobok);
// label2.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Zakaznik"].Ordinal].ToString();
// textBox6.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["NazovVyrobku"].Ordinal].ToString();
// comboBox2.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["InyNazov"].Ordinal].ToString();
if (DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["RozmerTvar"].Ordinal].ToString() == "Ø") numericUpDown1.Value = 0;
else numericUpDown1.Value = 1;
textBox2.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Rozmer1"].Ordinal].ToString();
textBox3.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Rozmer2"].Ordinal].ToString();
textBox4.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Rozmer3"].Ordinal].ToString();
// if (DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["RozmerTvar"].Ordinal].ToString() == "Ø") numericUpDown1.Value = 0;
// else numericUpDown1.Value = 1;
// textBox2.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Rozmer1"].Ordinal].ToString();
// textBox3.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Rozmer2"].Ordinal].ToString();
// textBox4.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Rozmer3"].Ordinal].ToString();
textBox1.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["RozlisZnakKonecnaOp"].Ordinal].ToString();
textBox5.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Alias"].Ordinal].ToString();
textBox7.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["PocetSegmentov"].Ordinal].ToString();
VypisSpojenyRozmer();
// textBox1.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["RozlisZnakKonecnaOp"].Ordinal].ToString();
// textBox5.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["Alias"].Ordinal].ToString();
// textBox7.Text = DTEditVyrobok.Rows[0].ItemArray[DTEditVyrobok.Columns["PocetSegmentov"].Ordinal].ToString();
// VypisSpojenyRozmer();
string cmd = @"SELECT `IDVyrobok`,
`IndexVykresu`,
`IndexVykresu` AS `OldIndexVykresu`,
'Z databázy SQL' AS `Názov`,
'-' AS `Cesta`,
`IDVykres`,
IF (`IndexVykresu` < 100, 'Aktuálny','Neaktuálny') AS `StatusVykresu`
FROM `mip`.`tabvykres` WHERE `IDVyrobok` = " + IDVyrobok + " ORDER BY `IndexVykresu` ;";
classSQL.SQL(cmd, out DTVykresy);
dataGridView1.DataSource = DTVykresy;
}
// string cmd = @"SELECT `IDVyrobok`,
// `IndexVykresu`,
// `IndexVykresu` AS `OldIndexVykresu`,
// 'Z databázy SQL' AS `Názov`,
// '-' AS `Cesta`,
// `IDVykres`,
// IF (`IndexVykresu` < 100, 'Aktuálny','Neaktuálny') AS `StatusVykresu`
// FROM `mip`.`tabvykres` WHERE `IDVyrobok` = " + IDVyrobok + " ORDER BY `IndexVykresu` ;";
// classSQL.SQL(cmd, out DTVykresy);
// dataGridView1.DataSource = DTVykresy;
//}
private void btnAddVykres_Click(object sender, EventArgs e)
{
@@ -118,7 +112,7 @@ namespace Mip
{
if (rowCesta["Cesta"].ToString() == Cesta.ToString()) CestaExist = true;
}
if (!CestaExist)
{
FileStream fileStream;
@@ -156,7 +150,7 @@ namespace Mip
private void StyleGridView()
{
dataGridView1.Columns["Data"].Visible = false;
dataGridView1.AutoResizeColumns();
dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
@@ -193,7 +187,7 @@ namespace Mip
private void btnVymazVykres_Click(object sender, EventArgs e)
{
deleteRow = true;
int currentRowIndex = dataGridView1.CurrentRow.Index;
int currentRowIndex = dataGridView1.CurrentRow.Index;
pomocnaDT.Rows[currentRowIndex].Delete();
if (pomocnaDT.Rows.Count == 0)
{
@@ -209,7 +203,7 @@ namespace Mip
obrazok_Refresh(currentRowIndex);
pictureBox1.Visible = true;
}
if (textBox6.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && dataGridView1.Rows.Count !=0) button5.Enabled = true;
if (textBox6.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && dataGridView1.Rows.Count != 0) button5.Enabled = true;
else button5.Enabled = false; //kontrola naplnenia povinných dát
}
@@ -227,13 +221,13 @@ namespace Mip
button1.Enabled = true;
if (textBox6.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && dataGridView1.Rows.Count != 0) button5.Enabled = true;
else button5.Enabled = false; //kontrola naplnenia povinných dát
if (!deleteRow) obrazok_Refresh(e.RowIndex);
else deleteRow = false;
}
@@ -246,12 +240,12 @@ namespace Mip
DataRow dRow;
if (pomocnaDT.Rows.Count != 0)
{
dRow = pomocnaDT.Rows[index];
dRow = pomocnaDT.Rows[index];
var isPdf = dRow["Typ_suboru"].ToString() == "pdf";
var isValid = dRow["Valid"].ToString() == "1";
if(isValid)
if (isValid)
{
if (isPdf)
{
@@ -293,7 +287,7 @@ namespace Mip
}
private void label9_Click(object sender, EventArgs e)
{
@@ -308,7 +302,7 @@ namespace Mip
private void textBox2_TextChanged(object sender, EventArgs e)
{
VypisSpojenyRozmer();
if (textBox6.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && dataGridView1.Rows.Count != 0) button5.Enabled = true;
else button5.Enabled = false; //kontrola naplnenia povinných dát
}
@@ -316,19 +310,19 @@ namespace Mip
public void VypisSpojenyRozmer()
{
string strSpojeny = "";
string strKonZnak ="";
string strKonZnak = "";
if (textBox2.Text != "")
{
if(textBox1.Text =="") strKonZnak = "";
else strKonZnak = " -" + textBox1.Text ;
if (textBox1.Text == "") strKonZnak = "";
else strKonZnak = " -" + textBox1.Text;
if (numericUpDown1.Value == 0)
{
if (textBox3.Text != "" && textBox3.Text != "0") strSpojeny = label10.Text + textBox2.Text + "/" + textBox3.Text + "x" + textBox4.Text + strKonZnak ;
else strSpojeny = label10.Text + textBox2.Text + "x" + textBox4.Text + strKonZnak ;
if (textBox3.Text != "" && textBox3.Text != "0") strSpojeny = label10.Text + textBox2.Text + "/" + textBox3.Text + "x" + textBox4.Text + strKonZnak;
else strSpojeny = label10.Text + textBox2.Text + "x" + textBox4.Text + strKonZnak;
}
else strSpojeny = label10.Text + textBox2.Text + "x" + textBox3.Text + "x" + textBox4.Text + strKonZnak ;
else strSpojeny = label10.Text + textBox2.Text + "x" + textBox3.Text + "x" + textBox4.Text + strKonZnak;
}
else strSpojeny = "";
label12.Text = strSpojeny;
@@ -414,7 +408,7 @@ namespace Mip
private void dataGridView1_DataMemberChanged(object sender, EventArgs e)
{
}
private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
@@ -461,13 +455,13 @@ namespace Mip
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point changePoint = new Point (e.Location.X - poinPosition.X, e.Location.Y - poinPosition.Y);
panel1.AutoScrollPosition = new Point(-panel1.AutoScrollPosition.X - changePoint.X, -panel1.AutoScrollPosition.Y - changePoint.Y);
Point changePoint = new Point(e.Location.X - poinPosition.X, e.Location.Y - poinPosition.Y);
panel1.AutoScrollPosition = new Point(-panel1.AutoScrollPosition.X - changePoint.X, -panel1.AutoScrollPosition.Y - changePoint.Y);
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
@@ -479,7 +473,7 @@ namespace Mip
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
z += Convert.ToSingle(0.1);
pictureBox1.Height = Convert.ToInt32(sizeH * z);
pictureBox1.Height = Convert.ToInt32(sizeH * z);
pictureBox1.Width = Convert.ToInt32(sizeW * z);
if (dataGridView1.RowCount != 0)
{
@@ -493,7 +487,7 @@ namespace Mip
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
z -= Convert.ToSingle(0.1);
pictureBox1.Height = Convert.ToInt32(sizeH * z);
pictureBox1.Height = Convert.ToInt32(sizeH * z);
pictureBox1.Width = Convert.ToInt32(sizeW * z);
if (dataGridView1.RowCount != 0)
{
@@ -509,8 +503,8 @@ namespace Mip
char[] nnazov = new char[nazov.LastIndexOf(".")];
nazov.CopyTo(0, nnazov, 0, nnazov.Length);
textBox6.Text = new string(nnazov);
textBox6.Text = new string(nnazov);
}
private void button2_Click(object sender, EventArgs e)
@@ -533,7 +527,7 @@ namespace Mip
+ "' AND `NazovVyrobku` = '" + textBox6.Text + "';", out dtbl);
if (dtbl.Rows.Count != 0) MessageBox.Show("Výrobok s názvom: \n " + textBox6.Text + "\n v datábáze výrobkov odberateľa " + label2.Text + " už existuje!!!\n Prosím zmeňte názov výrobku", "Pozor ... ",
MessageBoxButtons.OK,MessageBoxIcon.Warning); //Ak sa výrobok v databaze uz nachádza
MessageBoxButtons.OK, MessageBoxIcon.Warning); //Ak sa výrobok v databaze uz nachádza
else // ak sa výrobok v dtbaze nenachádza tak ho pridať
{
classGlobal.strNovyPomocnyUdaj = textBox6.Text; //pomocný údaj pre naplnenie comboboxu po zavreti okna
@@ -545,7 +539,7 @@ namespace Mip
cmd = "INSERT INTO `mip`.`tabvyrobok` (`NazovVyrobku`, `RozmerTvar`, `Rozmer1`, `Rozmer2`, `Rozmer3`, `SpojeneRozmery`, `Zakaznik`, `InyNazov`, `RozlisZnakKonecnaOp`, `Alias`,`PocetSegmentov`, `Status výrobku`) VALUES ('"
+ textBox6.Text.ToString() + "', '" //NazovVyrobku
+ label10.Text.ToString() + "', " //RozmerTvar
+ textBox2.Text.ToString().Replace(",",".") + ", " //rozmer1
+ textBox2.Text.ToString().Replace(",", ".") + ", " //rozmer1
+ textBox3.Text.ToString().Replace(",", ".") + "," //rozmer2
+ textBox4.Text.ToString().Replace(",", ".") + ", '" //rozmer3
+ label12.Text.ToString() + "', '" //spojene rozmery
@@ -562,7 +556,7 @@ namespace Mip
// <Pridať výkresovú dokumentáciu do tabvykresy>
int IDVyrobok;
//classSQL.commandSQL("SELECT `IDVyrobok` FROM `mip`.`tabvyrobok` WHERE `Zakaznik`= '" + label2.Text + "';");
// IDVyrobok = (int)classSQL.dTable.Rows[0]["IDVyrobok"];
// IDVyrobok = (int)classSQL.dTable.Rows[0]["IDVyrobok"];
string ccmmdd = "SELECT `NazovVyrobku`,`IDVyrobok` FROM `mip`.`tabvyrobok` WHERE `Zakaznik`= '" + label2.Text
+ "' AND `NazovVyrobku` = '" + textBox6.Text + "';";
@@ -573,22 +567,22 @@ namespace Mip
var indexVykresu = 1;
for (int p1=0; p1 < pomocnaDT.Rows.Count; p1++)
for (int p1 = 0; p1 < pomocnaDT.Rows.Count; p1++)
{
FileStream fs;
int fileSize;
byte[] VykresData;
dtrw=pomocnaDT.Rows[p1];
dtrw = pomocnaDT.Rows[p1];
var isValid = dtrw["Valid"].ToString() == "1";
if(isValid)
if (isValid)
{
fs = new FileStream(dtrw["Cesta"].ToString(), FileMode.Open, FileAccess.Read);
fileSize = (int)fs.Length;
VykresData = new byte[fileSize];
fs.Read(VykresData, 0, fileSize);
var fileToSave = new byte[fileSize];
switch (dtrw["Typ_suboru"].ToString())
@@ -610,7 +604,7 @@ namespace Mip
fileToSave = SaveAsJpeg(imageToJpeg);
break;
}
fs.Close();
classSQL.SaveVykresToSQL(IDVyrobok, indexVykresu, fileToSave);
indexVykresu += 1;
@@ -646,7 +640,7 @@ namespace Mip
private void textBox6_TextChanged(object sender, EventArgs e)
{
if (textBox6.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && dataGridView1.Rows.Count != 0) button5.Enabled = true;
else button5.Enabled = false; //kontrola naplnenia povinných dát
@@ -670,8 +664,8 @@ namespace Mip
*/
if((int)e.KeyChar!=8) foreach (char znak in Path.GetInvalidFileNameChars()) if (e.KeyChar == znak) e.KeyChar = '\0';
if ((int)e.KeyChar != 8) foreach (char znak in Path.GetInvalidFileNameChars()) if (e.KeyChar == znak) e.KeyChar = '\0';
}
private void toolTip1_Popup(object sender, PopupEventArgs e)