| | |
| | | using System.Collections.Generic; |
| | | using System.Runtime.InteropServices; |
| | | using System.Drawing; |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace WFormReadData_SMR |
| | | { |
| | |
| | | string selectedFolderPath = folderBrowserDialog.SelectedPath; |
| | | // 使用 selectedFolderPath 进行后续操作,例如显示在文本框中 |
| | | this.txtLj.Text = selectedFolderPath; |
| | | GetCSV_Read(selectedFolderPath); |
| | | //GetExcel_Read(selectedFolderPath); |
| | | //GetCSV_Read(selectedFolderPath);//轮廓仪 |
| | | GetExcel_Read(selectedFolderPath);//三坐标 |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | for (int i = 0; i < dataTable.Rows.Count; i++) |
| | | { |
| | | |
| | | CustomWriteLog("1 第 '" + i + "' 次 '" + dataTable.Rows[i]["Characteristic"].ToString() + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | CustomWriteLog("1 第 '" + i + "' 次 '" + Double.Parse(dataTable.Rows[i]["HUpLimit"].ToString()) + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | CustomWriteLog("1 第 '" + i + "' 次 '" + Double.Parse(dataTable.Rows[i]["HQCStd"].ToString()) + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | double HUpLimits = Double.Parse(dataTable.Rows[i]["HUpLimit"].ToString()) + Double.Parse(dataTable.Rows[i]["HQCStd"].ToString()); |
| | | CustomWriteLog("2 第 '" + i + "' 次 '"+ Double.Parse(dataTable.Rows[i]["HDownLimit"].ToString()) + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | CustomWriteLog("2 第 '" + i + "' 次 '" + Double.Parse(dataTable.Rows[i]["HQCStd"].ToString()) + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | double HDownLimits = Double.Parse(dataTable.Rows[i]["HDownLimit"].ToString()) + Double.Parse(dataTable.Rows[i]["HQCStd"].ToString()); |
| | | CustomWriteLog("3 第 '" + i + "' 次 '" + Double.Parse(dataTable.Rows[i]["Actual"].ToString()) + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | CustomWriteLog("3 第 '" + i + "' 次 '" + Double.Parse(dataTable.Rows[i]["HDownLimit"].ToString()) + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | int HLastResult = (Double.Parse(dataTable.Rows[i]["Actual"].ToString()) > HUpLimits || HDownLimits < Double.Parse(dataTable.Rows[i]["HDownLimit"].ToString())) ? 0 : 1; |
| | | CustomWriteLog("4 第 '" + i + "' 次 '" + HLastResult + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | if (HLastResult == 1 && HLastResults != 0) |
| | | { |
| | |
| | | { |
| | | HLastResults = 0; |
| | | } |
| | | |
| | | string sql = "Insert into QC_FirstPieceCheckBillSub " + |
| | | " (HInterID,HBillNo_bak,HEntryID,HCloseMan" + |
| | | ",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" + |
| | | ",HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + |
| | | ",HQCCheckItemID,HQCStd,HUnit,HQCNote,HResult" + |
| | | ",HMax,HMin,HAvg,HSampleSchemeID,HSampleQty,HSampleDamageQty,HAcceptQty" + |
| | | ",HRejectQty,HSampleUnRightQty,HStatus,HUnitID,HInspectVal,HTargetVal" + |
| | | ",HUpLimit,HDownLimit,HUpOffSet,HDownOffSet,HKeyInspect,HAnalysisMethod,HInspectInstruMentID,HInspectResult" + |
| | | ") values(" |
| | | + HInterID + ",'" + HBillNo + "'," + (i + 1) + ",''" + |
| | | ",getdate(),0,''," + HProcExchInterID + |
| | | "," + HProcExchEntryID + ",'" + HProcExchBillNo + "','',0,0" + |
| | | "," + dataTable.Rows[i]["CharacteristicID"].ToString() + ",'" + dataTable.Rows[i]["HQCStd"].ToString() + "','','" + dataTable.Rows[i]["HQCStd"].ToString() + "','" + HLastResult + "'" + |
| | | ",'" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() + "',''" + ",0,0,0,0,0,0,'',0,'" + dataTable.Rows[i]["Actual"].ToString() + "','" + dataTable.Rows[i]["HQCStd"].ToString() + "','" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() + "','','',0,'2'," + dataTable.Rows[i]["HInspectInstruMentID"].ToString() + ",'" + HLastResult + "'" + |
| | | ") "; |
| | | CustomWriteLog("首件保存前 第 '" +i+ "' '"+ dataTable.Rows[i]["Characteristic"].ToString() + "' 次:'" + sql + "'", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | oCN.RunProc("Insert into QC_FirstPieceCheckBillSub " + |
| | | " (HInterID,HBillNo_bak,HEntryID,HCloseMan" + |
| | | ",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" + |
| | |
| | | "," + dataTable.Rows[i]["CharacteristicID"].ToString() + ",'" + dataTable.Rows[i]["HQCStd"].ToString() + "','','"+ dataTable.Rows[i]["HQCStd"].ToString() + "','" + HLastResult + "'" + |
| | | ",'" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() + "',''" + ",0,0,0,0,0,0,'',0,'" + dataTable.Rows[i]["Actual"].ToString() + "','" + dataTable.Rows[i]["HQCStd"].ToString() + "','" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() + "','','',0,'2'," + dataTable.Rows[i]["HInspectInstruMentID"].ToString() + ",'" + HLastResult + "'" + |
| | | ") "); |
| | | CustomWriteLog("首件保存后 第 '" + i + "' 次", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | } |
| | | |
| | | DataSet SetData = oCN.RunProcReturn("select HMakeDate from QC_TakeSampleCheckBillMain where HInterID =" + this.HTakeSampleCheckBillID.Text, "QC_TakeSampleCheckBillMain"); |
| | |
| | | { |
| | | HLastResults = 0; |
| | | } |
| | | |
| | | |
| | | oCN.RunProc("Insert into QC_PatrolProcCheckOtherBillSub " + |
| | | " (HInterID,HBillNo_bak,HEntryID,HCloseMan" + |
| | | ",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" + |
| | |
| | | string HICMOEntryID = ds.Tables[0].Rows[0]["HICMOEntryID"].ToString(); |
| | | string HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString(); |
| | | string HPlanQty = ds.Tables[0].Rows[0]["HPlanQty"].ToString(); |
| | | string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString(); |
| | | string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString(); |
| | | string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString(); |
| | | string HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString(); |
| | | string HQty = ds.Tables[0].Rows[0]["HQty"].ToString(); |
| | |
| | | MessageBox.Show(this, e.Message, "提示"); |
| | | } |
| | | } |
| | | |
| | | |
| | | private static readonly object lockObj = new object(); |
| | | //写日志 |
| | | public static void CustomWriteLog(object obj, string FileName, string filePath = "Vlog", bool isAppend = true) |
| | | { |
| | | try |
| | | { |
| | | lock (lockObj) |
| | | { |
| | | filePath = $@"{filePath}\{FileName}.txt"; |
| | | |
| | | filePath = AppDomain.CurrentDomain.BaseDirectory + filePath; |
| | | |
| | | if (!System.IO.Directory.Exists(Path.GetDirectoryName(filePath))) |
| | | { |
| | | System.IO.Directory.CreateDirectory(Path.GetDirectoryName(filePath)); |
| | | } |
| | | |
| | | bool fileExists = System.IO.File.Exists(filePath); |
| | | //不存在 则创建该文件 |
| | | if (!fileExists) |
| | | { |
| | | System.IO.File.Create(filePath).Close(); |
| | | } |
| | | |
| | | using (StreamWriter writer = new StreamWriter(filePath, isAppend)) |
| | | { |
| | | //存在的时候才写一行 |
| | | if (fileExists && isAppend) |
| | | { |
| | | writer.WriteLine(); |
| | | } |
| | | |
| | | var content = obj is string ? obj : JsonConvert.SerializeObject(obj); |
| | | writer.WriteLine($"{DateTime.Now} {content}"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |