public bool CableUsedQueryFunc(string queryStr) { OleDbConnection connection = null; OleDbDataReader dataReader = null; bool bExistFlag = false; try { try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select * from TPlugLibrary where ConnectorName='" + queryStr + "'", connection).ExecuteReader(); if (dataReader.Read()) { this.usedPlugStr = dataReader["PlugNo"].ToString(); bExistFlag = true; } dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_76_0) { KLineTestProcessor.ExceptionRecordFunc(arg_76_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } catch (System.Exception arg_9A_0) { KLineTestProcessor.ExceptionRecordFunc(arg_9A_0.StackTrace); } return(bExistFlag); }
private void cmbZanr_SelectedIndexChanged(object sender, EventArgs e) { cmbNaslovi.Items.Clear(); txtcNaslov.Focus(); string q = "select distinct naziv from artikal" + " where id_artikal in" + "(select id_artikal from grupe where id_zanr in" + "(select id_zanr from zanrovi where nazivzanr= '" + cmbZanr.SelectedItem + "')) "; DBManager.Connection.Open(); var reader = new OleDbCommand(q, DBManager.Connection).ExecuteReader(); while (reader.Read()) { cmbNaslovi.Items.Add(reader["naziv"]); } DBManager.Connection.Close(); }
internal string GenerateAPI(string RANumber, OleDbConnection conn) { StringBuilder stringBuilder = new StringBuilder(); OleDbDataReader oleDbDataReader = new OleDbCommand("SELECT AircraftEngType as AET,APUSN as EMS From tblRepairHistory WHERE RANumber = " + RANumber, conn).ExecuteReader(); if (oleDbDataReader.HasRows) { stringBuilder.Append("<API_Segment>"); while (oleDbDataReader.Read()) { stringBuilder.Append("<" + oleDbDataReader.GetName(0).ToString() + ">" + oleDbDataReader.GetValue(0).ToString() + "</" + oleDbDataReader.GetName(0).ToString() + ">"); stringBuilder.Append("<" + oleDbDataReader.GetName(1).ToString() + ">" + oleDbDataReader.GetValue(1).ToString() + "</" + oleDbDataReader.GetName(1).ToString() + ">"); } stringBuilder.Append("</API_Segment>"); } return(stringBuilder.ToString()); }
private void Administracija() { string q = "select distinct nazivzanr from zanrovi order by nazivzanr asc"; try { DBManager.Connection.Open(); var reader = new OleDbCommand(q, DBManager.Connection).ExecuteReader(); while (reader.Read()) { cmbZanr.Items.Add(reader["nazivzanr"]); } DBManager.Connection.Close(); } catch { DBManager.Connection.Close(); } finally { DBManager.Connection.Close(); } }
public static List <Dictionary <string, object> > SqlRead(string query) { //fehler falls es sich nicht um einen SELECT befehl handelt if (!query.ToUpper().StartsWith("SELECT")) { throw new Exception("SQL query enthielt keinen SELECT befehl."); } List <Dictionary <string, object> > rückgabeWert = new List <Dictionary <string, object> >(); //Nimmt den text nach SELECT und vor FROM und ignoriert dabei groß / kleinschreibung string queryFix = query.Substring(7, query.ToUpper().IndexOf(" FROM ") - 7); //Liste der Abzufragenden Zeilen string[] querys = queryFix.Split(','); //formatiert die abzufragenden zeilen und weist alias zu for (int i = 0; i < querys.Length; i++) { if (querys[i].ToUpper().IndexOf(" AS ") > 0) { querys[i] = querys[i].Substring(querys[i].ToUpper().IndexOf(" AS ") + 4, querys[i].Length - (querys[i].ToUpper().IndexOf(" AS ") + 4)); } querys[i] = querys[i].Replace(" ", ""); } DbConnection.Open(); OleDbDataReader reader = new OleDbCommand(query, DbConnection).ExecuteReader(); while (reader.Read()) { Dictionary <string, object> obj = new Dictionary <string, object>(); for (int i = 0; i < reader.FieldCount; i++) { obj[querys[i]] = reader[i]; } rückgabeWert.Add(obj); } DbConnection.Close(); return(rückgabeWert); }
private void FormUpdateUser_Load(object sender, System.EventArgs e) { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { this.textBox_user.Text = this.userStr; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select * from TUser where UEnabled=1 and UEID='" + KLineTestProcessor.EncrypDisposeFunc(this.userStr) + "'", connection).ExecuteReader(); if (dataReader.Read()) { this.textBox_name.Text = dataReader["UNAME"].ToString(); string tempStr = dataReader["UPWD"].ToString(); this.textBox_psw.Text = KLineTestProcessor.DecodeDisposeFunc(tempStr); } dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_BA_0) { KLineTestProcessor.ExceptionRecordFunc(arg_BA_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } catch (System.Exception arg_E0_0) { KLineTestProcessor.ExceptionRecordFunc(arg_E0_0.StackTrace); } }
public void ImportDataFromExcelEquity() { string excelFilePath = "C:/Users/ahksysuser06/Desktop/EDISData/International_Equity_Daily_Closing_Price_20131211.xlsx"; // make sure your sheet name is correct, here sheet name is sheet1, so you can change the sheet name if have different string excelQuery = "select SecId,Name,Symbol from [Sheet1$]"; try { string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFilePath + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;'"; OleDbConnection oleConn = new OleDbConnection(excelConnectionString); oleConn.Open(); OleDbDataReader oleReader = new OleDbCommand(excelQuery, oleConn).ExecuteReader(); //while (oleReader.Read()) //{ // Domain.Portfolio.AggregateRoots.Asset.Equity equity = new AustralianEquity(edisRepo) // { // Name = oleReader.GetString(1), // Sector = oleReader.GetString(0), // Ticker = oleReader.GetString(2), // EquityType = EquityTypes.AustralianEquity, // }; // edisRepo.InsertEquityData(equity); //} while (oleReader.Read()) { Domain.Portfolio.AggregateRoots.Asset.Equity equity = new InternationalEquity(edisRepo) { Name = oleReader.GetString(1), Sector = oleReader.GetString(0), Ticker = oleReader.GetString(2), EquityType = EquityTypes.InternationalEquity, }; edisRepo.InsertEquityData(equity); } oleReader.Close(); oleConn.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
internal string GenerateSAS(string RANumber, OleDbConnection conn) { StringBuilder stringBuilder = new StringBuilder(); OleDbDataReader oleDbDataReader = new OleDbCommand("SELECT PartsChanged as [INT], SRLCD as SHL, SFAIND as RFI From tblRepairHistory WHERE RANumber = " + RANumber, conn).ExecuteReader(); if (oleDbDataReader.HasRows) { stringBuilder.Append("<SAS_Segment>"); while (oleDbDataReader.Read()) { stringBuilder.Append("<" + oleDbDataReader.GetName(0).ToString() + ">" + oleDbDataReader.GetValue(0).ToString() + "</" + oleDbDataReader.GetName(0).ToString() + ">"); stringBuilder.Append("<" + oleDbDataReader.GetName(1).ToString() + ">R2</" + oleDbDataReader.GetName(1).ToString() + ">"); stringBuilder.Append("<" + oleDbDataReader.GetName(2).ToString() + ">1</" + oleDbDataReader.GetName(2).ToString() + ">"); } stringBuilder.Append("</SAS_Segment>"); } return(stringBuilder.ToString()); }
public void RefreshFormControlFunc() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select * from TConverterLibrary where ID = " + this.iEditPid, connection).ExecuteReader(); if (dataReader.Read()) { this.textBox_name.Text = dataReader["ConverterName"].ToString(); this.textBox_ConverterType.Text = dataReader["ConverterType"].ToString(); this.textBox_Remark.Text = dataReader["Remark"].ToString(); } dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_AD_0) { KLineTestProcessor.ExceptionRecordFunc(arg_AD_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } catch (System.Exception arg_D1_0) { KLineTestProcessor.ExceptionRecordFunc(arg_D1_0.StackTrace); } }
public void QueryUpdateConnectorInfoFunc(int iIndex, int iEditPid) { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select top 1 * from TConnectorLibrary where ID=" + iEditPid, connection).ExecuteReader(); if (dataReader.Read()) { this.dataGridView1.Rows[iIndex].Cells[2].Value = dataReader["ConverterType"].ToString(); this.dataGridView1.Rows[iIndex].Cells[3].Value = dataReader["PinNum"].ToString(); this.dataGridView1.Rows[iIndex].Cells[4].Value = dataReader["Remark"].ToString(); } dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_ED_0) { KLineTestProcessor.ExceptionRecordFunc(arg_ED_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } catch (System.Exception arg_111_0) { KLineTestProcessor.ExceptionRecordFunc(arg_111_0.StackTrace); } }
public static ArrayList Query(String query) { if (databaseCon.State != ConnectionState.Open) { databaseCon.Open(); } OleDbDataReader reader = new OleDbCommand(query, databaseCon).ExecuteReader(); ArrayList data = new ArrayList(); while (reader.Read()) { Dictionary <string, object> arr = new Dictionary <string, object>(); for (int i = 0; i < reader.FieldCount; i++) { arr[reader.GetName(i)] = reader[i]; } data.Add(arr); } databaseCon.Close(); return(data); }
public void ProcessRequest(HttpContext context) { string feng = context.Request["taste"]; var conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\2019-2020作业汇总\.net高级程序设计\实验\素材7\素材\db\HotelDb.mdb"); conn.Open(); string sqls = "select [餐谱编号],[名称] from [餐谱] where [风味]='" + feng + "'"; var reader = new OleDbCommand(sqls, conn).ExecuteReader(); var map = new Dictionary <int, string>(); var str = "{"; while (reader.Read()) { str += reader["餐谱编号"] + ":'" + reader["名称"] + "',"; } str += "}"; //查询【法式】成功后组合的json串为:{3:古典烧烤牛仔排,7:鲜虾杂菜沙津,9:苹果蛋奶酥班戟} context.Response.Clear(); context.Response.Write(str); context.Response.Flush(); }
public int SelectData(out string errMessage) { int num = 0; errMessage = null; OleDbConnection connection = null; OleDbDataReader reader = null; try { connection = new OleDbConnection { ConnectionString = this.connectionString }; connection.Open(); string str = "SELECT * FROM DBINFO"; reader = new OleDbCommand { Connection = connection, CommandText = str }.ExecuteReader(); while (reader.Read()) { num++; } } catch (Exception exception) { errMessage = "errMessage:" + exception.Message + string.Format("\r\n\r\nMethod Name : SelectData", new object[0]); num = -1; } finally { reader.Close(); reader.Dispose(); connection.Close(); connection.Dispose(); } return(num); }
internal string GenerateShopFindingsDetails(string OprCode, string customer, OleDbConnection conn) { StringBuilder stringBuilder = new StringBuilder(); if (OprCode != string.Empty) { OleDbDataReader oleDbDataReader = new OleDbCommand("SELECT * From tblRepairHistory WHERE OprCode = '" + OprCode + "' AND Customer = '" + customer + "'AND SerialNumber LIKE 'cj%' AND DateReceived Between #" + this.sd + "# AND #" + this.ed + "# Order by DateReceived DESC", conn).ExecuteReader(); new OleDbDataAdapter(new OleDbCommand("SELECT * From tblRepairHistory WHERE OprCode = '" + OprCode + "' AND Customer = '" + customer + "' AND SerialNumber LIKE 'cj%' AND DateReceived Between #" + this.sd + "# AND #" + this.ed + "# Order by DateReceived DESC", conn)).Fill(new DataSet()); if (oleDbDataReader.HasRows) { while (oleDbDataReader.Read()) { stringBuilder.Append("<ShopFindingsDetails>"); stringBuilder.Append(this.GenerateRCS(oleDbDataReader.GetValue(0).ToString(), conn)); stringBuilder.Append(this.GenerateSAS(oleDbDataReader.GetValue(0).ToString(), conn)); stringBuilder.Append(this.GenerateRLS(oleDbDataReader.GetValue(0).ToString(), conn)); stringBuilder.Append(this.GenerateAID(oleDbDataReader.GetValue(0).ToString(), conn)); stringBuilder.Append("</ShopFindingsDetails>"); } } } return(stringBuilder.ToString()); }
public void frmMain_Load(object sender, EventArgs e) { this.ActiveControl = txtSrchZanr; Thread t = new Thread(Administracija); t.Start(); t.Join(); txtSrchZanr.Focus(); string q = "select distinct nazivzanr from zanrovi order by nazivzanr asc"; try { DBManager.Connection.Open(); var reader = new OleDbCommand(q, DBManager.Connection).ExecuteReader(); while (reader.Read()) { listZanr.Items.Add(reader["NazivZanr"]); } DBManager.Connection.Close(); } catch { DBManager.Connection.Close(); } finally { DBManager.Connection.Close(); } label2.Text = DateTime.Now.ToLongTimeString(); label3.Text = DateTime.Now.ToShortDateString(); }
internal string GenerateATT(string RANumber, OleDbConnection conn) { StringBuilder stringBuilder = new StringBuilder(); OleDbDataReader oleDbDataReader = new OleDbCommand("SELECT TCRCD as TRF, ODT From tblRepairHistory WHERE RANumber = " + RANumber, conn).ExecuteReader(); if (oleDbDataReader.HasRows) { stringBuilder.Append("<ATT_Segment>"); while (oleDbDataReader.Read()) { if (oleDbDataReader.GetValue(0).ToString() != string.Empty) { stringBuilder.Append("<" + oleDbDataReader.GetName(0).ToString() + ">" + oleDbDataReader.GetValue(0).ToString() + "</" + oleDbDataReader.GetName(0).ToString() + ">"); stringBuilder.Append("<" + oleDbDataReader.GetName(1).ToString() + ">" + oleDbDataReader.GetValue(1).ToString() + "</" + oleDbDataReader.GetName(1).ToString() + ">"); } else { stringBuilder.Append("<" + oleDbDataReader.GetName(0).ToString() + ">" + oleDbDataReader.GetValue(0).ToString() + "</" + oleDbDataReader.GetName(0).ToString() + ">"); } } stringBuilder.Append("</ATT_Segment>"); } return(stringBuilder.ToString()); }
internal void GenerateXML(DateTime StartDate, DateTime EndDate) { try { this.sd = string.Format("{0:MM/dd/yyyy}", (object)StartDate); this.ed = string.Format("{0:MM/dd/yyyy}", (object)EndDate); OleDbConnection oleDbConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;data source='" + this.fpath + "';Jet OLEDB:Database Password=''"); oleDbConnection.Open(); OleDbDataReader oleDbDataReader = new OleDbCommand("SELECT DISTINCT OprCode as OPR,Customer FROM tblRepairHistory WHERE SerialNumber LIKE 'cj%' AND OprCode not in(NULL,'0') AND DateReceived Between #" + this.sd + "# AND #" + this.ed + "# ", oleDbConnection).ExecuteReader(); new OleDbDataAdapter(new OleDbCommand("SELECT DISTINCT OprCode as OPR,Customer FROM tblRepairHistory WHERE SerialNumber LIKE 'cj%' AND OprCode not in(NULL,'0') AND DateReceived Between #" + this.sd + "# AND #" + this.ed + "# ", oleDbConnection)).Fill(new DataSet()); StringBuilder stringBuilder = new StringBuilder(); if (oleDbDataReader.HasRows) { stringBuilder.Append("<?xml version='1.0' encoding='UTF-8' ?> "); stringBuilder.Append("<ATA_InformationSet xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='Modular_Schema\\ATA_InformationSet.xsd' id='R2009.1' version='1.0'>"); while (oleDbDataReader.Read()) { stringBuilder.Append("<ReliabilityData>"); stringBuilder.Append("<ShopFindings version='2.00'>"); stringBuilder.Append("<HDR_Segment>"); stringBuilder.Append("<CHG>N</CHG>"); stringBuilder.Append("<ROC>10933</ROC>"); stringBuilder.Append("<RDT>" + StartDate.ToString("yyyy-MM-dd") + "</RDT>"); stringBuilder.Append("<RSD>" + EndDate.ToString("yyyy-MM-dd") + "</RSD>"); stringBuilder.Append("<" + oleDbDataReader.GetName(0).ToString() + ">" + oleDbDataReader.GetValue(0).ToString() + "</" + oleDbDataReader.GetName(0).ToString() + ">"); stringBuilder.Append("<RON>Avionic Instruments LLC</RON>"); if (oleDbDataReader.GetValue(0).ToString() == "ZZZZZ") { stringBuilder.Append("<WHO>" + oleDbDataReader.GetValue(1).ToString() + "</WHO>"); } stringBuilder.Append("</HDR_Segment>"); stringBuilder.Append(this.GenerateShopFindingsDetails(oleDbDataReader.GetValue(0).ToString(), oleDbDataReader.GetValue(1).ToString(), oleDbConnection)); stringBuilder.Append("</ShopFindings>"); stringBuilder.Append("</ReliabilityData>"); } stringBuilder.Append("</ATA_InformationSet>"); } string str = "report_" + DateTime.Now.Date.ToString("MM-dd-yy") + ".xml"; Directory.CreateDirectory(".\\reports"); if (File.Exists(".\\reports\\" + str)) { int num = (int)this.saveFileDialog1.ShowDialog(); TextWriter textWriter = (TextWriter) new StreamWriter(this.fpath_new); Directory.GetParent(this.fpath_new).ToString(); Process.Start(Directory.GetParent(this.fpath_new).ToString()); textWriter.Write(stringBuilder.ToString()); textWriter.Close(); } else { TextWriter textWriter = (TextWriter) new StreamWriter(".\\reports\\" + str); Process.Start(".\\reports"); textWriter.Write(stringBuilder.ToString()); textWriter.Close(); } oleDbConnection.Close(); Application.Exit(); } catch (OleDbException ex) { throw ex; } }
static void Main(string[] args) { #region Init Console.WriteLine("建立数据库..."); OleDbDataReader reader; string dConnS = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True"; bool flag = true; SqlConnection dbConn; flag: dbConn = new SqlConnection(dConnS); try { dbConn.Open(); } catch (SqlException exp) { if (flag) { dConnS = "Data Source=(local);Initial Catalog=master;Integrated Security=True"; flag = false; } else { Console.WriteLine("无法自动连接数据库,请手动输入DataSource。\n例如(local)\\SQLEXPRESS"); dConnS = "Data Source=" + Console.ReadLine() + ";Initial Catalog=master;Integrated Security=True"; } goto flag; } SqlDataReader re; re = new SqlCommand("select count(*) from sys.databases where name='plent' or name ='insect' or name ='users'", dbConn).ExecuteReader(); re.Read(); if (int.Parse(re.GetValue(0).ToString()) > 0) { re.Close(); Console.WriteLine("检测到已存在数据库plent或insect或users。\n即将删库并重新建立。输入9确认,按任意键结束程序。"); if (Console.ReadKey().KeyChar == 57) { try { new SqlCommand("drop database plent,insect,users", dbConn).ExecuteNonQuery(); Console.WriteLine("删库完成"); } catch (Exception exp) { } } else { dbConn.Close(); return; } } else { re.Close(); } new SqlCommand("create database insect\ncreate database plent\ncreate database users", dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("建库完成"); #endregion #region users Console.WriteLine("用户库建表..."); dbConn = new SqlConnection("Data Source=(local)" + (flag?"\\SQLEXPRESS":"") + ";Initial Catalog=users;Integrated Security=True"); dbConn.Open(); new SqlCommand(File.ReadAllText(".\\sqlusers.txt", Encoding.Default), dbConn).ExecuteNonQuery(); dbConn.Close(); #endregion #region insect Console.WriteLine("昆虫库建表..."); dbConn = new SqlConnection("Data Source=(local)" + (flag ? "\\SQLEXPRESS" : "") + ";Initial Catalog=insect;Integrated Security=True"); dbConn.Open(); new SqlCommand(File.ReadAllText(".\\sqlinsect.txt", Encoding.Default), dbConn).ExecuteNonQuery(); string eConnS = "Provider=Microsoft.Ace.OleDb.12.0;Data Source=.\\insect.xlsx;Extended Properties='Excel 8.0;HDR=yes;IMEX=1'"; OleDbConnection OleConn = new OleDbConnection(eConnS); dbConn.Close(); string insert; Console.WriteLine("填充目表..."); OleConn.Open(); reader = new OleDbCommand("SELECT * FROM [目$]", OleConn).ExecuteReader(); insert = "INSERT INTO orders VALUES "; if (reader.Read()) { insert += "('" + reader.GetValue(0) + "','" + reader.GetValue(1) + "','" + reader.GetValue(2) + "')"; } while (reader.Read()) { insert += ",('" + reader.GetValue(0) + "','" + reader.GetValue(1) + "','" + reader.GetValue(2) + "')"; } OleConn.Close(); dbConn.Open(); new SqlCommand(insert, dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("填充科表..."); OleConn.Open(); reader = new OleDbCommand("SELECT * FROM [科$]", OleConn).ExecuteReader(); insert = "INSERT INTO family VALUES "; if (reader.Read()) { insert += "('" + reader.GetValue(0) + "','" + reader.GetValue(1) + "','" + reader.GetValue(2) + "',(select oname from orders where c_oname='" + reader.GetValue(3) + "'))"; } while (reader.Read()) { insert += ",('" + reader.GetValue(0) + "','" + reader.GetValue(1) + "','" + reader.GetValue(2) + "',(select oname from orders where c_oname='" + reader.GetValue(3) + "'))"; } OleConn.Close(); dbConn.Open(); new SqlCommand(insert, dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("填充种表..."); OleConn.Open(); reader = new OleDbCommand("SELECT * FROM [种$]", OleConn).ExecuteReader(); insert = "INSERT INTO species VALUES "; if (reader.Read()) { insert += "(" + reader.GetValue(0) + ",'" + reader.GetValue(1) + "','" + reader.GetValue(2) + "',(select fname from family where c_fname='" + reader.GetValue(3) + "'))"; } while (reader.Read()) { insert += ",(" + reader.GetValue(0) + ",'" + reader.GetValue(1) + "','" + reader.GetValue(2) + "',(select fname from family where c_fname='" + reader.GetValue(3) + "'))"; } OleConn.Close(); dbConn.Open(); new SqlCommand(insert, dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("填充特征表..."); OleConn.Open(); reader = new OleDbCommand("SELECT * FROM [特征$]", OleConn).ExecuteReader(); insert = "INSERT INTO features VALUES "; if (reader.Read()) { insert += "(" + reader.GetValue(0) + ",'" + reader.GetValue(1) + "','" + reader.GetValue(2) + "','" + reader.GetValue(3) + "','" + reader.GetValue(4) + "'," + (reader.GetValue(5).ToString())[0] + ")"; } while (reader.Read()) { try { insert += ",(" + reader.GetValue(0) + ",'" + reader.GetValue(1) + "','" + reader.GetValue(2) + "','" + reader.GetValue(3) + "','" + reader.GetValue(4) + "'," + (reader.GetValue(5).ToString())[0] + ")"; } catch (Exception exp) { } } OleConn.Close(); dbConn.Open(); new SqlCommand(insert, dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("昆虫库添加存储过程"); dbConn.Open(); string si = File.ReadAllText(".\\insect.txt", Encoding.Default); int leni = si.Length; int lasti = 0; for (int i = 0; i < leni; i++) { if (si[i] == ';') { new SqlCommand(Extract(si, lasti, i), dbConn).ExecuteNonQuery(); lasti = i + 1; } } Console.WriteLine("昆虫库完成"); #endregion #region plent Console.WriteLine("植物库建表..."); dConnS = "Data Source=(local)" + (flag ? "\\SQLEXPRESS" : "") + ";Initial Catalog=plent;Integrated Security=True"; eConnS = "Provider=Microsoft.Ace.OleDb.12.0;Data Source=.\\plent.xlsx;Extended Properties='Excel 8.0;HDR=yes;IMEX=1'"; OleConn = new OleDbConnection(eConnS); dbConn = new SqlConnection(dConnS); dbConn.Open(); new SqlCommand(File.ReadAllText(".\\sqlplent.txt", Encoding.Default), dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("填充纲表..."); OleConn.Open(); reader = new OleDbCommand("SELECT * FROM [纲$]", OleConn).ExecuteReader(); insert = "INSERT INTO class VALUES "; if (reader.Read()) { insert += "('" + reader.GetValue(0) + "','" + reader.GetValue(1) + "','" + reader.GetValue(2) + "')"; } while (reader.Read()) { insert += ",('" + reader.GetValue(0) + "','" + reader.GetValue(1) + "','" + reader.GetValue(2) + "')"; } OleConn.Close(); dbConn.Open(); new SqlCommand(insert, dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("填充科表..."); OleConn.Open(); reader = new OleDbCommand("SELECT * FROM [科$]", OleConn).ExecuteReader(); while (reader.Read()) { insert += "INSERT INTO family VALUES " + "('" + reader.GetValue(0) + "','" + reader.GetValue(1) + "','" + reader.GetValue(2) + "',(select cname from class where c_cname='" + reader.GetValue(3) + "'))"; } OleConn.Close(); dbConn.Open(); try { new SqlCommand(insert, dbConn).ExecuteNonQuery(); } catch (Exception exp) { } dbConn.Close(); Console.WriteLine("填充种表..."); OleConn.Open(); reader = new OleDbCommand("SELECT * FROM [种$]", OleConn).ExecuteReader(); insert = "INSERT INTO species VALUES "; if (reader.Read()) { insert += "(" + reader.GetValue(0) + ",'" + reader.GetValue(1) + "','" + reader.GetValue(2) + "',(select fname from family where c_fname='" + reader.GetValue(3) + "'))"; } while (reader.Read()) { if (reader.GetValue(0).ToString() == "") { break; } else { insert += ",(" + reader.GetValue(0) + ",'" + reader.GetValue(1) + "','" + reader.GetValue(2) + "',(select fname from family where c_fname='" + reader.GetValue(3) + "'))"; } } OleConn.Close(); dbConn.Open(); new SqlCommand(insert, dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("填充特征表..."); OleConn.Open(); reader = new OleDbCommand("SELECT * FROM [特征$]", OleConn).ExecuteReader(); insert = "INSERT INTO features VALUES "; if (reader.Read()) { insert += "(" + reader.GetValue(0) + ",'" + reader.GetValue(1) + "','" + reader.GetValue(2) + "','" + reader.GetValue(3) + "','" + reader.GetValue(4) + "','" + reader.GetValue(5) + "','" + reader.GetValue(6) + "')"; } while (reader.Read()) { insert += ",(" + reader.GetValue(0) + ",'" + reader.GetValue(1) + "','" + reader.GetValue(2) + "','" + reader.GetValue(3) + "','" + reader.GetValue(4) + "','" + reader.GetValue(5) + "','" + reader.GetValue(6) + "')"; } OleConn.Close(); dbConn.Open(); new SqlCommand(insert, dbConn).ExecuteNonQuery(); dbConn.Close(); Console.WriteLine("植物库填充存储过程..."); dbConn = new SqlConnection(dConnS); dbConn.Open(); string sp = File.ReadAllText(".\\plent.txt", Encoding.Default); int len = sp.Length; int lastp = 0; for (int i = 0; i < len; i++) { if (sp[i] == ';') { new SqlCommand(Extract(sp, lastp, i), dbConn).ExecuteNonQuery(); lastp = i + 1; } } dbConn.Close(); #endregion Console.WriteLine("植物库完成\n建立数据库完成\n按任意键退出"); Console.ReadKey(); }
public void GLDealwithFunc() { OleDbConnection connection = null; string sqlcommand = null; OleDbDataReader dataReader = null; try { this.dataGridView1.Rows.Clear(); int inum = 0; string cNameStr = this.textBox_Connector.Text.ToString().Trim(); try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); if (this.comboBox_sxtj.SelectedIndex == 0) { if (string.IsNullOrEmpty(cNameStr)) { sqlcommand = "select * from TConnectorLibrary order by ConnectorName"; } else { sqlcommand = "select * from TConnectorLibrary where ConnectorName like '%" + cNameStr + "%' order by ConnectorName"; } } else if (this.comboBox_sxtj.SelectedIndex == 1) { if (string.IsNullOrEmpty(cNameStr)) { sqlcommand = "select * from TConnectorLibrary order by ConverterType"; } else { sqlcommand = "select * from TConnectorLibrary where ConverterType like '%" + cNameStr + "%' order by ConverterType"; } } else if (this.comboBox_sxtj.SelectedIndex == 2) { if (string.IsNullOrEmpty(cNameStr)) { sqlcommand = "select * from TConnectorLibrary order by PinNum"; } else { sqlcommand = "select * from TConnectorLibrary where PinNum='" + cNameStr + "'"; } } dataReader = new OleDbCommand(sqlcommand, connection).ExecuteReader(); this.dataGridView1.AllowUserToAddRows = true; while (dataReader.Read()) { this.dataGridView1.Rows.Add(1); int num = inum + 1; this.dataGridView1.Rows[inum].Cells[0].Value = System.Convert.ToString(num); this.strIDArray[inum] = dataReader["ID"].ToString(); this.dataGridView1.Rows[inum].Cells[1].Value = dataReader["ConnectorName"].ToString(); this.dataGridView1.Rows[inum].Cells[2].Value = dataReader["ConverterType"].ToString(); this.dataGridView1.Rows[inum].Cells[3].Value = dataReader["PinNum"].ToString(); this.dataGridView1.Rows[inum].Cells[4].Value = dataReader["Remark"].ToString(); inum = num; if (inum >= 5000) { break; } } this.dataGridView1.AllowUserToAddRows = false; dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_26D_0) { this.dataGridView1.AllowUserToAddRows = false; KLineTestProcessor.ExceptionRecordFunc(arg_26D_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } catch (System.Exception arg_291_0) { KLineTestProcessor.ExceptionRecordFunc(arg_291_0.StackTrace); } }
private void btnQuery_Click(object sender, System.EventArgs e) { OleDbConnection connection = null; string sqlcommand = null; OleDbDataReader dataReader = null; try { System.ValueType dt = this.dateTimePicker_start.Value; System.ValueType dt2 = this.dateTimePicker_stop.Value; System.ValueType valueType = default(System.DateTime); (System.DateTime)valueType = new System.DateTime(((System.DateTime)dt).Year, ((System.DateTime)dt).Month, ((System.DateTime)dt).Day, 0, 0, 0, 0); System.ValueType startdt = valueType; System.ValueType valueType2 = default(System.DateTime); (System.DateTime)valueType2 = new System.DateTime(((System.DateTime)dt2).Year, ((System.DateTime)dt2).Month, ((System.DateTime)dt2).Day, 23, 59, 59, 999); System.ValueType stopdt = valueType2; System.DateTime value = this.dateTimePicker_stop.Value; if (System.DateTime.Compare(this.dateTimePicker_start.Value, value) > 0) { MessageBox.Show("起始日期大于终止日期!", "提示", MessageBoxButtons.OK); } else { string _cablebhStr = this.textBox_cableName.Text.ToString(); string batchMumberStr = this.textBox_batchMumber.Text.ToString().Trim(); this.userIDStrList.Clear(); this.dataGridView1.Rows.Clear(); this.btnDelRecord.Visible = false; int inum = 0; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.mddbPathStr; connection.Open(); if (string.IsNullOrEmpty(_cablebhStr) && string.IsNullOrEmpty(batchMumberStr)) { sqlcommand = "select * from THistoryDataInfo where TestTime Between #" + valueType + "# and #" + valueType2 + "# ORDER BY ID DESC"; } else if (!string.IsNullOrEmpty(_cablebhStr) && !string.IsNullOrEmpty(batchMumberStr)) { sqlcommand = "select * from THistoryDataInfo where batchMumberStr = '" + batchMumberStr + "' and bcCableName = '" + _cablebhStr + "' and TestTime Between #" + valueType + "# and #" + valueType2 + "# ORDER BY ID DESC"; } else if (string.IsNullOrEmpty(_cablebhStr) && !string.IsNullOrEmpty(batchMumberStr)) { sqlcommand = "select * from THistoryDataInfo where batchMumberStr = '" + batchMumberStr + "' and TestTime Between #" + valueType + "# and #" + valueType2 + "# ORDER BY ID DESC"; } else if (!string.IsNullOrEmpty(_cablebhStr) && string.IsNullOrEmpty(batchMumberStr)) { sqlcommand = "select * from THistoryDataInfo where bcCableName = '" + _cablebhStr + "' and TestTime Between #" + valueType + "# and #" + valueType2 + "# ORDER BY ID DESC"; } dataReader = new OleDbCommand(sqlcommand, connection).ExecuteReader(); this.dataGridView1.AllowUserToAddRows = true; while (dataReader.Read()) { this.dataGridView1.Rows.Add(1); int num = inum + 1; this.dataGridView1.Rows[inum].Cells[0].Value = System.Convert.ToString(num); this.strIDArray[inum] = dataReader["ID"].ToString(); this.dataGridView1.Rows[inum].Cells[1].Value = dataReader["ProjectName"].ToString(); this.dataGridView1.Rows[inum].Cells[3].Value = dataReader["batchMumberStr"].ToString(); this.dataGridView1.Rows[inum].Cells[2].Value = dataReader["bcCableName"].ToString(); this.dataGridView1.Rows[inum].Cells[4].Value = dataReader["TestTime"].ToString(); this.userIDStrList.Add(dataReader["Tester"].ToString()); this.dataGridView1.Rows[inum].Cells[5].Value = dataReader["Operator"].ToString(); this.dataGridView1.Rows[inum].Cells[6].Value = dataReader["TestResult"].ToString(); inum = num; if (inum >= 5000) { break; } } this.dataGridView1.AllowUserToAddRows = false; dataReader.Close(); dataReader = null; connection.Close(); connection = null; if (inum <= 0) { MessageBox.Show("查无记录!", "提示", MessageBoxButtons.OK); return; } } catch (System.Exception arg_4AE_0) { this.dataGridView1.AllowUserToAddRows = false; KLineTestProcessor.ExceptionRecordFunc(arg_4AE_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } this.qCablebhStr = _cablebhStr; this.qStartdt = startdt; this.qStopdt = stopdt; this.qMethod = 0; } } catch (System.Exception arg_4F0_0) { KLineTestProcessor.ExceptionRecordFunc(arg_4F0_0.StackTrace); } }
public void LoadDefaultParaFunc() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { bool bExsitFlag = false; string dbpath = Application.StartupPath + "\\ctsdb.mdb"; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select * from TReportParaSet", connection).ExecuteReader(); if (dataReader.Read()) { bExsitFlag = true; this.iReportTemplateFormat = System.Convert.ToInt32(dataReader["iReportTemplateFormat"].ToString()); } dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_7C_0) { KLineTestProcessor.ExceptionRecordFunc(arg_7C_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } if (bExsitFlag) { int num = this.iReportTemplateFormat; if (num == 0) { this.radioButton_ShowFormat_All.Checked = true; } else if (num == 1) { this.radioButton_ShowFormat_Err.Checked = true; } else if (num == 2) { this.radioButton_ShowFormat_Mea.Checked = true; } } } catch (System.Exception arg_DD_0) { KLineTestProcessor.ExceptionRecordFunc(arg_DD_0.StackTrace); } }
public void LoginDisposeFunc() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { string userStr = this.textBox_UserName.Text.ToString(); string secrStr = this.textBox_Password.Text.ToString(); if (!string.IsNullOrEmpty(userStr) && !string.IsNullOrEmpty(secrStr)) { this.bIsAdminFlag = false; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); string arg_A4_0 = "select * from TUser where UEnabled = 1"; if (-1 != userStr.ToUpper().LastIndexOf("ADMIN")) { arg_A4_0 = "select * from TAdmin where UEnabled = 1"; this.bIsAdminFlag = true; } dataReader = new OleDbCommand(arg_A4_0, connection).ExecuteReader(); while (dataReader.Read()) { string uidStr = dataReader["UEID"].ToString(); this.loginName = dataReader["UNAME"].ToString(); string upsStr = dataReader["UPWD"].ToString(); string uStr = KLineTestProcessor.EncrypDisposeFunc(userStr); string sStr = KLineTestProcessor.EncrypDisposeFunc(secrStr); if (uStr == uidStr && sStr == upsStr) { this.bLoginSuccFlag = true; this.loginUser = userStr; this.loginSecr = secrStr; break; } } dataReader.Close(); connection.Close(); dataReader = null; connection = null; } catch (System.Exception arg_15E_0) { if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } KLineTestProcessor.ExceptionRecordFunc(arg_15E_0.StackTrace); goto IL_19C; } if (!this.bLoginSuccFlag) { MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.OK); } else { string contStr = "登录系统"; this.saveOperationRecord(contStr); base.Close(); } IL_19C :; } else { MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.OK); } } catch (System.Exception arg_1B1_0) { KLineTestProcessor.ExceptionRecordFunc(arg_1B1_0.StackTrace); } }
private void btnOpenProj_Click(object sender, System.EventArgs e) { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { string projectNameStr = this.textBox_tm.Text.ToString().Trim(); if (string.IsNullOrEmpty(projectNameStr)) { MessageBox.Show("项目名为空!", "提示", MessageBoxButtons.OK); } else { bool bExsitFlag = false; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select top 1 * from TProjectInfo where ProjectName = '" + projectNameStr + "'", connection).ExecuteReader(); if (dataReader.Read()) { bExsitFlag = true; } dataReader.Close(); dataReader = null; if (!bExsitFlag) { connection.Close(); connection = null; MessageBox.Show("项目不存在!", "提示", MessageBoxButtons.OK); } else { this.bOpenProjectFlag = true; this.testProjectNameStr = projectNameStr; base.Close(); } } catch (System.Exception arg_BE_0) { KLineTestProcessor.ExceptionRecordFunc(arg_BE_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } } catch (System.Exception arg_E2_0) { KLineTestProcessor.ExceptionRecordFunc(arg_E2_0.StackTrace); } }
public void RefreshDataGridView() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { this.dataGridView1.Rows.Clear(); int inum = 0; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select top " + 5000 + " * from TProjectInfo order by ID desc", connection).ExecuteReader(); this.dataGridView1.AllowUserToAddRows = true; while (dataReader.Read()) { this.dataGridView1.Rows.Add(1); int num = inum + 1; this.dataGridView1.Rows[inum].Cells[0].Value = System.Convert.ToString(num); this.strIDArray[inum] = dataReader["ID"].ToString(); this.dataGridView1.Rows[inum].Cells[1].Value = dataReader["ProjectName"].ToString(); string cpStr = dataReader["iCommonProject"].ToString(); if (cpStr == "1") { this.dataGridView1.Rows[inum].Cells[4].Value = "是"; } else { this.dataGridView1.Rows[inum].Cells[4].Value = "否"; } this.dataGridView1.Rows[inum].Cells[3].Value = dataReader["batchMumberStr"].ToString(); this.dataGridView1.Rows[inum].Cells[2].Value = dataReader["bcCableName"].ToString(); this.dataGridView1.Rows[inum].Cells[5].Value = dataReader["Remark"].ToString(); inum = num; if (inum >= 5000) { break; } } this.dataGridView1.AllowUserToAddRows = false; dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_23B_0) { this.dataGridView1.AllowUserToAddRows = false; KLineTestProcessor.ExceptionRecordFunc(arg_23B_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } catch (System.Exception arg_25F_0) { KLineTestProcessor.ExceptionRecordFunc(arg_25F_0.StackTrace); } }
public void ShowPinRelationFunc() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { int iIndex = 0; if (this.bDLHistoryInfoView) { try { try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.mddbPathStr; connection.Open(); dataReader = new OleDbCommand("select * from THistoryDLDataDetail where HID=" + this.iEditPid + "", connection).ExecuteReader(); this.dataGridView1.AllowUserToAddRows = true; while (dataReader.Read()) { string temp1Str = dataReader["PlugName1"].ToString(); string temp2Str = dataReader["Pin1"].ToString(); string temp3Str = dataReader["PlugName2"].ToString(); string temp4Str = dataReader["Pin2"].ToString(); this.dataGridView1.Rows.Add(1); int num = iIndex + 1; int num2 = num; this.dataGridView1.Rows[iIndex].Cells[0].Value = num2.ToString(); this.dataGridView1.Rows[iIndex].Cells[1].Value = temp1Str; this.dataGridView1.Rows[iIndex].Cells[2].Value = temp2Str; this.dataGridView1.Rows[iIndex].Cells[3].Value = temp3Str; this.dataGridView1.Rows[iIndex].Cells[4].Value = temp4Str; iIndex = num; } dataReader.Close(); dataReader = null; this.dataGridView1.AllowUserToAddRows = false; connection.Close(); connection = null; } catch (System.Exception arg_1D0_0) { this.dataGridView1.AllowUserToAddRows = false; KLineTestProcessor.ExceptionRecordFunc(arg_1D0_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } goto IL_383; } catch (System.Exception arg_1F7_0) { KLineTestProcessor.ExceptionRecordFunc(arg_1F7_0.StackTrace); goto IL_383; } } if (this.gLineTestProcessor.gDLPinConnectInfoDLResultArray != null) { for (int i = 0; i < this.gLineTestProcessor.gDLPinConnectInfoDLResultArray.Count; i++) { string temp1Str = this.gLineTestProcessor.gDLPinConnectInfoDLResultArray[i].mALJQName; string temp2Str = this.gLineTestProcessor.gDLPinConnectInfoDLResultArray[i].mnALJQPinNum; string temp3Str = this.gLineTestProcessor.gDLPinConnectInfoDLResultArray[i].mBLJQName; string temp4Str = this.gLineTestProcessor.gDLPinConnectInfoDLResultArray[i].mnBLJQPinNum; this.dataGridView1.AllowUserToAddRows = true; this.dataGridView1.Rows.Add(1); int num3 = iIndex + 1; int num4 = num3; this.dataGridView1.Rows[iIndex].Cells[0].Value = num4.ToString(); this.dataGridView1.Rows[iIndex].Cells[1].Value = temp1Str; this.dataGridView1.Rows[iIndex].Cells[2].Value = temp2Str; this.dataGridView1.Rows[iIndex].Cells[3].Value = temp3Str; this.dataGridView1.Rows[iIndex].Cells[4].Value = temp4Str; this.dataGridView1.AllowUserToAddRows = false; iIndex = num3; } } IL_383 :; } catch (System.Exception arg_385_0) { KLineTestProcessor.ExceptionRecordFunc(arg_385_0.StackTrace); } }
public void GLDealwithFunc() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { string pnStr = this.textBox_Project.Text.ToString().Trim(); this.dataGridView1.Rows.Clear(); int inum = 0; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand((!string.IsNullOrEmpty(pnStr)) ? ("select * from TProjectInfo where ProjectName like '%" + pnStr + "%' order by ID desc") : "select * from TProjectInfo order by ID desc", connection).ExecuteReader(); this.dataGridView1.AllowUserToAddRows = true; while (dataReader.Read()) { this.dataGridView1.Rows.Add(1); int num = inum + 1; this.dataGridView1.Rows[inum].Cells[0].Value = System.Convert.ToString(num); this.strIDArray[inum] = dataReader["ID"].ToString(); this.dataGridView1.Rows[inum].Cells[1].Value = dataReader["ProjectName"].ToString(); string cpStr = dataReader["iCommonProject"].ToString(); if (cpStr == "1") { this.dataGridView1.Rows[inum].Cells[4].Value = "是"; } else { this.dataGridView1.Rows[inum].Cells[4].Value = "否"; } this.dataGridView1.Rows[inum].Cells[3].Value = dataReader["batchMumberStr"].ToString(); this.dataGridView1.Rows[inum].Cells[2].Value = dataReader["bcCableName"].ToString(); this.dataGridView1.Rows[inum].Cells[5].Value = dataReader["Remark"].ToString(); inum = num; if (inum >= 5000) { break; } } this.dataGridView1.AllowUserToAddRows = false; dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_25A_0) { this.dataGridView1.AllowUserToAddRows = false; KLineTestProcessor.ExceptionRecordFunc(arg_25A_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } catch (System.Exception arg_27E_0) { KLineTestProcessor.ExceptionRecordFunc(arg_27E_0.StackTrace); } }
private void ctFormProjectCopy_Load(object sender, System.EventArgs e) { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { TProjectInfoStruct tProjectInfoStruct = new TProjectInfoStruct(); this.projectInfoStruct = tProjectInfoStruct; tProjectInfoStruct.Creator = this.gLineTestProcessor.loginUserID; bool bExistFlag = false; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select top 1 * from TProjectInfo where ID=" + this.iCopyProjextID, connection).ExecuteReader(); if (dataReader.Read()) { this.projectInfoStruct.iID = System.Convert.ToInt32(dataReader["ID"].ToString()); this.projectInfoStruct.ProjectName = dataReader["ProjectName"].ToString(); this.projectInfoStruct.iCommonProject = System.Convert.ToInt32(dataReader["iCommonProject"].ToString()); this.projectInfoStruct.iTestModel = System.Convert.ToInt32(dataReader["iTestModel"].ToString()); this.projectInfoStruct.iDTTestModel = System.Convert.ToInt32(dataReader["iDTTestModel"].ToString()); this.projectInfoStruct.iJYTestModel = System.Convert.ToInt32(dataReader["iJYTestModel"].ToString()); this.projectInfoStruct.iNYTestModel = System.Convert.ToInt32(dataReader["iNYTestModel"].ToString()); this.projectInfoStruct.dDT_Threshold = System.Convert.ToDouble(dataReader["dDT_Threshold"].ToString()); this.projectInfoStruct.dDT_DTVoltage = System.Convert.ToDouble(dataReader["dDT_DTVoltage"].ToString()); this.projectInfoStruct.dDT_DTCurrent = System.Convert.ToDouble(dataReader["dDT_DTCurrent"].ToString()); this.projectInfoStruct.dJY_Threshold = System.Convert.ToDouble(dataReader["dJY_Threshold"].ToString()); this.projectInfoStruct.dJY_JYHoldTime = System.Convert.ToDouble(dataReader["dJY_JYHoldTime"].ToString()); this.projectInfoStruct.dJY_DCHighVolt = System.Convert.ToDouble(dataReader["dJY_DCHighVolt"].ToString()); this.projectInfoStruct.dJY_DCRiseTime = System.Convert.ToDouble(dataReader["dJY_DCRiseTime"].ToString()); this.projectInfoStruct.dNY_Threshold = System.Convert.ToDouble(dataReader["dNY_Threshold"].ToString()); this.projectInfoStruct.dNY_NYHoldTime = System.Convert.ToDouble(dataReader["dNY_NYHoldTime"].ToString()); this.projectInfoStruct.dNY_ACHighVolt = System.Convert.ToDouble(dataReader["dNY_ACHighVolt"].ToString()); this.projectInfoStruct.other1 = System.Convert.ToDouble(dataReader["other1"].ToString()); this.projectInfoStruct.other2 = System.Convert.ToDouble(dataReader["other2"].ToString()); this.projectInfoStruct.iGroupTestFlag = System.Convert.ToInt32(dataReader["iGroupTestFlag"].ToString()); this.projectInfoStruct.batchMumberStr = dataReader["batchMumberStr"].ToString(); this.projectInfoStruct.bcCableName = dataReader["bcCableName"].ToString(); this.projectInfoStruct.Remark = dataReader["Remark"].ToString(); bExistFlag = true; } dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_34D_0) { KLineTestProcessor.ExceptionRecordFunc(arg_34D_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } if (bExistFlag) { this.textBox_yxmmc.Text = this.projectInfoStruct.ProjectName; this.textBox_copyPN.Text = this.projectInfoStruct.ProjectName + "_副本"; this.textBox_ybcxs.Text = this.projectInfoStruct.bcCableName; this.textBox_CopyXS.Text = this.projectInfoStruct.bcCableName + "_副本"; } } catch (System.Exception arg_3E0_0) { KLineTestProcessor.ExceptionRecordFunc(arg_3E0_0.StackTrace); } try { if (this.gLineTestProcessor.iUIDisplayMode == 0) { base.WindowState = FormWindowState.Normal; } } catch (System.Exception arg_403_0) { KLineTestProcessor.ExceptionRecordFunc(arg_403_0.StackTrace); } }
public void LoadDefaultParaFunc() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { double d_JY_DCVolt_Min = 0.0; double d_JY_DCVolt_Max = 0.0; double d_NY_ACVolt_Min = 0.0; double d_NY_ACVolt_Max = 0.0; bool bExsitFlag = false; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select * from TTestParaRangeTable", connection).ExecuteReader(); if (dataReader.Read()) { bExsitFlag = true; d_JY_DCVolt_Min = System.Convert.ToDouble(dataReader["d_JY_DCVolt_Min"].ToString()); d_JY_DCVolt_Max = System.Convert.ToDouble(dataReader["d_JY_DCVolt_Max"].ToString()); d_NY_ACVolt_Min = System.Convert.ToDouble(dataReader["d_NY_ACVolt_Min"].ToString()); d_NY_ACVolt_Max = System.Convert.ToDouble(dataReader["d_NY_ACVolt_Max"].ToString()); } dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_D6_0) { KLineTestProcessor.ExceptionRecordFunc(arg_D6_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } if (bExsitFlag) { decimal maximum = System.Convert.ToDecimal(d_JY_DCVolt_Max); this.numericUpDown_HV_DC.Maximum = maximum; decimal value = System.Convert.ToDecimal(d_JY_DCVolt_Min); this.numericUpDown_HV_DC.Value = value; decimal maximum2 = System.Convert.ToDecimal(d_NY_ACVolt_Max); this.numericUpDown_HV_AC.Maximum = maximum2; decimal value2 = System.Convert.ToDecimal(d_NY_ACVolt_Min); this.numericUpDown_HV_AC.Value = value2; decimal maximum3 = System.Convert.ToDecimal(d_JY_DCVolt_Max); this.numericUpDown_LV_DC.Maximum = maximum3; decimal value3 = System.Convert.ToDecimal(d_JY_DCVolt_Min); this.numericUpDown_LV_DC.Value = value3; } } catch (System.Exception arg_181_0) { KLineTestProcessor.ExceptionRecordFunc(arg_181_0.StackTrace); } }
public void RefreshDataGridView() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { this.dataGridView1.Rows.Clear(); int iUserCount = 0; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.dbPathStr; connection.Open(); dataReader = new OleDbCommand("select * from TUser where UEnabled=1 order by UID asc", connection).ExecuteReader(); while (dataReader.Read()) { string tempStr = dataReader["UEID"].ToString(); this.userStrArray[iUserCount] = KLineTestProcessor.DecodeDisposeFunc(tempStr); this.nameStrArray[iUserCount] = dataReader["UNAME"].ToString(); iUserCount++; if (iUserCount >= FormUserManage.MAX_USER_NUM) { break; } } dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception ex) { if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } KLineTestProcessor.ExceptionRecordFunc(ex.StackTrace); goto IL_19E; } if (iUserCount > 0) { this.dataGridView1.AllowUserToAddRows = true; int num; for (int i = 0; i < iUserCount; i = num) { this.dataGridView1.Rows.Add(1); num = i + 1; this.dataGridView1.Rows[i].Cells[0].Value = System.Convert.ToString(num); this.dataGridView1.Rows[i].Cells[1].Value = this.userStrArray[i]; this.dataGridView1.Rows[i].Cells[2].Value = this.nameStrArray[i]; } this.dataGridView1.AllowUserToAddRows = false; } IL_19E :; } catch (System.Exception ex2) { this.dataGridView1.AllowUserToAddRows = false; KLineTestProcessor.ExceptionRecordFunc(ex2.StackTrace); } }
public void RefreshDataGridView() { OleDbConnection connection = null; OleDbDataReader dataReader = null; try { this.userIDStrList.Clear(); this.dataGridView1.Rows.Clear(); this.btnDelRecord.Visible = false; int inum = 0; try { connection = new OleDbConnection(); connection.ConnectionString = this.gLineTestProcessor.mddbPathStr; connection.Open(); dataReader = new OleDbCommand("select * from THistoryDataInfo ORDER BY ID DESC", connection).ExecuteReader(); this.dataGridView1.AllowUserToAddRows = true; while (dataReader.Read()) { this.dataGridView1.Rows.Add(1); int num = inum + 1; this.dataGridView1.Rows[inum].Cells[0].Value = System.Convert.ToString(num); this.strIDArray[inum] = dataReader["ID"].ToString(); this.dataGridView1.Rows[inum].Cells[1].Value = dataReader["ProjectName"].ToString(); this.dataGridView1.Rows[inum].Cells[3].Value = dataReader["batchMumberStr"].ToString(); this.dataGridView1.Rows[inum].Cells[2].Value = dataReader["bcCableName"].ToString(); this.dataGridView1.Rows[inum].Cells[4].Value = dataReader["TestTime"].ToString(); this.userIDStrList.Add(dataReader["Tester"].ToString()); this.dataGridView1.Rows[inum].Cells[5].Value = dataReader["Operator"].ToString(); this.dataGridView1.Rows[inum].Cells[6].Value = dataReader["TestResult"].ToString(); inum = num; if (inum >= 5000) { break; } } this.dataGridView1.AllowUserToAddRows = false; dataReader.Close(); dataReader = null; connection.Close(); connection = null; } catch (System.Exception arg_241_0) { this.dataGridView1.AllowUserToAddRows = false; KLineTestProcessor.ExceptionRecordFunc(arg_241_0.StackTrace); if (dataReader != null) { dataReader.Close(); dataReader = null; } if (connection != null) { connection.Close(); connection = null; } } } catch (System.Exception arg_265_0) { KLineTestProcessor.ExceptionRecordFunc(arg_265_0.StackTrace); } }