示例#1
0
        /// <summary>
        ///
        /// </summary>
        private void UpdateQRCode2AliCloud()
        {
            //取得所有的缓存数据
            DataTable dtAllData = new DataTable();

            dtAllData = AccessHelper.ExecuteDataTable(connAccess, "SELECT [FCodeID],[FQRCode], [FBillNoEntryId] FROM T_QRCODE");

            if (dtAllData.Rows.Count > 0)
            {
                //得到唯一的单据行号
                string[] DistinctBillNo = CommonProcess.GetDistinctBillNo(dtAllData, "FBillNoEntryId").Split(';');

                if (DistinctBillNo.Length > 0)
                {
                    //对每一行进行处理
                    foreach (string billNo in DistinctBillNo)
                    {
                        //过滤只留下一行数据
                        DataTable dtFilteredData = CommonProcess.FilterData(dtAllData, "FBillNoEntryId = '" + billNo + "'");

                        if (dtFilteredData.Rows.Count > 0)
                        {
                            //生成插入语句
                            sql = BuildDetailSql(dtFilteredData);

                            //写入云
                            int ret = SqlHelper.ExecuteNonQuery(connALiClouds, sql);

                            //如果返回值等于一行数据的个数,表示该行数据已经到云
                            if (ret == dtFilteredData.Rows.Count)
                            {
                                // 更新主表中已扫个数
                                string billNoEntryID = dtFilteredData.Rows[0]["FBillNoEntryId"].ToString();
                                int    retUpdateQty  = UpdateCloudQty(billNoEntryID, ret);
                                //更新成功
                                if (retUpdateQty > 0)
                                {
                                    //删除ACCESS数据库中的该行数据
                                    sql = string.Format("Delete from t_QRCode where FBillNoEntryId = '{0}'", billNoEntryID);
                                    int retInt = AccessHelper.ExecuteNonQuery(connAccess, sql);
                                    if (retInt == ret)
                                    {
                                        //删除成功,则是上传成功
                                        CustomDesktopAlert.H2("数据上传成功!");
                                    }
                                    else
                                    {
                                        //删除失败,则是上传失败
                                        CustomDesktopAlert.H2("数据未能全部上传!");
                                    }
                                }
                                else
                                {
                                    //更新个数失败
                                    CustomDesktopAlert.H2("更新主表失败!");
                                }
                            }
                            else
                            {
                                CustomDesktopAlert.H2("缓存中无数据");
                            }
                        }
                        else
                        {
                            CustomDesktopAlert.H2("保存数据出错!");
                        }
                    }
                }
                else
                {
                    CustomDesktopAlert.H2("缓存中的单号列表为空");
                }
            }
            else
            {
                CustomDesktopAlert.H2("缓存中无数据");
            }
        }