using System; using System.Data; using System.Data.OleDb; using System.Text; using System.IO; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.UI; using System.Web; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Web.SessionState;
namespace lpt_sys { /// <summary> /// ClassLpt 的摘要说明。 /// </summary> public class ClassLpt { public ClassLpt() { // // TOD 在此处添加构造函数逻辑 // }
String OleConnstr="Provider=MSDAORA.1;Password=lpt;User ID=lpt;Data Source=winsfc"; // String OleConnstr="Provider=MSDAORA.1;Password=lpt;User ID=lpt;Data Source=sfcdb"; public string TxtRet = "<br><div align=right><a href='javascript:history.go(-1)'>[返回]</a></div>"; public string msg1 = "目前正处于测试阶段,有问题请." + "<br><font color='51485f'>请联络:李兆华 分机2266</font>" + " 谢谢合作!<br>[错误信息]<font color = '336633'>";
public Boolean Execute_Reasult(string sql) { OleDbConnection MyConn = new OleDbConnection(OleConnstr); MyConn.Open(); DataSet MyDataset = new DataSet(); OleDbCommand MyCommand = new OleDbCommand(sql, MyConn); OleDbDataAdapter myAdapter = new OleDbDataAdapter(MyCommand); myAdapter.Fill(MyDataset,"one"); DataTable mytable=MyDataset.Tables["one"]; if (mytable.Rows.Count>0) { return true; } else { return false; } }
public OleDbDataReader Reader(string sql) { OleDbConnection MyConn = new OleDbConnection(OleConnstr); try { MyConn.Open(); OleDbCommand MyCmd= new OleDbCommand(sql,MyConn); OleDbDataReader myReader=MyCmd.ExecuteReader(); while (myReader.Read()) { Console.Write(myReader.GetInt32(0) + ", " + myReader.GetString(1)); } // always call Close when done reading. myReader.Close(); // Close the connection when done with it. MyConn.Close(); return myReader; } catch { MyConn.Close(); } finally { MyConn.Close(); } return null; }
public DataSet Get_Ds(string sql) { OleDbConnection MyConn = new OleDbConnection(OleConnstr); MyConn.Open(); DataSet MyDataset = new DataSet(); OleDbCommand MyCommand = new OleDbCommand(sql, MyConn); OleDbDataAdapter myAdapter = new OleDbDataAdapter(MyCommand); myAdapter.Fill(MyDataset,"one"); return MyDataset; }
public DataSet Get_Ds(string sql,string tab) { OleDbConnection MyConn = new OleDbConnection(OleConnstr); MyConn.Open(); DataSet MyDataset = new DataSet(); OleDbCommand MyCommand = new OleDbCommand(sql, MyConn); OleDbDataAdapter myAdapter = new OleDbDataAdapter(MyCommand); myAdapter.Fill(MyDataset,tab); return MyDataset; }
public void Execute(string sql) { OleDbConnection myConnection = new OleDbConnection(OleConnstr); OleDbCommand myCommand = new OleDbCommand(sql, myConnection); myConnection.Open(); myCommand.ExecuteNonQuery(); myCommand.Dispose(); myConnection.Close(); }
public string Q(string Temp) {string t; if (IsLen0(Temp)) { return "''"; } else { t=Temp.Trim() + ""; return "'" + Temp.ToUpper() + "'"; } }
public Boolean IsLen0(object obj) { if(obj.ToString().Trim().Length==0) { return true; } else { return false; } }
public string D(string Tmp) { string t; if(IsLen0(Tmp)) { return "''"; } else { t=Tmp.Trim() + ""; return "#" + Tmp.ToUpper() + "#"; } }
public string Checked(Boolean val) { if (val==true) { return "Y"; } else { return "N"; } }
public void Check(System.Web.UI.WebControls.CheckBox obj,string val) { if (val.ToUpper()=="Y") { obj.Checked =true; } else { obj.Checked=false; } }
public void DrpSelect(System.Web.UI.WebControls.DropDownList obj,string val) { int i; for(i=0;i<=obj.Items.Count-1;i++) { //if(obj.Items[i].Value.Trim().ToUpper()==val.Trim().ToUpper()) //obj.Items[i].Selected=true; //else // obj.Items[i].Selected=false; obj.Items[i].Selected=((obj.Items[i].Text.Trim()).ToUpper() == (val.Trim()).ToUpper()); } }
public string CheckStrNull(object val) { if(val!=System.DBNull.Value) return val.ToString().Trim(); else return "";
}
public int CheckIntNull(string str) { if (str.Trim()=="") return 0; else return int.Parse(str.Trim()); }
public double CheckDouNull(object obj) { switch(obj.GetType().FullName) { case "System.DBNull" : return 0; case "System.Int16" : return (int)obj; case "System.Int32" : return (int)obj; case "System.Int64": return (int)obj; case "System.Decimal": return (double)((Decimal)obj); case "System.Double": return (Double)obj; case "System.String": return double.Parse((string)obj); default: return (double)obj; } }
public int CInt(object PValue ) { switch (PValue.GetType().FullName) { case "System.DBNull" : return 0; case "System.Double" : return (int)PValue; case "System.Int32" : return (int)PValue; case "System.Decimal": return (int)((decimal)PValue); case "System.String" : return int.Parse((string)PValue); //字符串型转换为int,float,double,... default : return (int)PValue; } }
} }