Initial commit
This commit is contained in:
726
Mip/classGlobal.cs
Normal file
726
Mip/classGlobal.cs
Normal file
@@ -0,0 +1,726 @@
|
||||
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;
|
||||
|
||||
namespace Mip
|
||||
{
|
||||
class classGlobal
|
||||
{
|
||||
private static char Disk = 'W';
|
||||
|
||||
/// <summary>
|
||||
/// Vytvorí v RAM disk W:
|
||||
/// </summary>
|
||||
public static void CreateRamDisk()
|
||||
{
|
||||
classDiskOperations.CreatePath();
|
||||
//classDiskOperations.RemoveCurrentUserProtecion(classDiskOperations.TempPath);
|
||||
classDiskOperations.MapDrive(Disk, classDiskOperations.TempPath);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Vymaže RAM disk W:
|
||||
/// </summary>
|
||||
|
||||
public static void DeleteRamDisk()
|
||||
{
|
||||
string TempPath = Application.StartupPath + @"\MipTemp";
|
||||
classDiskOperations.CreatePath();
|
||||
classDiskOperations.UnmapDrive(Disk);
|
||||
classDiskOperations.RemovePath(TempPath);
|
||||
//classDiskOperations.AddCurrentUserProtecion(classDiskOperations.TempPath);
|
||||
|
||||
}
|
||||
|
||||
//Stara verzia s pouzitim imdisk a vytvorenim noveho RAM disku
|
||||
|
||||
/*
|
||||
private static string Disk = "W:";
|
||||
|
||||
//cmd /C imdisk -a -s 10M -m W: -p "/fs:fat /q /y"
|
||||
//cmd /C imdisk -D -m W:
|
||||
//net user administrator /active:yes
|
||||
|
||||
/// <summary>
|
||||
/// Vytvorí v RAM disk W:
|
||||
/// </summary>
|
||||
public static void CreateRamDisk()
|
||||
{
|
||||
ProcessStartInfo procStartInfo = new ProcessStartInfo();
|
||||
procStartInfo.UseShellExecute = false;
|
||||
procStartInfo.CreateNoWindow = true;
|
||||
procStartInfo.Verb = "runas";
|
||||
procStartInfo.FileName = "cmd";
|
||||
procStartInfo.Arguments = "/C imdisk -a -s 10M -m " + Disk + " -p \"/fs:fat /q /y\"";
|
||||
var process = Process.Start(procStartInfo);
|
||||
process.WaitForExit();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Vymaže RAM disk W:
|
||||
/// </summary>
|
||||
|
||||
public static void DeleteRamDisk()
|
||||
{
|
||||
ProcessStartInfo procStartInfo = new ProcessStartInfo();
|
||||
procStartInfo.UseShellExecute = false;
|
||||
procStartInfo.CreateNoWindow = true;
|
||||
procStartInfo.FileName = "cmd";
|
||||
procStartInfo.Arguments = "/C imdisk -D -m " + Disk;
|
||||
Process.Start(procStartInfo);
|
||||
var process = Process.Start(procStartInfo);
|
||||
process.WaitForExit();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public static string strNovyPomocnyUdaj;
|
||||
|
||||
/// <summary>
|
||||
/// Naplna comboBox cb udajmi z SQL servera
|
||||
/// </summary>
|
||||
/// <param name="cb"> nazov naplnaneho comboBoxu</param>
|
||||
/// <param name="strTab"> nazov tabulky z ktorej comboBox naplname</param>
|
||||
/// <param name="strCollumn"> nazov stlpca z tabulky z ktorého data naplname do comboBoxu</param>
|
||||
public static void FillCB(ComboBox cb, string strTab, string strCollumn)
|
||||
{
|
||||
DataTable dtbl = new DataTable();
|
||||
string c = "SELECT DISTINCT `"
|
||||
+ strCollumn + "` FROM `mip`.`"
|
||||
+ strTab + "` ORDER BY "
|
||||
+ strCollumn + ";";
|
||||
|
||||
classSQL.SQL(c, out dtbl);
|
||||
cb.Items.Clear();
|
||||
foreach (DataRow row in dtbl.Rows)
|
||||
{
|
||||
cb.Items.Add(row[strCollumn].ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Naplna comboBox cb udajmi z SQL servera
|
||||
/// </summary>
|
||||
/// <param name="cb"> nazov naplnaneho comboBoxu</param>
|
||||
/// <param name="strTab"> nazov tabulky z ktorej comboBox naplname</param>
|
||||
/// <param name="strCollumn"> nazov stlpca z tabulky z ktorého data naplname do comboBoxu</param>
|
||||
/// <param name="strCollumnWhere"> nazov stlpca v ktorom sa nachadza hladana hodnota</param>
|
||||
/// <param name="strHodnotaWhere"> hladana hodnota</param>
|
||||
public static void FillCB(ComboBox cb, string strTab, string strCollumn, string strCollumnWhere, string strHodnotaWhere)
|
||||
{
|
||||
DataTable dtbl = new DataTable();
|
||||
string c = "SELECT DISTINCT `" + strCollumn
|
||||
+ "` FROM `mip`.`" + strTab
|
||||
+ "` WHERE `" + strCollumnWhere
|
||||
+ "` = '" + strHodnotaWhere
|
||||
+ "' ORDER BY " + strCollumn
|
||||
+ ";";
|
||||
|
||||
|
||||
classSQL.SQL(c, out dtbl);
|
||||
cb.Items.Clear();
|
||||
foreach (DataRow row in dtbl.Rows)
|
||||
{
|
||||
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 (Urceny pre comboboxy na vydaj a prijem do skladu vyrobkov, konvertuje nazvy krabic(string na integer))
|
||||
/// </summary>
|
||||
/// <param name="cb"> nazov naplnaneho comboBoxu</param>
|
||||
/// <param name="strTab"> nazov tabulky z ktorej comboBox naplname</param>
|
||||
/// <param name="strCollumn"> nazov stlpca z tabulky z ktorého data naplname do comboBoxu</param>
|
||||
/// <param name="strCollumnWhere"> nazov stlpca v ktorom sa nachadza hladana hodnota</param>
|
||||
/// <param name="strHodnotaWhere"> hladana hodnota</param>
|
||||
public static void FillCBSklad(ComboBox cb, string strTab, string strCollumn, string strCollumnWhere, string strHodnotaWhere)
|
||||
{
|
||||
//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 "
|
||||
+ " FROM `mip`.`" + strTab
|
||||
+ "` WHERE `" + strCollumnWhere
|
||||
+ "` = '" + strHodnotaWhere
|
||||
+ "' ORDER BY NUMBER;";
|
||||
|
||||
classSQL.SQL(c, out dtbl);
|
||||
cb.Items.Clear();
|
||||
foreach (DataRow row in dtbl.Rows)
|
||||
{
|
||||
cb.Items.Add(row["NUMBER"].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Naplna comboBox cb udajmi z SQL servera s pridaným textboxom ako filtrom
|
||||
/// </summary>
|
||||
/// <param name="cb"> nazov naplnaneho comboBoxu</param>
|
||||
/// <param name="strTab"> nazov tabulky z ktorej comboBox naplname</param>
|
||||
/// <param name="strCollumn"> nazov stlpca z tabulky z ktorého data naplname do comboBoxu</param>
|
||||
/// <param name="strCollumnWhere"> nazov stlpca v ktorom sa nachadza hladana hodnota</param>
|
||||
/// <param name="strHodnotaWhere"> hladana hodnota</param>
|
||||
/// <param name="tb"> hodnota z textboxu podla ktorej sa tiez filtruju polozky v comboboxe</param>
|
||||
public static void FillCB(ComboBox cb, string strTab, string strCollumn, string strCollumnWhere, string strHodnotaWhere, TextBox tb)
|
||||
{
|
||||
DataTable dtbl = new DataTable();
|
||||
string c = "SELECT DISTINCT `" + strCollumn
|
||||
+ "` FROM `mip`.`" + strTab
|
||||
+ "` WHERE `" + strCollumnWhere
|
||||
+ "` = '" + strHodnotaWhere
|
||||
+ "' AND INSTR(`" + strCollumn + "`, '" + tb.Text + "')>0"
|
||||
+ " ORDER BY " + strCollumn
|
||||
+ ";";
|
||||
|
||||
classSQL.SQL(c, out dtbl);
|
||||
cb.Items.Clear();
|
||||
foreach (DataRow row in dtbl.Rows)
|
||||
{
|
||||
cb.Items.Add(row[strCollumn].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Nastavi farbu riadkov v datagridview
|
||||
/// </summary>
|
||||
/// <param name="dgv"> nazov prefarbovaneho datagridview</param>
|
||||
/// <param name="eColumnIndex"> e.columnindex odosielatela</param>
|
||||
/// <param name="eRowIndex"> e.rowindex odosielatela</param>
|
||||
/// <param name="eValue"> stringova hodnota e.value odosielatela</param>
|
||||
public static void SetRowColor(DataGridView dgv, int eColumnIndex, int eRowIndex, string eValue)
|
||||
{
|
||||
if (dgv.DataSource != null)
|
||||
{
|
||||
if (eColumnIndex == dgv.Columns["StatusDopytu"].Index)
|
||||
{
|
||||
string RepVisits = eValue.ToString();
|
||||
if (RepVisits != null)
|
||||
{
|
||||
if (RepVisits == "Prijatý" || RepVisits == "Prijatá")
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.ForeColor = Color.Black;
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
}
|
||||
if (RepVisits == "Zrušená" || RepVisits == "Zrušený")
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.ForeColor = Color.Red;
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.MistyRose;
|
||||
}
|
||||
if (RepVisits == "Vo výrobe")
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.ForeColor = Color.DarkGreen;
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.Honeydew;
|
||||
}
|
||||
if (RepVisits == "Zaradená do výroby")
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.ForeColor = Color.SaddleBrown;
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.AntiqueWhite;
|
||||
}
|
||||
if (RepVisits == "Na lapovni")
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.ForeColor = Color.MidnightBlue;
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.Azure;
|
||||
}
|
||||
if (RepVisits == "Pozastavená" || RepVisits == "Pozastavený")
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.ForeColor = Color.Red;
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.MistyRose;
|
||||
}
|
||||
if (RepVisits == "Skončený" || RepVisits == "Odoslaná" || RepVisits == "Odoslaný")
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.ForeColor = Color.Olive;
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.LightGoldenrodYellow;
|
||||
}
|
||||
if (RepVisits == "Nacenená")
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.ForeColor = Color.DarkMagenta;
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.LavenderBlush;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Nastavi farbu riadkov v datagridview
|
||||
/// </summary>
|
||||
/// <param name="dgv"> nazov prefarbovaneho datagridview</param>
|
||||
/// <param name="str"> nazov stlpca v ktorom sa nachada status dopytu</param>
|
||||
public static void SetRowColor2(DataGridView dgv, string str)
|
||||
{
|
||||
for (int i = 0; i < dgv.RowCount; i++)
|
||||
{
|
||||
switch (dgv.Rows[i].Cells[str].Value.ToString())
|
||||
{
|
||||
case "Vo výrobe":
|
||||
case "Čiastočne odoslaná":
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.DarkGreen;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.Honeydew;
|
||||
break;
|
||||
case "Prijatý":
|
||||
case "Prijatá":
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Black;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
break;
|
||||
case "Zrušená":
|
||||
case "Zrušený":
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.MistyRose;
|
||||
break;
|
||||
case "Zaradená do výroby":
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.SaddleBrown;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.AntiqueWhite;
|
||||
break;
|
||||
case "Na lapovni":
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.MidnightBlue;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.Azure;
|
||||
break;
|
||||
case "Pozastavená":
|
||||
case "Pozastavený":
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.MistyRose;
|
||||
break;
|
||||
case "Skončený":
|
||||
case "Odoslaná":
|
||||
case "Odoslaný":
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Olive;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.LightGoldenrodYellow;
|
||||
break;
|
||||
case "Nacenená":
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.DarkMagenta;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.LavenderBlush;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Nastavi farbu riadkov v datagridview naspet na predvolenu
|
||||
/// </summary>
|
||||
/// <param name="dgv"> nazov prefarbovaneho datagridview</param>
|
||||
/// <param name="str"> nazov stlpca v ktorom sa nachada status dopytu</param>
|
||||
public static void SetRowColorBack(DataGridView dgv)
|
||||
{
|
||||
for (int i = 0; i < dgv.RowCount; i++)
|
||||
{
|
||||
dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Empty;
|
||||
dgv.Rows[i].DefaultCellStyle.BackColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void SetCellColor(DataGridView dgv, int eColumnIndex, int eRowIndex, string eValue)
|
||||
{
|
||||
if (dgv.DataSource != null)
|
||||
{
|
||||
if (eColumnIndex == dgv.Columns["OnlineStatus"].Index)
|
||||
{
|
||||
string RepVisits = eValue.ToString();
|
||||
if (RepVisits != null)
|
||||
{
|
||||
if (RepVisits == "Online")
|
||||
{
|
||||
dgv.Rows[eRowIndex].Cells[eColumnIndex].Style.ForeColor = Color.Green;
|
||||
}
|
||||
if (RepVisits == "Offline")
|
||||
{
|
||||
dgv.Rows[eRowIndex].Cells[eColumnIndex].Style.ForeColor = Color.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eColumnIndex == dgv.Columns["Meno"].Index && dgv.Rows[eRowIndex].Cells["NoveSpravy"].Value.ToString() == "True")
|
||||
{
|
||||
string RepVisits = eValue.ToString();
|
||||
if (RepVisits != null)
|
||||
{
|
||||
dgv.Rows[eRowIndex].DefaultCellStyle.BackColor = Color.Gold;
|
||||
dgv.Rows[eRowIndex].Cells[eColumnIndex].Style.ForeColor = Color.Blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetRowColorExpedicneZaznamy(DataGridView dgv, int eColumnIndex, int eRowIndex, string eValue)
|
||||
{
|
||||
if (dgv.DataSource != null)
|
||||
{
|
||||
if (eColumnIndex == dgv.Columns["StatusSkladOperacie"].Index)
|
||||
{
|
||||
string RepVisits = eValue.ToString();
|
||||
if (RepVisits != null)
|
||||
{
|
||||
if (RepVisits == "Nevybavený" || RepVisits == "Bez skladovej operácie") for (int i = 0; i < dgv.Columns.Count; i++)
|
||||
{
|
||||
dgv.Rows[eRowIndex].Cells[i].Style.ForeColor = Color.Green;
|
||||
if (dgv.Columns[i].Name.ToString() == "DatumOperacie" ||
|
||||
dgv.Columns[i].Name.ToString() == "SkladOperacia" ||
|
||||
dgv.Columns[i].Name.ToString() == "StatusSkladOperacie") dgv.Rows[eRowIndex].Cells[i].ReadOnly = true;
|
||||
}
|
||||
if (RepVisits == "Vybavený") for (int i = 0; i < dgv.Columns.Count; i++)
|
||||
{
|
||||
dgv.Rows[eRowIndex].Cells[i].Style.ForeColor = Color.Red;
|
||||
dgv.Rows[eRowIndex].Cells[i].ReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RowColor(DataGridView _dgv, Int32 _cI)
|
||||
{
|
||||
switch (_dgv.Name.ToString())
|
||||
{
|
||||
case "dataGridView16":
|
||||
for (int i = 0; i < _dgv.RowCount; i++)
|
||||
{
|
||||
switch (_dgv.Rows[i].Cells["Status žiadanky"].Value.ToString())
|
||||
{
|
||||
case "Prijatá":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.Aqua;
|
||||
break;
|
||||
case "Zamietnutá":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon;
|
||||
break;
|
||||
case "Schválená":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.LightGoldenrodYellow;
|
||||
break;
|
||||
case "Dopyt odoslaný":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.PaleGoldenrod;
|
||||
break;
|
||||
case "Objednávka odoslaná":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.Tan;
|
||||
break;
|
||||
case "Potvrdená":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.PaleGreen;
|
||||
break;
|
||||
case "Tovar doručený":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.PaleTurquoise;
|
||||
break;
|
||||
case "Vybavená":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.LightSkyBlue;
|
||||
break;
|
||||
case "Nevybavená":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.MistyRose;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "dataGridView7":
|
||||
for (int i = 0; i < _dgv.RowCount; i++)
|
||||
{
|
||||
switch (_dgv.Rows[i].Cells["Status"].Value.ToString())
|
||||
{
|
||||
case "Prijatá":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.LightGoldenrodYellow;
|
||||
break;
|
||||
case "Zrušená":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon;
|
||||
break;
|
||||
case "Nacenená":
|
||||
_dgv.Rows[i].DefaultCellStyle.BackColor = Color.PaleGreen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(_cI>-1) _dgv.Columns[_cI].DefaultCellStyle.BackColor = Color.GreenYellow;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// kod na zrychlenie datagridview,
|
||||
public class DoubleBufferedDataGridView : DataGridView
|
||||
{
|
||||
public DoubleBufferedDataGridView()
|
||||
{
|
||||
DoubleBuffered = true;
|
||||
}
|
||||
}
|
||||
|
||||
public class MyTransparentTrackBar : TrackBar
|
||||
{
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
if (Parent != null)
|
||||
BackColor = Parent.BackColor;
|
||||
|
||||
base.OnCreateControl();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetServerIP ()
|
||||
{
|
||||
System.Net.NetworkInformation.Ping pingIP = new System.Net.NetworkInformation.Ping();
|
||||
string IPaddress = "";
|
||||
PingReply pingReply;
|
||||
|
||||
IPaddress = "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";
|
||||
pingReply = pingIP.Send(IPaddress);
|
||||
if (pingReply.Status.ToString() == "Success")
|
||||
{
|
||||
classUser.MariaDBServerIPAddress = IPaddress;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
IPaddress = "192.168.1.13"; //IP Adresa MariaDB pre VLAN2
|
||||
pingReply = pingIP.Send(IPaddress);
|
||||
if (pingReply.Status.ToString() == "Success")
|
||||
{
|
||||
classUser.MariaDBServerIPAddress = IPaddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
IPaddress = "87.197.164.107";
|
||||
pingReply = pingIP.Send(IPaddress);
|
||||
if (pingReply.Status.ToString() == "Success")
|
||||
{
|
||||
classUser.MariaDBServerIPAddress = IPaddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
classUser.MariaDBServerIPAddress = "0.0.0.0";
|
||||
MessageBox.Show("Žiadny lokálny ani internetový MariaDB server nebol nájdený!"
|
||||
+ Environment.NewLine
|
||||
+ "Program Mip bude ukončený! ");
|
||||
|
||||
Environment.Exit(0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void fillExcelForm(DataTable _formToFill)
|
||||
{
|
||||
Excel.Application xlApp = new Excel.Application();
|
||||
Excel.Workbook xlWorkBook = xlApp.Workbooks.Open(@"C:\" + _formToFill.TableName + ".xlsx");
|
||||
Excel.Worksheet xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
|
||||
|
||||
for (int i = _formToFill.Columns.Count - 1; i >= 0; i--)
|
||||
{
|
||||
xlWorkBook.Names.Item(_formToFill.Columns[i].ColumnName.ToString()).RefersToRange.Value
|
||||
=
|
||||
_formToFill.Rows[0][i].ToString();
|
||||
}
|
||||
/*
|
||||
range = xlWorkSheet.UsedRange;
|
||||
xlWorkBook.Names.Item("ZakCislo").RefersToRange.Value = "55";
|
||||
|
||||
//xlWorkSheet.Cells["ZakCislo"].Value2 = "55";
|
||||
|
||||
|
||||
|
||||
|
||||
xlWorkSheet.Range["D2", "F2"].Value = dtrw.Cells["ZakCislo"].Value.ToString();
|
||||
xlWorkSheet.Range["G2", "K2"].Value = "Č.V.: " + dtrw.Cells["NazovVyrobku"].Value.ToString();
|
||||
if (dtrw.Cells["UpravaMaterialu"].Value.ToString() == "") xlWorkSheet.Range["H6", "I6"].Value = dtrw.Cells["Material"].Value.ToString();
|
||||
else xlWorkSheet.Range["H6", "I6"].Value = dtrw.Cells["Material"].Value.ToString() + "-" + dtrw.Cells["UpravaMaterialu"].Value.ToString();
|
||||
DateTime date = (DateTime)dtrw.Cells["DatumPrijatiaOBJ"].Value;
|
||||
xlWorkSheet.Range["B4", "C4"].Value = date.Day.ToString() + "." + date.Month.ToString() + "." + date.Year.ToString();
|
||||
xlWorkSheet.Range["B6", "C6"].Value = dtrw.Cells["Zakaznik"].Value.ToString();
|
||||
xlWorkSheet.Range["D6", "E6"].Value = dtrw.Cells["CisloObj"].Value.ToString();
|
||||
xlWorkSheet.Range["F8", "G9"].Value = dtrw.Cells["PocetDoVyroby"].Value.ToString();
|
||||
date = (DateTime)dtrw.Cells["DatumPotvrdeny"].Value;
|
||||
xlWorkSheet.Range["D10", "F10"].Value = date.Day.ToString() + "." + date.Month.ToString() + "." + date.Year.ToString();
|
||||
xlWorkSheet.Range["B8", "E9"].Value = dtrw.Cells["SpojeneRozmery"].Value.ToString();
|
||||
if (dtrw.Cells["NazovKontraktu"].Value.ToString() == "") xlWorkSheet.Range["F5", "G5"].Value = "K.č.: --";
|
||||
else xlWorkSheet.Range["F5", "G5"].Value = "K.č.: " + dtrw.Cells["NazovKontraktu"].Value.ToString();
|
||||
xlWorkSheet.Range["F6", "G6"].Value = "Kon.op.: " + dtrw.Cells["RozlisZnakKonecnaOp"].Value.ToString();
|
||||
if (dtrw.Cells["PoznamkaOBJ"].Value.ToString() == "") xlWorkSheet.Range["B49", "O54"].Value = "Poznámky:";
|
||||
else xlWorkSheet.Range["B49", "O54"].Value = "Poznámky: " + dtrw.Cells["PoznamkaOBJ"].Value.ToString();
|
||||
*/
|
||||
/*
|
||||
for (int i = _changes.Rows.Count; i >= 1; i--)
|
||||
{
|
||||
xlWorkSheet.Range[_changes.Rows[i - 1]["Start"].ToString(), _changes.Rows[i - 1]["End"].ToString()].Value = _changes.Rows[i - 1]["Value"].ToString();
|
||||
}
|
||||
|
||||
*/
|
||||
xlApp.Visible = true;
|
||||
xlApp.ActiveWindow.Activate();
|
||||
xlWorkSheet.PrintPreview();
|
||||
|
||||
xlApp.Visible = false;
|
||||
|
||||
xlWorkBook.Save();
|
||||
xlWorkBook.Close(false, null, null);
|
||||
xlApp.Quit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void wait(Boolean _switch)
|
||||
{
|
||||
//Form cf = Form.ActiveForm;
|
||||
//MessageBox.Show(cf.Name.ToString());
|
||||
/*
|
||||
if (_switch) cf.Cursor = System.Windows.Forms.Cursors.WaitCursor;
|
||||
|
||||
else cf.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
*/
|
||||
|
||||
|
||||
if (_switch) Application.UseWaitCursor = true;
|
||||
|
||||
else Application.UseWaitCursor = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Kontrola prístupu k jednotlivým komponentom MIP
|
||||
/// Doposiaľ implementované komponenty:
|
||||
/// 1. "Ziadanka-zobrazit vsetky"
|
||||
/// 2. "Ziadanka-schvalit"
|
||||
/// 3. "Ziadanka-operacie"
|
||||
/// </summary>
|
||||
/// <param name="_IDUSER"> ID užívateľa pre ktorého za zisťujú prístupové práva</param>
|
||||
/// <param name="_NAZOVPRISTUPU"> Názov komponentu ku ktorému sa zisťuje prístup</param>
|
||||
public static bool PristupovePrava(Int32 _IDUSER, string _NAZOVPRISTUPU)
|
||||
{
|
||||
bool bReturnValue = false;
|
||||
string NazovPristupu = _NAZOVPRISTUPU;
|
||||
Int32 IDUser = _IDUSER;
|
||||
|
||||
// 1.Čulák 2.Kuna 4.Bujna 5.Ďurčeková 8.Kúdelová 9.Bahelka 10.Štefke 11.Bulák 12.Bielich 13.Zajko 14.Bolha 15.Fiala
|
||||
// 17.Poluch 18.Staňo 19.Urbaník 20.Danko 21.Močáry 22.Beneš 23.Kučerka 25.Adamcová 26.Balog 27.Kubala 28.Rybanská
|
||||
// 29.Káčerová 30.Ďurček
|
||||
|
||||
switch (NazovPristupu)
|
||||
{
|
||||
case "Ziadanka-zobrazit vymazane":
|
||||
switch (_IDUSER)
|
||||
{
|
||||
case 1:
|
||||
case 4:
|
||||
case 13:
|
||||
case 28:
|
||||
case 29:
|
||||
bReturnValue = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
bReturnValue = false;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case "Ziadanka-zobrazit vsetky":
|
||||
switch (_IDUSER)
|
||||
{
|
||||
case 1:
|
||||
case 4:
|
||||
case 6:
|
||||
case 9:
|
||||
case 13:
|
||||
case 28:
|
||||
case 29:
|
||||
bReturnValue = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
bReturnValue = false;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case "Ziadanka-schvalit":
|
||||
switch (_IDUSER)
|
||||
{
|
||||
case 1:
|
||||
case 4:
|
||||
case 6:
|
||||
case 9:
|
||||
case 13:
|
||||
case 24:
|
||||
case 28:
|
||||
bReturnValue = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
bReturnValue = false;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case "Ziadanka-operacie":
|
||||
switch (_IDUSER)
|
||||
{
|
||||
case 1:
|
||||
case 4:
|
||||
case 5:
|
||||
case 13:
|
||||
case 24:
|
||||
case 28:
|
||||
bReturnValue = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
bReturnValue = false;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
bReturnValue = false;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return bReturnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user