日期:2014-05-17  浏览次数:20778 次

大侠帮看看,实在看不出哪有问题!!!!!!!!
private void button1_Click_1(object sender, EventArgs e) 
  {

  string connections = "Server=localhost;User ID=root;Password=wencui2006;Persist Security Info=True;DataBase=ken;charset=utf8";
  MySqlConnection conn = new MySqlConnection(connections);
  if (conn.State == ConnectionState.Closed)
  {
  conn.Open();
  }

  int machineID;
  string IP = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
  string[] array = IP.Split('.');
  machineID = Convert.ToInt32(array[3].ToString());//获取IP最后一位作为机器号
  //string FileName = Application.StartupPath + "\\Data\\" + "H" + DateTime.Now.ToString("yyyyMMdd") + "S." + machineID;
  string FileName = Application.StartupPath + "\\456.123";
  if (!File.Exists(FileName))
  {
  MessageBox.Show(FileName + "\n" + " 文件丢失");
  }
  else
  {
  /
  ckd ckd1 = new ckd();
  ckdsp ckdsp1 = new ckdsp();
  FileStream fs1 = new FileStream(FileName,FileMode.Open,FileAccess.Read);
  byte[] byteckd1=new byte[Marshal.SizeOf(typeof(ckd))];
  byte[] byteckdsp1=new byte[Marshal.SizeOf(typeof(ckdsp))];
  while (fs1.Read(byteckd1, 0, byteckd1.Length) == byteckd1.Length)
  {
  ckd1 = (ckd)BytesToStuct(byteckd1,typeof(ckd));
  //MessageBox.Show(ckd1.lsh64.ToString());
  for (int i = 0; i < ckd1.wLength; i++) //ckd1.wLength记录项目数(记录ckdsp1结构体中有多少条记录 )
  {
  if (fs1.Read(byteckdsp1, 0, byteckdsp1.Length) == byteckdsp1.Length)
  {
  ckdsp1 = (ckdsp)BytesToStuct(byteckdsp1,typeof(ckdsp));
  //MessageBox.Show(ckdsp1.iGoodsID.ToString());
  }
  }
  }
   
  string createtime = new string(ckd1.rq).Trim();  
  fs1.Flush();
  fs1.Close();
  string sqlLSH = string.Format("select a.FCreateTime from ShoprecentSalesM a,ShoprecentSalesD b where a.FID={0} and a.FID=b.FID", ckd1.lsh64); 
  MySqlCommand sqlLSHCmd = new MySqlCommand(sqlLSH, conn); /
  try
  {
  string gets = sqlLSHCmd.ExecuteScalar().ToString();
  DateTime dt = Convert.ToDateTime(gets);
  string CreateTimes = dt.ToString("yyyyMMddHHmmss");
  // MessageBox.Show(CreateTimes);
  if (string.Compare(createtime, CreateTimes) == 0) /
  {
  MessageBox.Show("该文件已上传");
  }
  else
  {
  MessageBox.Show("该文件没有上传过");
  }

  }
  catch  
  {
  int SuccessOrFailed = 0;
  in