/// <summary> /// Підключення до Касового Апарату /// Number //Номер аппарата. //Тип: строка //Умолчание: "1" //Позволяет указать кассовый аппарат для работы в виде: //Логический номер (в виде "число") //Комбинация номер порта, сетевой номер кассы (в виде "порт;сетевойномер") //Комбинация номер порта, сетевой номер кассы, скорость обмена (в виде "порт;сетевойномер;скорость") //Если в момент установки значения свойства сеанс связи с аппаратом был установлен, он закрывается. //При использовании логического номера он должен совпадать с логическим номером, запрограммированным в кассе в параметрах связи с компьютером. //Если используется сетевой номер, то он должен совпадать с сетевым номером, запрограммированным в кассе в параметрах связи с компьютером. //Возможные значения скорости: 9600, 19200, 38400, 57600, 115200. Однако некоторые модели касс не поддерживают скорости 57600 и 115200. Указанная скорость должна совпадать со скоростью обмена с компьютером, запрограммированной в кассе. //Если касса подключена к компьютеру и в её настройках разрешён обмен с компьютером, то с помощью утилиты comtest.exe вы можете выяснить, на какой скорости работает касса, какой протокол она использует для обмена (упрощённый или полный) и какой имеет сетевой номер. Эти данные помогут вам правильно сформировать строку для свойства Number. Иконка comtest.exe устанавливается на рабочем столе Windows большинством инсталляторов, которые устанавливают драйверы EQL.. /// </summary> public void Connect(string Port, string LogicNumber, string UserId, string Password) { connection = new Connection(); string strCnn = "Provider=EQL OLE DB Provider;"; strCnn = strCnn + "Data Source='" + Port + ";" + LogicNumber + "'"; //strCnn = strCnn + "Data Source=’" + Port + ";" + LogicNumber + "’"; strCnn = strCnn + ";User Id=" + UserId + ";Password="******";"; strCnn = strCnn + "Extended Properties = \"Protocol=" + "L2Com.HcComSessionCreator\""; connection.Open(strCnn); srv = new Recordset(); //відкриття службової таблиці srv.Open("EQL_service", connection, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 512); //отримання процедурного інтерфейсу proc = srv.Fields[1].Value; fp = (IHcFReg)proc; fpext = (IHcFRegEx)proc; report = (IHcReport)proc; display = (IHcDisplay)proc; fiscPrinter = (IHcFiscPrnt)proc; fiscPrinterLastInfo = (IHmLastInfo)proc; fiscPrinterSound = (IHcSound)proc; this.OutTone(1000, 100); }
private double Cal_Plate_Wgt(string sMode, string sEndUseCd, string sStlgrd, double dThk, double dWid, double dLen) { double Plate_Wgt = 0; sQuery = "SELECT Gf_Cal_Plate_Wgt('" + sMode + "'"; sQuery = sQuery + " ,'" + sEndUseCd + "'"; sQuery = sQuery + " ,'" + sStlgrd + "'"; sQuery = sQuery + " ," + dThk; sQuery = sQuery + " ," + dWid; sQuery = sQuery + " ," + dLen; sQuery = sQuery + " ,0 )"; sQuery = sQuery + " FROM DUAL "; if (GeneralCommon.M_CN1.State == 0) { if (!GeneralCommon.GF_DbConnect()) { return(Plate_Wgt); } } ADODB.Recordset AdoRs = new ADODB.Recordset(); try { AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); if (!AdoRs.BOF && !AdoRs.EOF) { //RltValue = true; while (!AdoRs.EOF) { Plate_Wgt = Convert.ToDouble(AdoRs.Fields[0].Value); AdoRs.MoveNext(); } } //判断是不是需要关闭连接对象,有时候该方法是在查询过程中调用,关闭对象会导致框架查询报错 韩超 //GeneralCommon.M_CN1.Close(); AdoRs = null; return(Plate_Wgt); } catch (Exception ex) { // if (GeneralCommon.M_CN1.State != 0) GeneralCommon.M_CN1.Close(); AdoRs = null; return(0); } }
public static DataTable GetDataTable(string strFileName) { ADODB.Connection oConn = new ADODB.Connection(); oConn.Open("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\";", "", "", 0); string strQuery = "SELECT * FROM [" + System.IO.Path.GetFileName(strFileName) + "]"; ADODB.Recordset rs = new ADODB.Recordset(); System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(); DataTable dt = new DataTable(); rs.Open(strQuery, "Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\";", ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 1); adapter.Fill(dt, rs); return dt; }
public string Gf_GroupSet(string shift, string setDate) { if (GeneralCommon.M_CN1.State == 0) { if (!GeneralCommon.GF_DbConnect()) { return(""); } } string sQuery; string group = "0"; sQuery = "SELECT Gf_Groupset('C3'," + shift + ",SUBSTR('" + setDate + "',1,8)) FROM DUAL"; ADODB.Recordset AdoRs = new ADODB.Recordset(); try { AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); if (!AdoRs.BOF && !AdoRs.EOF) { //RltValue = true; while (!AdoRs.EOF) { if (AdoRs.Fields[0].Value.ToString() == "") { group = ""; } else { group = AdoRs.Fields[0].Value.ToString(); } AdoRs.MoveNext(); } } GeneralCommon.M_CN1.Close(); AdoRs = null; return(group); } catch (Exception ex) { if (GeneralCommon.M_CN1.State != 0) { GeneralCommon.M_CN1.Close(); } AdoRs = null; return(""); } }
public static DataTable GetDataTableFromSQLAdoDb(string sql, string connectionString) { var conn = new ADODB.Connection(); var recordSet = new ADODB.Recordset(); conn.Open(connectionString); recordSet.Open(sql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 0); var table = new DataTable(); var adapter = new OleDbDataAdapter(); adapter.Fill(table, recordSet); conn.Close(); return(table); }
public void InsertAdo() { var con = new Connection(); con.Open("Provider='sqloledb';Data Source='(local)';Initial Catalog='Proba';Integrated Security='SSPI';"); var rec = new Recordset(); rec.Open("SELECT s1, s2 FROM Tabl1", con, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 0); rec.MoveFirst(); rec.Fields["s1"].Value = "s"; rec.Fields["s2"].Value = "s"; rec.Update("s1", rec.Fields["s1"].Value); rec.Close(); con.Close(); }
public static bool ValidaUsuarioSenha(string UsuarioID, string SenhaAcesso, ADODB.Connection cn) { var RsUsuarios = new ADODB.Recordset(); try { RsUsuarios.Open(String.Format("SELECT Usuario FROM Usuarios WHERE Usuario='{0}' AND SenhaAcesso='{1}'", UsuarioID, SenhaAcesso), cn, CursorTypeEnum.adOpenForwardOnly, LockTypeEnum.adLockReadOnly); if (!RsUsuarios.EOF) { return(true); } } catch (Exception) { throw; } return(false); }
private ADODB.Recordset ReturnRecordset(string strSQL, ref ADODB.Connection objConnection) { ADODB.Recordset rsDBase = new ADODB.Recordset(); try { objConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\\\fedex01dwyer\\fedex;Extended Properties=dBASE IV;"); // objConnection.Execute("Select * from EPOSTAGE.dbf",rsDBase); rsDBase.Open(strSQL, objConnection, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1); } catch { } return(rsDBase); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="queryString"></param> /// <returns></returns> public List <T> QueryDataReturnListObject <T>(string queryString) where T : new() { if (con == null || con.State != 1) { this.OpenConnection(); } if (con.State != 1) { return(null); } //Get properties of T Type itemType = typeof(T); var properties = itemType.GetProperties(BindingFlags.Public | BindingFlags.Instance); //open recordset rs = new ADODB.Recordset(); rs.Open(queryString, con); //get data object[,] dataRows = (object[, ])rs.GetRows(); List <T> ts = new List <T>(); for (int i = 0; i < dataRows.GetLength(1); i++) { object[] p = Enumerable.Range(0, dataRows.GetLength(0)).Select(x => dataRows[x, i]).ToArray(); T t = new T(); for (int k = 0; k < properties.Length; k++) { properties[k].SetValue(t, Convert.ChangeType(p[k], properties[k].PropertyType)); } ts.Add(t); } //close recordset rs.Close(); rs = null; //return data return(ts); }
public DataTable GetData(string strSql) { DataTable dt = new DataTable(); dt.Locale = System.Globalization.CultureInfo.InvariantCulture; try { ADODB.Recordset rs = new ADODB.Recordset(); rs.Open(strSql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, -1); OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.Fill(dt, rs); adapter.Dispose(); rs.Close(); } catch (Exception ex) { //PublicLib.handleError("", this.GetType().Name, ex.Message + string.Format("({0})", strSql)); } return(dt); }
public void MegaInsertAdo() { var con = new Connection(); con.Open("Provider='sqloledb';Data Source='(local)';Initial Catalog='Proba';Integrated Security='SSPI';"); var rec = new Recordset(); rec.Open("SELECT s1,s2 FROM Tabl2", con, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 0); for (int i = 1; i <= 10000; ++i) { //string [] f={"s1","s2"}; int[] f = { 0, 1 }; string [] v = { "s1", "s2" }; rec.AddNew(f, v); //rec.Fields["s2"].Value = i.ToString(); //rec.Fields["s2"].Value = "new"; rec.Update(f, v); } rec.Close(); con.Close(); }
public DataTable GetData(string strSql, string strSqlData) { DataTable dt = new DataTable(); try { conn.BeginTrans(); ADODB.Command cmd = new ADODB.Command(); cmd.ActiveConnection = conn; cmd.CommandTimeout = 90; cmd.CommandType = ADODB.CommandTypeEnum.adCmdText; cmd.CommandText = strSql; object objRecordsAffected = Type.Missing; object objParams = Type.Missing; cmd.Execute(out objRecordsAffected, ref objParams, (int)ADODB.ExecuteOptionEnum.adExecuteNoRecords); ADODB.Recordset rs = new ADODB.Recordset(); rs.Open(strSqlData, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, -1); OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.Fill(dt, rs); adapter.Dispose(); rs.Close(); conn.CommitTrans(); } catch (Exception ex) { conn.RollbackTrans(); //PublicLib.handleError("", this.GetType().Name, ex.Message + string.Format("({0})", strSql)); } return(dt); }
/* * NOTE: ADO WORKAROUND: The adOpenForwardOnly and adLockReadOnly combination will always discard the recordset on a commit or abort, so it cannot be used. * NOTE: ADO WORKAROUND only required when the isolation level > read uncommitted because the browse Cursors are all opened on a separate Cursor connection which runs its own transaction. * NOTE: ADO WORKAROUND not required at all because the only cursors that span transactions are browse Cursors */ protected override SQLCursor InternalOpen(SQLCursorType cursorType, SQLIsolationLevel isolationLevel) { PrepareCommand(isolationLevel); SetParameters(); ADODB.Recordset recordset = new ADODB.Recordset(); recordset.Source = _command; recordset.CacheSize = 20; //LRecordset.Properties["Preserve on Commit"].Value = true; //LRecordset.Properties["Preserve on Abort"].Value = true; recordset.Open ( Missing.Value, Missing.Value, ( (cursorType == SQLCursorType.Static) ? ADODB.CursorTypeEnum.adOpenStatic : ( (LockType == SQLLockType.ReadOnly) ? ADODB.CursorTypeEnum.adOpenForwardOnly : ADODB.CursorTypeEnum.adOpenDynamic ) ), (LockType == SQLLockType.Optimistic) ? ADODB.LockTypeEnum.adLockOptimistic : ( (LockType == SQLLockType.Pessimistic) ? ADODB.LockTypeEnum.adLockPessimistic : ADODB.LockTypeEnum.adLockReadOnly ), CommandType == SQLCommandType.Table ? (int)CommandTypeEnum.adCmdTableDirect : -1 ); SQLCursor cursor = new ADOCursor(this, recordset); GetParameters(); return(cursor); }
public static ImpostoRetidoBO Impostos(float Valordafatura, Connection cn) { var RsTabelaTaxas = new ADODB.Recordset(); var Chamada = new ImpostoRetidoBO(); try { //Pega as taxas cadastradas da tabela "TabelaTaxas" RsTabelaTaxas.Open(string.Format("SELECT * FROM TabelaTaxas"), cn, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockReadOnly); if (!RsTabelaTaxas.EOF) { //Faz algumas verificações no valor da Fatura, faz o arredondamento para duas casas Decimais após a virgula e preenche o Objeto com os Totais. if (Valordafatura * (double)RsTabelaTaxas.Fields["TaxaIR_Retido"].Value > 10) { Chamada.IR_Retido = Math.Round((Valordafatura * (double)RsTabelaTaxas.Fields["TaxaIR_Retido"].Value), 2); } if (Valordafatura > 5000) { Chamada.PIS_Retido = Math.Round((Valordafatura * (double)RsTabelaTaxas.Fields["TaxaPIS_Retido"].Value), 2); } Chamada.Cofins_Retido = Math.Round((Valordafatura * (double)RsTabelaTaxas.Fields["TaxaCOFINS_Retido"].Value), 2); Chamada.CSLL_Retido = Math.Round((Valordafatura * (double)RsTabelaTaxas.Fields["TaxaCSLL_Retido"].Value), 2); } else { throw new Exception("Cadastre as Taxas dos impostos"); } RsTabelaTaxas.Close(); return(Chamada); }catch (Exception) { throw; } }
public static ADODB.Recordset ConvertToRecordset(DataTable dt) { ADODB.Recordset rs = new ADODB.Recordset(); rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient; ADODB.Fields RsFld = rs.Fields; System.Data.DataColumnCollection DtCols = dt.Columns; foreach (DataColumn DtCol in DtCols) { RsFld.Append(DtCol.ColumnName , CAdo.ConvertDotNetTypeToAdoType(DtCol.DataType) , DtCol.MaxLength , DtCol.AllowDBNull ? ADODB.FieldAttributeEnum.adFldIsNullable : ADODB.FieldAttributeEnum.adFldUnspecified , null); } rs.Open(System.Reflection.Missing.Value , System.Reflection.Missing.Value , ADODB.CursorTypeEnum.adOpenStatic , ADODB.LockTypeEnum.adLockOptimistic, 0); foreach (DataRow dr in dt.Rows) { rs.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value); for (int cl = 0; cl < DtCols.Count; cl++) { RsFld[cl].Value = dr[cl]; } } return(rs); }
private void save_form() { try { //ADOconn.BeginTrans(); ADODB.Recordset cus = new ADODB.Recordset(); //ADOconn.BeginTrans(); if (cmbgrp.Text == "") { MessageBox.Show("Invalid User Group", "Invalid Entry"); return; } dgv1.EndEdit(); ADODB.Connection ADOconn = new ADODB.Connection(); ADOconn.Open("Provider=SQLOLEDB;Initial Catalog= " + decoder.InitialCatalog + ";Data Source=" + decoder.DataSource + ";", decoder.UserID, decoder.Password, 0); for (int i = 1; i < dgv1.RowCount; i++) { if (dgv1["id", i].Value == null) { continue; } cus = new ADODB.Recordset(); if (!Convert.ToBoolean(dgv1["select", i].Value)) { sql = "delete FROM Menu_Xpress where id=" + dgv1["id", i].Value; object a; ADOconn.Execute(sql, out a); continue; } else { sql = "SELECT * FROM Menu_Xpress where id=" + dgv1["id", i].Value; cus.Open(sql, ADOconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1); if (cus.RecordCount == 0) { cus.AddNew(); } cus.Fields["GROUP_NAME"].Value = cmbgrp.Text; cus.Fields["id"].Value = Convert.ToInt16(dgv1["id", i].Value); cus.Fields["Menu_code"].Value = dgv1["menucode", i].Value; cus.Fields["Menu_Name"].Value = dgv1["menuname", i].Value; cus.Update(); } } string grp = cmbgrp.Text; sql = "SELECT distinct group_name FROM UserPriv "; SqlDataAdapter adagrp = new SqlDataAdapter(sql, Conn); ///ada.TableMappings.Add("Table", "Leaders"); DataSet grpds = new DataSet(); adagrp.Fill(grpds, "UserPriv"); cmbgrp.DisplayMember = "group_name"; cmbgrp.DataSource = grpds.Tables[0]; cmbgrp.Text = grp; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//日期格式 public string Gf_DTSet(string DTCheck, string DTFlag) { if (DTCheck == "D") { DTCheck = "D"; } else { DTCheck = "S"; } DTFlag = "C"; string sQuery = ""; int sQuery_Len = 0; string time = ""; switch (DTCheck) { case "S": sQuery = "SELECT TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') FROM DUAL"; sQuery_Len = 14; break; case "I": sQuery = "SELECT TO_CHAR(SYSDATE,'YYYYMMDDHH24MI') FROM DUAL"; sQuery_Len = 12; break; case "H": sQuery = "SELECT TO_CHAR(SYSDATE,'YYYYMMDDHH24') FROM DUAL"; sQuery_Len = 10; break; case "D": sQuery = "SELECT TO_CHAR(SYSDATE,'YYYYMMDD') FROM DUAL"; sQuery_Len = 8; break; case "T": sQuery = "SELECT TO_CHAR(SYSDATE,'HH24MISS') FROM DUAL"; sQuery_Len = 6; break; case "M": sQuery = "SELECT TO_CHAR(SYSDATE,'YYYYMM') FROM DUAL"; sQuery_Len = 6; break; case "Y": sQuery = "SELECT TO_CHAR(SYSDATE,'YYYY') FROM DUAL"; sQuery_Len = 4; break; } if (DTFlag == "C") { if (DTCheck == "T") { return(DateTime.Now.ToString("HHmmss")); } return((DateTime.Now.ToString("yyyyMMddHHmmss")).Substring(0, sQuery_Len)); } if (GeneralCommon.M_CN1.State == 0) { if (!GeneralCommon.GF_DbConnect()) { return("00000000000000"); } } ADODB.Recordset AdoRs = new ADODB.Recordset(); try { AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); if (!AdoRs.BOF && !AdoRs.EOF) { //RltValue = true; while (!AdoRs.EOF) { if (AdoRs.Fields[0].Value.ToString() == "") { time = ""; } else { time = AdoRs.Fields[0].Value.ToString(); } AdoRs.MoveNext(); } } else { time = "00000000000000"; } GeneralCommon.M_CN1.Close(); AdoRs = null; return(time); } catch (Exception ex) { if (GeneralCommon.M_CN1.State != 0) { GeneralCommon.M_CN1.Close(); } AdoRs = null; return("00000000000000"); } }
public string Gf_ShiftSet3(string WKDATE) { if (GeneralCommon.M_CN1.State == 0) { if (!GeneralCommon.GF_DbConnect()) { return(""); } } string Shift_HH = "0"; string sQuery; sQuery = "SELECT TO_CHAR(SYSDATE,'HH24MI') FROM DUAL"; ADODB.Recordset AdoRs = new ADODB.Recordset(); try { if (WKDATE != "") { return(WKDATE); } AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); if (!AdoRs.BOF && !AdoRs.EOF) { //RltValue = true; while (!AdoRs.EOF) { if (AdoRs.Fields[0].Value.ToString() == "") { Shift_HH = ""; } else { Shift_HH = AdoRs.Fields[0].Value.ToString(); } AdoRs.MoveNext(); } } GeneralCommon.M_CN1.Close(); AdoRs = null; if (Convert.ToInt32(Shift_HH) < 800) { return("1"); } else if (Convert.ToInt32(Shift_HH) < 1600) { return("2"); } else { return("3"); } } catch (Exception ex) { if (GeneralCommon.M_CN1.State != 0) { GeneralCommon.M_CN1.Close(); } AdoRs = null; return("0"); } }
public void SearchCommentsData() { string sql; string sDate; string sQuery; int i; if (txt_DATE.RawDate.Length != 8) { sDate = DateTime.Now.AddDays(-1).ToString("yyyyMMdd"); } else { sDate = txt_DATE.RawDate; } sql = " SELECT YEAR_PLAN_WGT , YEAR_FIN_WGT , YEAR_PROD_PROG , "; sql = sql + " YEAR_PROG , YEAR_AVE_NEED , YEAR_LEFT_DAY , "; sql = sql + " NULL , "; sql = sql + " MONTH_PLAN_WGT , MONTH_FIN_WGT , MONTH_PROD_PROG , "; sql = sql + " MONTH_PROG , MONTH_AVE_NEED , MONTH_LEFT_DAY , "; sql = sql + " NULL "; sql = sql + " FROM gp_zb_mon "; sql = sql + " WHERE PLT = 'C3' "; sql = sql + " AND PROD_DATE = '" + sDate + "' "; sQuery = sql; if (GeneralCommon.M_CN1.State == 0) { if (!GeneralCommon.GF_DbConnect()) { return; } } ADODB.Recordset AdoRs = new ADODB.Recordset(); try { AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); while (!AdoRs.EOF) { for (int j = 6; j <= 7; j++) { for (i = 2; i <= 14; i += 2) { if (j == 6) { if (!(AdoRs.Fields[i / 2 - 1].Value == null || convertD(AdoRs.Fields[i / 2 - 1].Value.ToString()) == 0)) { ss3.ActiveSheet.Cells[j - 1, i - 1].Text = AdoRs.Fields[i / 2 - 1].Value.ToString(); } } else { if (!(AdoRs.Fields[i / 2 + 6].Value == null | convertD(AdoRs.Fields[i / 2 + 6].Value.ToString()) == 0)) { ss3.ActiveSheet.Cells[j - 1, i - 1].Text = AdoRs.Fields[i / 2 + 6].Value.ToString(); } } } } AdoRs.MoveNext(); } AdoRs.Close(); AdoRs = null; //判断是不是需要关闭连接对象,有时候该方法是在查询过程中调用,关闭对象会导致框架查询报错 韩超 GeneralCommon.M_CN1.Close(); } catch (Exception ex) { // if (GeneralCommon.M_CN1.State != 0) GeneralCommon.M_CN1.Close(); AdoRs.Close(); AdoRs = null; } }
public bool Gf_Sp_Display3(ADODB.Connection Conn, FarPoint.Win.Spread.FpSpread oSpread, string sQuery, Collection lColumn, bool MsgChk) { bool returnValue = false; int iCount; int iRowCount; int iColcount; object[,] ArrayRecords; ADODB.Recordset AdoRs; if (Conn.State == 0) { if (GeneralCommon.GF_DbConnect() == false) { return(false); } } AdoRs = new ADODB.Recordset(); try { returnValue = true; //if (oSpread.ActiveSheet.RowCount > 0) //{ // // // //'Hux,修改。 // //'解决:Spread有两条数据时,点击列头排序后,再点击Spread插入,Spread行清除时报错。 // oSpread.ActiveSheet.AutoSortColumn(0); // oSpread.ActiveSheet.RowCount = 0; //} //FarPoint.Win.Spread.FpSpread with_1 = oSpread; iCount = 0; Cursor.Current = Cursors.WaitCursor; /////////20130606begin解决保存失败后,第一次查询提示算数运算符溢出的问题 AdoRs.CursorLocation = ADODB.CursorLocationEnum.adUseClient; AdoRs.CursorType = ADODB.CursorTypeEnum.adOpenStatic; //AdoRs.CursorType = //AdoRs.CursorLocation = ADODB.CursorLocationEnum.adUseServer; //AdoRs.Open(sQuery, Conn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, 1); AdoRs.Open(sQuery, Conn); /////////20130606end if (AdoRs.BOF || AdoRs.EOF) { if (MsgChk) { GeneralCommon.Gp_MsgBoxDisplay("无法找到该资料..!!!", "I", ""); } returnValue = false; AdoRs.Close(); AdoRs = null; Cursor.Current = Cursors.Default; return(returnValue); } int RsRowCount = AdoRs.RecordCount; int RsColCount = AdoRs.Fields.Count; ArrayRecords = new object[RsRowCount, RsColCount]; int i = 0; while (!AdoRs.EOF) { for (int j = 0; j < AdoRs.Fields.Count; j++) { ArrayRecords[i, j] = AdoRs.Fields[j].Value; } i++; AdoRs.MoveNext(); } AdoRs.Close(); AdoRs = null; //此处进行表单数据录入 int ROW = 0; int Col = 0; if (ArrayRecords.GetLength(0) != 0) { for (iRowCount = 0; iRowCount < ArrayRecords.GetLength(0); iRowCount++) { for (iColcount = 1; iColcount <= 7; iColcount++) { if (substr(ArrayRecords[iRowCount, 0].ToString(), 1, 1) == "0") { Col = 2 * iColcount - 2; } else if (substr(ArrayRecords[iRowCount, 0].ToString(), 1, 1) == "1") { Col = 2 * iColcount - 1; } if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "A") { ROW = 0; } else if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "B") { ROW = 1; } else if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "C") { ROW = 2; } else if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "D") { ROW = 3; } else if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "T") { ROW = 4; } if (ArrayRecords[iRowCount, iColcount].ToString() == "" || ArrayRecords[iRowCount, iColcount].ToString() == "0") { oSpread.ActiveSheet.Cells[ROW, Col].Text = ""; } else { oSpread.ActiveSheet.Cells[ROW, Col].Text = ArrayRecords[iRowCount, iColcount].ToString(); } } } } Cursor.Current = Cursors.Default; ArrayRecords = null; } catch (Exception ex) { AdoRs = null; returnValue = false; GeneralCommon.Gp_MsgBoxDisplay((string)("Gf_Sp_Display Error : " + ex.Message), "", ""); Cursor.Current = Cursors.Default; if (Information.Err().Number == 438 || Information.Err().Number == -2147467259) { Conn.Close(); } } return(returnValue); }
private void enablemenu() { ADODB.Connection ADOconn = new ADODB.Connection(); ADOconn.Open("Provider=SQLOLEDB;Initial Catalog= " + decoder.InitialCatalog + ";Data Source=" + decoder.DataSource + ";", decoder.UserID, decoder.Password, 0); ADODB.Recordset cus = new ADODB.Recordset(); cus = new ADODB.Recordset(); //string sql = "SELECT menu_code FROM menu_master where id in (select form_id from userpriv where dsp=1 and group_name = (select group_name from userinfo where userid='" + Gvar.Userid+ "'))"; string sql = "SELECT m.menu_code,p.* FROM menu_master as M inner join userpriv as p on m.id=p.form_id where p.dsp=1 and p.group_name = (select group_name from userinfo where userid='" + Gvar.Userid + "')"; cus.Open(sql, ADOconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1); while (!cus.EOF) { string mnu = cus.Fields[0].Value.ToString(); string prv; Gvar.Priv menu_item = new Gvar.Priv(); if (string.IsNullOrEmpty(cus.Fields["ins"].Value.ToString())) { cus.Fields["ins"].Value = 0; } if (string.IsNullOrEmpty(cus.Fields["upd"].Value.ToString())) { cus.Fields["upd"].Value = 0; } if (string.IsNullOrEmpty(cus.Fields["del"].Value.ToString())) { cus.Fields["del"].Value = 0; } if ((bool)cus.Fields["ins"].Value) { prv = "1"; } else { prv = "0"; } if ((bool)cus.Fields["upd"].Value) { prv = prv + "1"; } else { prv = prv + "0"; } if ((bool)cus.Fields["del"].Value) { prv = prv + "1"; } else { prv = prv + "0"; } lstmenu.Items.Add(mnu); lstpriv.Items.Add(prv); menu_item.Menu = mnu; menu_item.priv = prv; Gvar.User_Priv.Add(menu_item); cus.MoveNext(); ////foreach (ToolStripMenuItem toolSripItem in menuStrip.Items) ////{ //// if (toolSripItem.HasDropDownItems) //// { //// foreach (ToolStripItem toolSripItem1 in toolSripItem.DropDownItems) //// { //// if (toolSripItem1 is ToolStripSeparator) continue; //// if (toolSripItem1 is ToolStripMenuItem) //// // insert_menu(menuItem.Text, toolSripItem.Name, 1, toolSripItem.Text, "", 'A'); //// if (toolSripItem1.Name==mnu) //// toolSripItem.Visible = true; //// { //call recursively //// // disableMenu((ToolStripMenuItem)toolSripItem); //// } //// } //// } ////} } ADOconn.Close(); //cus.Close(); }
static ADODB.Recordset ConvertToRecordset(DataTable inTable) { ADODB.Recordset result = new ADODB.Recordset(); result.CursorLocation = ADODB.CursorLocationEnum.adUseClient; ADODB.Fields resultFields = result.Fields; System.Data.DataColumnCollection inColumns = inTable.Columns; foreach (DataColumn inColumn in inColumns) { resultFields.Append(inColumn.ColumnName , TranslateType(inColumn.DataType) , inColumn.MaxLength , inColumn.AllowDBNull ? ADODB.FieldAttributeEnum.adFldIsNullable : ADODB.FieldAttributeEnum.adFldUnspecified , null); } result.Open(System.Reflection.Missing.Value , System.Reflection.Missing.Value , ADODB.CursorTypeEnum.adOpenStatic , ADODB.LockTypeEnum.adLockOptimistic, 0); foreach (DataRow dr in inTable.Rows) { result.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value); for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++) { resultFields[columnIndex].Value = dr[columnIndex]; } } return result; }
private void CHEMISTRY_DISP() { if (GeneralCommon.M_CN1.State == 0) { if (!GeneralCommon.GF_DbConnect()) { return; } } ADODB.Recordset AdoRs = new ADODB.Recordset(); string sQuery; sQuery = "SELECT ELEMENT_CD, ELEMENT_VAL FROM NISCO.FP_CHEMISTRY WHERE HEAT_NO = '" + txt_new_slab_no.Text + "' ORDER BY SEQ_NO "; try { AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); //bool RltValue = false; if (!AdoRs.BOF && !AdoRs.EOF) { //RltValue = true; while (!AdoRs.EOF) { switch (AdoRs.Fields[0].Value.ToString()) { case "C": txt_c.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Mn": txt_mn.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "P": txt_p.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "S": txt_s.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Si": txt_si.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Ceq": txt_ceq.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Nb": txt_nb.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Cu": txt_cu.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "V": txt_v.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Cr": txt_cr.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Ni": txt_ni.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Alt": txt_alt.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Mo": txt_mo.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Ti": txt_ti.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "W": txt_w.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "B": txt_b.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Re": txt_re.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Pb": txt_pb.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Ca": txt_ca.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "N": txt_n.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "H": txt_h.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "O": txt_o.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Als": txt_als.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Zr": txt_zr.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Mg": txt_mg.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Sn": txt_sn.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "As": txt_as.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Co": txt_co.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Te": txt_te.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Bi": txt_bi.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Sb": txt_sb.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Zn": txt_zn.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Se": txt_se.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Ta": txt_ta.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; case "Pcm": txt_pcm.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value); break; } AdoRs.MoveNext(); } } sQuery = " SELECT STEEL_NET_WGT "; sQuery = sQuery + " FROM NISCO.FP_CHARGE "; sQuery = sQuery + " WHERE HEAT_NO LIKE '" + txt_new_slab_no.Text.Trim() + "%'"; txt_wgt.NumValue = 0; txt_wgt.NumValue = GeneralCommon.Gf_FloatFind(GeneralCommon.M_CN1, sQuery); txt_slabcnt.Text = ss1.ActiveSheet.RowCount.ToString(); } catch (Exception ex) { if (GeneralCommon.M_CN1.State != 0) { GeneralCommon.M_CN1.Close(); } AdoRs = null; //RltValue = false; GeneralCommon.Gp_MsgBoxDisplay("数据读取失败" + ex.Message, "", ""); } }
public void Get_OldSms_Info() { string tmHeatNo; string sQuery; sQuery = " SELECT HEAT_NO "; sQuery = sQuery + " FROM NISCO.FP_CHARGE "; sQuery = sQuery + " WHERE HEAT_NO LIKE '" + txt_new_slab_no.Text.Trim() + "%'"; tmHeatNo = GeneralCommon.Gf_FloatFind(GeneralCommon.M_CN1, sQuery).ToString(); if (tmHeatNo.Trim() != "0") { return; } sQuery = "SELECT * FROM NISCO.GP_OLDSMSCHEMIF WHERE NEW_HEAT_NO = '" + txt_new_slab_no.Text.Trim() + "'"; ADODB.Recordset AdoRs = new ADODB.Recordset(); //bool RltValue = false; try { AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); //bool RltValue = false; if (!AdoRs.BOF && !AdoRs.EOF) { //RltValue = true; while (!AdoRs.EOF) { txt_act_stlgrd_dec.Text = AdoRs.Fields[5].Value.ToString(); txt_thk.NumValue = Convert.ToDouble(AdoRs.Fields[6].Value); txt_wid.NumValue = Convert.ToDouble(AdoRs.Fields[7].Value); txt_len.NumValue = Convert.ToDouble(AdoRs.Fields[8].Value); txt_wgt.NumValue = Convert.ToDouble(AdoRs.Fields[9].Value); txt_slabcnt.NumValue = Convert.ToDouble(AdoRs.Fields[10].Value); txt_car_no.Text = AdoRs.Fields[13].Value == "" ? "0" : AdoRs.Fields[13].Value.ToString(); txt_c.NumValue = AdoRs.Fields[14].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[14].Value); txt_si.NumValue = AdoRs.Fields[15].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[15].Value); txt_mn.NumValue = AdoRs.Fields[16].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[16].Value); txt_p.NumValue = AdoRs.Fields[17].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[17].Value); txt_s.NumValue = AdoRs.Fields[18].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[18].Value); txt_cu.NumValue = AdoRs.Fields[19].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[19].Value); txt_alt.NumValue = AdoRs.Fields[20].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[20].Value); txt_als.NumValue = AdoRs.Fields[21].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[21].Value); txt_b.NumValue = AdoRs.Fields[22].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[22].Value); txt_ni.NumValue = AdoRs.Fields[23].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[23].Value); txt_cr.NumValue = AdoRs.Fields[24].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[24].Value); txt_mo.NumValue = AdoRs.Fields[25].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[25].Value); txt_w.NumValue = AdoRs.Fields[26].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[26].Value); txt_ti.NumValue = AdoRs.Fields[27].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[27].Value); txt_v.NumValue = AdoRs.Fields[28].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[28].Value); txt_zr.NumValue = AdoRs.Fields[29].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[29].Value); txt_pb.NumValue = AdoRs.Fields[30].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[30].Value); txt_sn.NumValue = AdoRs.Fields[31].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[31].Value); txt_as.NumValue = AdoRs.Fields[32].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[32].Value); txt_ca.NumValue = AdoRs.Fields[33].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[33].Value); txt_co.NumValue = AdoRs.Fields[34].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[34].Value); txt_mg.NumValue = AdoRs.Fields[35].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[35].Value); txt_te.NumValue = AdoRs.Fields[36].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[36].Value); txt_bi.NumValue = AdoRs.Fields[37].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[37].Value); txt_sb.NumValue = AdoRs.Fields[38].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[38].Value); txt_zn.NumValue = AdoRs.Fields[39].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[39].Value); txt_nb.NumValue = AdoRs.Fields[40].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[40].Value); txt_ceq.NumValue = AdoRs.Fields[41].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[41].Value); txt_re.NumValue = AdoRs.Fields[42].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[42].Value); txt_ta.NumValue = AdoRs.Fields[43].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[43].Value); txt_n.NumValue = AdoRs.Fields[44].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[44].Value); txt_h.NumValue = AdoRs.Fields[45].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[45].Value); txt_o.NumValue = AdoRs.Fields[46].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[46].Value); txt_se.NumValue = AdoRs.Fields[47].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[47].Value); txt_pcm.NumValue = AdoRs.Fields[48].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[48].Value); AdoRs.MoveNext(); } comm_slab_test(); } } catch (Exception ex) { if (GeneralCommon.M_CN1.State != 0) { GeneralCommon.M_CN1.Close(); } AdoRs = null; //RltValue = false; GeneralCommon.Gp_MsgBoxDisplay("数据读取失败" + ex.Message, "", ""); } }
private void frmMain_Load(object sender, EventArgs e) { ADODB.Recordset rsMail = null; ADODB.Recordset rsContract = null; ADODB.Recordset rsMailSettings = null; ADODB.Connection connDb = null; bool solde = false; string destinataire = ""; bool contratEchu = false; string CONN_DB = ""; // if (args==null) // Application.Exit(); if (args == null) { CONN_DB = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\lementor\StudiosUnis\LeMentorÉlèveTables.mdb;"; } else { CONN_DB = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + args; } try { connDb = new ADODB.Connection(); rsMail = new ADODB.Recordset(); rsMailSettings = new ADODB.Recordset(); rsContract = new ADODB.Recordset(); System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); client.UseDefaultCredentials = false; client.EnableSsl = true; client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; System.Net.Mail.MailMessage msg = null; connDb.Open(CONN_DB); rsMail.Open("select * from emailmessage", connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic); rsMailSettings.Open("select * from cie", connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic); if (!rsMail.EOF) { rsMail.MoveFirst(); } if (!rsMailSettings.EOF) { rsMailSettings.MoveFirst(); client.Port = rsMailSettings.Fields["PortSmtp"].Value; // rsMailSettings.Fields["PortSmtp"].Value; client.Host = rsMailSettings.Fields["ServerSmtp"].Value.ToString(); client.Credentials = new System.Net.NetworkCredential(rsMailSettings.Fields["E-mail"].Value.ToString(), rsMailSettings.Fields["MotdePasseE-mail"].Value); } while (!rsMail.EOF) { solde = rsMail.Fields["solde"].Value; contratEchu = rsMail.Fields["contratechu"].Value; //destinataire = rsMail.Fields["destinataire"].Value.ToString(); // destinataire = "dquirion78@@gmail.com"; msg = new System.Net.Mail.MailMessage(); msg.From = new MailAddress(rsMailSettings.Fields["e-mail"].Value.ToString()); msg.Subject = rsMail.Fields["sujet"].Value.ToString(); msg.Body = rsMail.Fields["texte"].Value.ToString(); msg.IsBodyHtml = false; if (string.IsNullOrEmpty(rsMail.Fields["destinataire"].Value.ToString())) { throw new Exception("Destinataire Manquant!"); } else { msg.To.Add(destinataire); } if (!string.IsNullOrEmpty(rsMail.Fields["cc"].Value.ToString())) { msg.CC.Add(rsMail.Fields["cc"].Value.ToString()); } if (!string.IsNullOrEmpty(rsMail.Fields["cci"].Value.ToString())) { msg.Bcc.Add(rsMail.Fields["cci"].Value.ToString()); } if (rsMail.Fields["fichier"].Value.ToString().Length > 3) { System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment(rsMail.Fields["fichier"].Value.ToString()); msg.Attachments.Add(attachment); } client.Send(msg); // if (rsMail.Fields["fichier"].Value.ToString().Length > 3) // File.Delete(rsMail.Fields["fichier"].Value.ToString()); msg = null; rsContract.Open("select * from GA_Eleve_Cours where [noidcours] =" + rsMail.Fields["noidcours"].Value.ToString(), connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic); if (!rsContract.EOF) { rsContract.MoveFirst(); if (rsMail.Fields["ContratEchu"].Value == true) { rsContract.Fields["NotficationContratEchu"].Value = true; } if (rsMail.Fields["solde"].Value == true) { rsContract.Fields["DernDateNotificationsolde"].Value = rsMail.Fields["DernDateNotificationsolde"].Value; rsContract.Fields["NbreNotificationsolde"].Value = rsMail.Fields["NbreNotificationsolde"].Value; } rsContract.Update(); } rsContract.Close(); rsMail.Delete(); rsMail.MoveNext(); if (!rsMail.EOF) { System.Threading.Thread.Sleep(5000);//limite les chances d'être taggé comme spam par le fournisseur d'envoi en envoyant pas trop vite les emails. } //msg.CC.Add(Email); } /* * if (Attachments.Count() > 0) * { * foreach (var item in Attachments) * { * if (!string.IsNullOrEmpty(item)) * { * System.Net.Mail.Attachment attachment; * attachment = new System.Net.Mail.Attachment(item); * msg.Attachments.Add(attachment); * } * } * } */ if (((solde == false && contratEchu == false) || (rsMail.RecordCount == 1)) && destinataire.Length > 0) { MessageBox.Show("Message Envoyé : à " + destinataire); Application.Exit(); } else { // MessageBox.Show("Message Envoyé : à " + rsMail.RecordCount.ToString() + " clients."); } } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show("ÉCHEC d'envoi de courier !"); Application.Exit(); } try { if (rsMail.State != 0) { rsMail.Close(); } rsMail = null; if (rsMailSettings.State != 0) { rsMailSettings.Close(); } rsMailSettings = null; if (rsContract.State != 0) { rsContract.Close(); } rsContract = null; Application.Exit(); } catch { Application.Exit(); } }
public string Gf_CarInfFind(string Car_no, string Car_knd, string nameType) { if (GeneralCommon.M_CN1.State == 0) { if (!GeneralCommon.GF_DbConnect()) { return("FAIL"); } } string sQuery; string Gf_CarInfFind = ""; switch (nameType) { case "1": //最大装载量 sQuery = "SELECT H.CAR_WGT_MAX FROM HP_CAR_IMF H WHERE H.CAR_NO = '" + Car_no + "' AND H.CAR_KND = '" + Car_knd + "' "; break; case "2": //装载量(适量) sQuery = "SELECT H.CAR_WGT_AVE FROM HP_CAR_IMF H WHERE H.CAR_NO = '" + Car_no + "' AND H.CAR_KND = '" + Car_knd + "' "; break; default: //可装车长度 sQuery = "SELECT H.CAR_LEN FROM HP_CAR_IMF H WHERE H.CAR_NO = '" + Car_no + "' AND H.CAR_KND = '" + Car_knd + "' "; break; } ADODB.Recordset AdoRs = new ADODB.Recordset(); try { AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); if (!AdoRs.BOF && !AdoRs.EOF) { //RltValue = true; while (!AdoRs.EOF) { if (AdoRs.Fields[0].Value.ToString() == "") { Gf_CarInfFind = ""; } else { Gf_CarInfFind = AdoRs.Fields[0].Value.ToString(); } AdoRs.MoveNext(); } } GeneralCommon.M_CN1.Close(); AdoRs = null; return(Gf_CarInfFind); } catch (Exception ex) { if (GeneralCommon.M_CN1.State != 0) { GeneralCommon.M_CN1.Close(); } AdoRs = null; return(""); } }