static bool _continue;
static SerialPort _serialPort;
public static void Main(string[] args)
{
string name;
string message;
StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;
Thread readThread = new Thread(Read);
// Create a new SerialPort object with default settings.
_serialPort = new SerialPort();
// Allow the user to set the appropriate properties.
_serialPort.PortName = SetPortName(_serialPort.PortName);
_serialPort.BaudRate = SetPortBaudRate(_serialPort.BaudRate);
_serialPort.Parity = SetPortParity(_serialPort.Parity);
_serialPort.DataBits = SetPortDataBits(_serialPort.DataBits);
_serialPort.StopBits = SetPortStopBits(_serialPort.StopBits);
_serialPort.Handshake = SetPortHandshake(_serialPort.Handshake);
// Set the read/write timeouts
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;
_serialPort.Open();
_continue = true;
readThread.Start();
Console.Write("Name: ");
name = Console.ReadLine();
Console.WriteLine("Type QUIT to exit");
while (_continue)
{
message = Console.ReadLine();
if (stringComparer.Equals("quit", message))
{
_continue = false;
}
else
{
_serialPort.WriteLine(
String.Format("<{0}>: {1}", name, message));
}
}
readThread.Join();
_serialPort.Close();
}
public static void Read()
{
while (_continue)
{
try
{
string message = _serialPort.ReadLine();
Console.WriteLine(mesGetData.GetDataHelp getData = new GetData.GetDataHelp();
return (getData.getDataSetCities(Rows).Tables[0]);
}backgroundWorker1.RunWorkerAsync();
}DataTable dt;
toolStripStatusLabel1.Text = "Loading ... " + "Thanks for your patience";
dt = getDataTable(1000000);
e.Result = dt;
}class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入待加密的内容:");
Console.WriteLine();
string strSrc = Console.ReadLine().ToString();
Console.WriteLine();
Console.WriteLine("你输入的内容是:" + strSrc);
Console.WriteLine();
Console.WriteLine("MD5加密后编码:" + MD5_Hash(strSrc));
Console.WriteLine();
Console.WriteLine("SHA1加密后编码:" + SHA1_Hash(strSrc));
Console.WriteLine();
Console.ReadLine();
//Console.WriteLine("MD5加密后编码:" + UserMd5("16"));
//Console.WriteLine();
//Console.WriteLine("SHA1加密后编码:" + cncrypto(strSrc));
//Console.WriteLine();
//Console.WriteLine(Ge***5Str("8"));
}
//MD5
static public string MD5_Hash(string str_md5_in)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] bytes_md5_in = UTF8Encoding.Default.GetBytes(str_md5_in);
byte[] bytes_md5_out = md5.ComputeHash(bytes_md5_in);
string str_md5_out = BitConverter.ToString(bytes_md5_out);
str_md5_out = str_md5_out.Replace("-", "");
return str_md5_out;
}
//SHA1
static public string SHA1_Hash(string str_sha1_in)
{
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] bytes_sha1_in = UTF8Encoding.Default.GetBytes(str_sha1_in);
byte[] bytes_sha1_out = sha1.ComputeHash(bytes_sha1_in);
string str_sha1_out = BitConverter.ToString(bytes_sha1_out);
str_sha1_out = str_sha1_out.Replace("-", "");
return str_sha1_out;
}
//static public string cncrypto(strprivate void dataGridView1_MouseDown(object sender, MouseEventArgs e)
2{
3if (e.Button == MouseButtons.Right)
4{
5DataGridView.HitTestInfo info = dataGridView1.HitTest(e.X, e.Y);
67
if (info.RowIndex >= 0)
8{
9DataGridViewRow dr = (DataGridViewRow)
10dataGridView1.Rows[info.RowIndex];
11if (dr != null)
12dataGridView1.DoDragDrop(dr, DragDropEffects.Copy);
13}
14}
15}
16private void treeView1_DragEnter(object sender, DragEventArgs e)
18{
19e.Effect = DragDropEffects.Copy;
20}
21private void treeView1_DragDrop(object sender, DragEventArgs e)
23{
24if (e.Data.GetDataPresent(typeof(DataGridViewRow)))
25 {26
Point p = treeView1.PointToClient(new Point(e.X, e.Y));
27TreeViewHitTestInfo index = treeView1.HitTest(p);
28if (index.Node != null)
30{
31DataGridViewRow drv = (DataGridViewRow)e.Data.GetData(typeof(DataGridViewRow));
33index.Node.Text = "Drop: " + drv.Cells[0].ToString();
3435
}
36}
37}
if (e.KeyChar == '\r')
this.SelectNextControl(this.ActiveControl, true, true, true, true);
这个方法我认为最简洁.document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="<a target="_blank" rel="nofollow" href="http://download.Macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7">http://download.Macromedia.com/pub/sho ... h/swflash.cab#version=7</a>,0,19,0" width="'+w+'" height="'+h+'"> ');
document.write('<param name="movIE" value="' + file + '">');
document.write('<param name="quality" value="high"> ');
document.write('<param name="wmode" value="transparent"> ');
document.write('<param name="menu" value="false"> ');
document.write('<embed src="' + file + '" quality="high" pluginspage="<a target="_blank" rel="nofollow" href="http://www.macromedia.com/go/getflashplayer">http://www.macromedia.com/go/getflashplayer</a>" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed> ');
document.write('</object> ');
}<script type="text/<i>javascript</i>" language="<i>javascript</i>">swf('filename.swf','500','220');</script>
</div><script type="text/<i>javascript</i>" language="<i>javascript</i>">swf('filename.swf','500','220');</script>
</div>//private OleDbConnection m_XLSConn;
//private OleDbDataAdapter m_XLSAdapter;
//private DataTable GetDataFromXLS(string s_FileName)
//{
// string s_ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + s_FileName + ";Extended Properties = Excel 8.0";
// string s_SQLSelect = "select * from jx";
// m_XLSConn = new OleDbConnection(s_ConnString);
// m_XLSAdapter = new OleDbDataAdapter(s_SQLSelect, m_XLSConn);
// DataTable m_dtXLS = null;
// try
// {
// m_dtXLS = DataTable();
// m_XLSConn.Open();
// m_XLSAdapter.Fill(m_dtXLS);
// }
// catch (Exception exc)
// {
// throw exc;
// }
// finally
// {
// if (m_XLSConn.State == ConnectionState.Open)
// m_XLSConn.Close();
// }
// return m_dtXLS;
//}
private void simpleButton6_Click_1(object sender, EventArgs e)
{
try
{
int i;
string only;
SqlConnection conn = new SqlConnection("Data Source=172.16.112.20\\jweb;Initial Catalog=db_OA;Persist Security Info=True;User ID=sa;Password=");
only = "select count(*) from JobINcentive where 姓名 like '%" + cmbName.Text.Trim().ToString() + "%' and 日期='" + lblData.Text.Trim().ToString() + "'";
SqlCommand onlycmm = new SqlCommand(only, conn);
conn.Open();
i = (int)onlycmm.ExecuteScalar();
conn.Close();
if (lblData.Text == "" || cmbName.Text == "" || cmbName.Text == "--=请选择=--")
{
MessageBox.Show("日期和姓名必须填写,并且必须和将导入的报表中相同,否则将出现想现不到的结果,请慎重!", "导入条件不全", MessageBoxBu//调用kernel32.dll中的两个API:WritePrivateProfileString,GetPrivateProfileString来实现对ini文件的读写
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
public void IniWriteValue(string Section, string Key, string Value, string filepath) //对ini文件进行写操作的函数
{
WritePrivateProfileString(Section, Key, Value, filepath);
}
public string IniReadValue(string Section, string Key, string filepath) //对ini文件进行读操作的函数
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, filepath);
return temp.ToString();
}
//==================开始写入INI文件操作====================
public void writeIniFileSqlServer()
{
//label13.Text = "";
string iniFile = "DBC.ini";
string iniFilePath = Application.StartupPath + "\\" + iniFile;
if (!System.IO.File.Exists(iniFilePath))
{
System.IO.File.CreateText(iniFilePath);
}
if (comboBox4.Text == "")
{
MessageBox.Show("请选择一种类型的数据库", "选择错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (comboBox4.Text == "Sql Server")
{
try
{
IniWriteValue("OLEDB for Sql Server", "Microsoft Sql Server Database Sources",textBox4.Text + "\\" + textBox5.Text + ";Initial Catalog=" + textBox6.Text + ";Persist Security Info=True;User ID=" + textBox7.Text + ";Password=" + textBox8.Text, iniFilePath);
/**
* 给图片添加水印
* @param filePath 需要添加水印的图片的路径
* @param markContent 水印的文字
* @param markContentColor 水印文字的颜色
* @param qualNum 图片质量
* @return
*/
public boolean createMark(String filePath,String markContent,Color markContentColor,float qualNum)
{
//图片
ImageIcon imgIcon=new ImageIcon(filePath);
Image theImg =imgIcon.getImage();
int width=theImg.getWidth(null);
int height= theImg.getHeight(null);
BufferedImage bimage = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
//
水印图片
ImageIcon imgIcon1=new ImageIcon("f://ee.gif");
Image theImg1 =imgIcon1.getImage();
Graphics2D g=bimage.createGraphics();
g.setColor(markContentColor);
g.setBackground(Color.white);
g.drawImage(theImg, 0, 0, null );
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,1f)); //添加图片水印
g.drawImage(theImg1,0,0,null);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
//g.drawString(markContent,width-200,height-10); //添加水印的文字和设置水印文字出现的内容 和位置
g.dispose();
try{
FileOutputStream out=new FileOutputStream(filePath);
JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(out);
encoder.encode(bimage);
out.close();
}catch(Exception e)
{ return false; }
return true;
}
public static void main(String[] args) {
WaterMark wm = new WaterMark();
if (wm.createMark("f://yy.jpg","<h1><a target="_blank" rel="nofollow" href="http://www.free-120.com">http://www.free-120.com</a><h1>",Color.RED,80f))
{
System.out.println("添加水印成功!");
}
else
{
System