Commit 4b327bc9 authored by YONG-LIN SU's avatar YONG-LIN SU

log out print complex

parent b0ce97a0
using System;
using MySql.Data.MySqlClient; //連線MySql的方法
using System.Windows.Forms; //錯誤視窗的方法
namespace ETC_App1
{
class Authentication
{
internal static bool Authentication_1(string ID_in, string password_in) //使用者輸入的帳號密碼
{
MySqlConnection conn = new MySqlConnection("server=192.168.5.17;user=root;database=eye_test;port=3306;password=root;");//連線位置;使用者;資料庫;阜號;密碼;
conn.Open(); //連線資料庫
string sql_ID = String.Format("SELECT password FROM account WHERE username = \"{0}\"", ID_in);//輸入ID得到對應密碼
MySqlCommand cmd_ID = new MySqlCommand(sql_ID, conn); //下達SQL語法和資料庫連線
String password = (String)cmd_ID.ExecuteScalar(); //取得結果回傳到password
if (password_in == password) //拿得到的密碼去比對他輸入的密碼確認是否一致
{
return true;
}
else //錯誤就提示帳密錯誤
{
MessageBox.Show("帳號或密碼錯誤"); //錯誤提示框
return false;
}
}
}
}
This diff is collapsed.
...@@ -24,6 +24,8 @@ namespace ETC_App1 ...@@ -24,6 +24,8 @@ namespace ETC_App1
private List<Json> Data = new List<Json>(); private List<Json> Data = new List<Json>();
public string UsingID { get; set; }
public Color ErrorColor { get; set; } = Color.Red; public Color ErrorColor { get; set; } = Color.Red;
public Color WarningColor { get; set; } = Color.Blue; public Color WarningColor { get; set; } = Color.Blue;
...@@ -117,13 +119,20 @@ namespace ETC_App1 ...@@ -117,13 +119,20 @@ namespace ETC_App1
listBox1.Items.Add((json.lost2 ? "" : json.index + ". ") + (json.success ? json.message1 : "資料異常")); listBox1.Items.Add((json.lost2 ? "" : json.index + ". ") + (json.success ? json.message1 : "資料異常"));
listBox2.Items.Add((json.lost2 ? json.filename + "," : json.index + ". ") + (json.success ? json.message1 : json.message2)); listBox2.Items.Add((json.lost2 ? json.filename + "," : json.index + ". ") + (json.success ? json.message1 : (json.lost1?json.filename:json.message2)));
listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox2.SelectedIndex = listBox2.Items.Count - 1; listBox2.SelectedIndex = listBox2.Items.Count - 1;
} }
public void Clear()
{
listBox1.Items.Clear();
listBox2.Items.Clear();
}
private void EtcStatusStrip1_Resize(object sender, EventArgs e) private void EtcStatusStrip1_Resize(object sender, EventArgs e)
{ {
StatusStripWidth = etcStatusStrip1.Size.Width; StatusStripWidth = etcStatusStrip1.Size.Width;
...@@ -216,10 +225,6 @@ namespace ETC_App1 ...@@ -216,10 +225,6 @@ namespace ETC_App1
button1.Text = json.success && json.failed ? "正確" : button1.Text; button1.Text = json.success && json.failed ? "正確" : button1.Text;
button1.ForeColor = json.success ? Color.Green : button1.ForeColor; button1.ForeColor = json.success ? Color.Green : button1.ForeColor;
button2.Text = json.success && json.failed ? "錯誤" : "下一筆";
button2.ForeColor = json.success ? Color.Red : Color.Black;
} }
listBox2.SelectedIndex = listBox1.SelectedIndex; listBox2.SelectedIndex = listBox1.SelectedIndex;
...@@ -251,5 +256,68 @@ namespace ETC_App1 ...@@ -251,5 +256,68 @@ namespace ETC_App1
{ {
listBox1.SelectedIndex = listBox2.SelectedIndex; listBox1.SelectedIndex = listBox2.SelectedIndex;
} }
private void Button1_Click(object sender, EventArgs e)
{
if (button1.Text == "正確")
{
Data[listBox1.SelectedIndex].failed = false;
Data[listBox1.SelectedIndex].message1 = Data[listBox1.SelectedIndex].message1+"["+UsingID+"]";
listBox1.Items[listBox1.SelectedIndex] = listBox1.SelectedIndex + "." + Data[listBox1.SelectedIndex].message1;
listBox2.Items[listBox1.SelectedIndex] = listBox2.SelectedIndex + "." + Data[listBox1.SelectedIndex].message1;
}
}
private void Button2_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex < listBox1.Items.Count - 1)
{
for (int i = listBox1.SelectedIndex; i < listBox1.Items.Count; i++)
{
if(Data[i].success && Data[i].failed)
{
listBox1.SelectedIndex = i;
break;
}
};
}
}
public void SaveLogs(string save_path)
{
string file_path = save_path + "/log.txt";
FileStream fs = new FileStream(@file_path, FileMode.Create, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.Default);
int success = 0;
int noimg = 0;
int nodata = 0;
for (int i = 0; i < Data.Count; i++)
{
string msg = "";
if (Data[i].lost2)
{
msg = msg + Data[i].filename + ","+ Data[i].message2;
nodata++;
}
else if(Data[i].success)
{
msg = msg + i + "." + Data[i].message1;
success++;
}
else if (Data[i].lost1)
{
msg = msg + i + "." + Data[i].filename;
noimg++;
}
sw.WriteLine(msg);
}
sw.WriteLine("完全正確:"+success+" 找不到圖片:"+noimg+" 缺少比對資料:"+nodata);
sw.Close();
fs.Close();
}
} }
} }
...@@ -68,6 +68,9 @@ ...@@ -68,6 +68,9 @@
<Reference Include="ICSharpCode.SharpZipLib, Version=1.0.0.999, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL"> <Reference Include="ICSharpCode.SharpZipLib, Version=1.0.0.999, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.0.0\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath> <HintPath>..\packages\SharpZipLib.1.0.0\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference> </Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\mysql\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
...@@ -103,6 +106,7 @@ ...@@ -103,6 +106,7 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Authentication.cs" />
<Compile Include="D1.cs" /> <Compile Include="D1.cs" />
<Compile Include="ETCBackgroundWorker1.cs"> <Compile Include="ETCBackgroundWorker1.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
......
...@@ -11,6 +11,7 @@ using System.Windows.Forms; ...@@ -11,6 +11,7 @@ using System.Windows.Forms;
namespace ETC_App1 namespace ETC_App1
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
private int index = 0; private int index = 0;
...@@ -89,9 +90,28 @@ namespace ETC_App1 ...@@ -89,9 +90,28 @@ namespace ETC_App1
private void ToolStripButton1_Click(object sender, EventArgs e) private void ToolStripButton1_Click(object sender, EventArgs e)
{ {
IsLock = false; //int change=0;
string ID = toolStripTextBox1.Text;
string Password = toolStripTextBox2.Text; //取得輸入的帳密
//if (change == 0)
//{
if (Authentication.Authentication_1(ID, Password))
{
//change = 1;
etcPictureCheckBox1.UsingID = ID;
IsLock = false; //登入成功
}
//}
/*
else if (change == 1)
{
change = 0;
IsLock = true;
}
*/
} }
private void ToolStripButton2_Click(object sender, EventArgs e) private void ToolStripButton2_Click(object sender, EventArgs e)
{ {
string text = toolStripTextBox3.Text; string text = toolStripTextBox3.Text;
...@@ -109,6 +129,8 @@ namespace ETC_App1 ...@@ -109,6 +129,8 @@ namespace ETC_App1
toolStripTextBox4.Text = Path.GetDirectoryName(text); toolStripTextBox4.Text = Path.GetDirectoryName(text);
etcPictureCheckBox1.Clear();
etcBackgroundWorker11.RunWorkerAsync(text); etcBackgroundWorker11.RunWorkerAsync(text);
} }
else else
...@@ -138,8 +160,6 @@ namespace ETC_App1 ...@@ -138,8 +160,6 @@ namespace ETC_App1
toolStripComboBox1.Enabled = true; toolStripComboBox1.Enabled = true;
toolStripComboBox1.Items.Clear();
toolStripComboBox1.Items.AddRange(etcBackgroundWorker31.Data.Keys.ToArray()); toolStripComboBox1.Items.AddRange(etcBackgroundWorker31.Data.Keys.ToArray());
toolStripComboBox1.SelectedIndex = toolStripComboBox1.Items.Count > 0 ? 0 : -1; toolStripComboBox1.SelectedIndex = toolStripComboBox1.Items.Count > 0 ? 0 : -1;
...@@ -198,6 +218,7 @@ namespace ETC_App1 ...@@ -198,6 +218,7 @@ namespace ETC_App1
private void ToolStripButton4_Click(object sender, EventArgs e) private void ToolStripButton4_Click(object sender, EventArgs e)
{ {
toolStripComboBox1.Items.Clear();
if (!etcBackgroundWorker31.IsBusy) if (!etcBackgroundWorker31.IsBusy)
{ {
etcBackgroundWorker31.RunWorkerAsync(index); etcBackgroundWorker31.RunWorkerAsync(index);
...@@ -251,7 +272,7 @@ namespace ETC_App1 ...@@ -251,7 +272,7 @@ namespace ETC_App1
private void ToolStripButton6_Click(object sender, EventArgs e) private void ToolStripButton6_Click(object sender, EventArgs e)
{ {
etcPictureCheckBox1.SaveLogs(toolStripTextBox4.Text);
} }
} }
} }
This diff is collapsed.
20af047b28ab6c4cf1b6e3c0dd90f71e4169e178 de48493c4e47c17f1d3fb9ea7de587584520d94e
...@@ -116,3 +116,64 @@ D:\C#\e-eye\ETC_App1\obj\Debug\ETC_App1.csproj.CoreCompileInputs.cache ...@@ -116,3 +116,64 @@ D:\C#\e-eye\ETC_App1\obj\Debug\ETC_App1.csproj.CoreCompileInputs.cache
D:\C#\e-eye\ETC_App1\obj\Debug\ETC_App1.csproj.CopyComplete D:\C#\e-eye\ETC_App1\obj\Debug\ETC_App1.csproj.CopyComplete
D:\C#\e-eye\ETC_App1\obj\Debug\ETC_App1.exe D:\C#\e-eye\ETC_App1\obj\Debug\ETC_App1.exe
D:\C#\e-eye\ETC_App1\obj\Debug\ETC_App1.pdb D:\C#\e-eye\ETC_App1\obj\Debug\ETC_App1.pdb
D:\C#\e-eye3\ETC_App1\bin\Debug\x64\concrt140.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x64\cvextern.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x64\msvcp140.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x64\opencv_ffmpeg401_64.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x64\vcruntime140.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x86\concrt140.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x86\cvextern.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x86\msvcp140.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x86\opencv_ffmpeg401.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\x86\vcruntime140.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\ETC_App1.exe.config
D:\C#\e-eye3\ETC_App1\bin\Debug\ETC_App1.exe
D:\C#\e-eye3\ETC_App1\bin\Debug\ETC_App1.pdb
D:\C#\e-eye3\ETC_App1\bin\Debug\Aspose.BarCode.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\Emgu.CV.UI.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\Emgu.CV.World.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\ICSharpCode.SharpZipLib.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\Newtonsoft.Json.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\NPOI.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\NPOI.OOXML.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\NPOI.OpenXml4Net.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\NPOI.OpenXmlFormats.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\RestSharp.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\ZedGraph.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\Aspose.BarCode.xml
D:\C#\e-eye3\ETC_App1\bin\Debug\Emgu.CV.UI.xml
D:\C#\e-eye3\ETC_App1\bin\Debug\Emgu.CV.World.xml
D:\C#\e-eye3\ETC_App1\bin\Debug\ICSharpCode.SharpZipLib.xml
D:\C#\e-eye3\ETC_App1\bin\Debug\Newtonsoft.Json.xml
D:\C#\e-eye3\ETC_App1\bin\Debug\RestSharp.xml
D:\C#\e-eye3\ETC_App1\bin\Debug\ZedGraph.xml
D:\C#\e-eye3\ETC_App1\bin\Debug\de\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\es\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\fr\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\hu\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\it\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\ja\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\pt\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\ru\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\sk\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\sv\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\tr\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\zh-cn\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\bin\Debug\zh-tw\ZedGraph.resources.dll
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.csprojAssemblyReference.cache
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.ETCBackgroundWorker1.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.ETCBackgroundWorker2.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.ETCBackgroundWorker3.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.ETCPictureBox.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.ETCPictureCheckBox.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.ETCStatusStrip.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.ETCToolStrip.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.Form1.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.Properties.Resources.resources
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.csproj.GenerateResource.cache
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.csproj.CoreCompileInputs.cache
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.csproj.CopyComplete
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.exe
D:\C#\e-eye3\ETC_App1\obj\Debug\ETC_App1.pdb
D:\C#\e-eye\ETC_App1\bin\Debug\MySql.Data.dll
D:\C#\e-eye\ETC_App1\bin\Debug\MySql.Data.xml
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment