示例#1
0
 //遍历文件夹,更新数据
 private void UpdateData()
 {
     while (true)
     {
         Thread.Sleep(1000*60);
         try
         {
             OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Windows\\System32\\data\\data.mdb;");
             cn.Open();
             DataTable dt = new DataTable();
             OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [data]", cn);
             da.Fill(dt);
             string sqls = "";
             foreach (DataRow row in dt.Rows)
             {
                 CarData data = new CarData();
                 data.boxid = row["boxid"].ToString();
                 data.truckNo = row["truckNo"].ToString();
                 data.startTime = row["startTime"].ToString();
                 data.stationID = int.Parse(row["startstationid"].ToString());
                 data.type = int.Parse(row["type"].ToString());
                 data.endTime = row["endTime"].ToString();
                 data.allWeight = double.Parse(row["allWeight"].ToString());
                 data.carWeight = double.Parse(row["downWeight"].ToString());
                 data.downTime = row["downTime"].ToString();
                 data.uplist = row["upList"].ToString();
                 data.downTime = row["downList"].ToString();
                 string sql = "EXEC center_updatedata '" + data.boxid + "','"
         + data.truckNo + "','" + data.parseData(1) + "',"
         + data.stationID + "," + data.type + "," + CommonData.stationID + ",'" + data.parseData(0)
         + "'," + (data.allWeight - data.carWeight) + ",'"
         + data.picPath + "',@status=" + 0 + ",@allWeight="
         + data.allWeight + ",@downWeight=" + data.carWeight + ",@downTime='"
         + data.downTime + "',@uplist='" + data.uplist + "',@downlist='" + data.downlist + "'";
                 BaseOperate op = new BaseOperate();
                 if (!op.getcom(sql))
                     continue;
                 sql = "DELETE FROM [data] WHERE ID = " + int.Parse(row["id"].ToString());
                 OleDbCommand cmd = new OleDbCommand(sql, cn);
                 cmd.ExecuteNonQuery();
             }
             cn.Close();
         }
         catch (Exception ex) { LogWriter.WriteLog(ex.Message + "\n" + ex.StackTrace); }
     }
 }
示例#2
0
 //保存文件
 public void SaveData()
 {
     try
     {
         string strWeight = (data.allWeight - data.carWeight).ToString();
         if (strWeight.Length > 4)
             strWeight = strWeight.Substring(0,4);
         string sql = "EXEC center_updatedata '" + data.boxid + "','"
             + data.truckNo + "','" + data.parseData(1) + "',"
             + data.stationID + "," + data.type + "," + CommonData.stationID + ",'" + data.parseData(0)
             + "'," + strWeight + ",'"
             + data.picPath + "',@status=" + this.state + ",@allWeight="
             + this.data.allWeight + ",@downWeight=" + this.data.carWeight + ",@downTime='"
             + data.downTime + "',@uplist='" + data.uplist + "',@downlist='" + data.downlist + "'";
         BaseOperate op = new BaseOperate();
         if (op.getcom(sql) == false)
         {
             this.SaveFile(sql);
         }
         if (tmrDownOut == null)
         {
             CommonData.datas.Remove(this);
             this.Dispose();
             return;
         }
         tmrDownOut.Start();
     }
     catch (Exception ex) { LogWriter.WriteLog(ex.Message + "\n" + ex.StackTrace); }
 }
示例#3
0
        private void bgwUpdate_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Control.CheckForIllegalCrossThreadCalls = false;
                string sql = "SELECT * FROM [dbo.Goods] WHERE EndStationID=" + CommonData.stationID + " AND EndTime >= '" + DateTime.Now.ToString("yy-MM-dd,00:00") + "'";
                double sumWeight = 0;
                BaseOperate op = new BaseOperate();
                DataSet ds = op.getds(sql, "[dbo.Goods]");
                if (ds.Tables.Count <= 0)
                    return;
                ChartData chartdata = new ChartData();
                vschart = new visifire();

                chartdata.updateData(5, DateTime.Now, 0).ToString();
                vschart.reSize(webBrowser.Width, webBrowser.Height);
                vschart.settitle("当日转运中心报表", "时间", "运输量");
                string[] column = new string[16];
                double[] data1 = new double[16];
                for (int i = 0; i <= 15; i++)
                {
                    column[i] = (i + 5).ToString() + ":00";
                    data1[i] = chartdata.stationdaybox[i];
                }

                vschart.set3D(true);
                vschart.setData(column, data1, 16);
                string type = "pie";

                vschart.setType(type);
                e.Result = ds;
                if (CommonData.stations.Rows.Count > 0)
                    return;
                sql = "Select * from [dbo.Station]";
                DataSet ds1 = operate.getds(sql, "[dbo.Station]");
                if (ds1 == null || ds1.Tables.Count <= 0)
                    CommonData.stations = new DataTable();
                else
                    CommonData.stations = ds1.Tables[0];
            }
            catch (Exception ex) { LogWriter.WriteLog(ex.Message + "\n" + ex.StackTrace); }
        }