Exemplo n.º 1
0
        /// <summary>
        /// 加载帐套档案
        /// </summary>
        public void LoadAccount()
        {
            if (AccountArchives != null)
            {
                AccountArchives.Clear();
            }
            XmlReader reader = new XmlTextReader(AccountArchivePath);

            try
            {
                AccountArchives accountArchives = XMLHelper.UnSerializer(reader, typeof(AccountArchives)) as AccountArchives;
                if (accountArchives != null)
                {
                    foreach (var value in accountArchives)
                    {
                        AccountArchives.Add(value);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 导入凭证
 /// </summary>
 /// <param name="filePath"></param>
 /// <returns></returns>
 public void ImportAccvouchByExcel(string filePath, List <string> infos)
 {
     try
     {
         DataSet ds = ExcelHelper.QueryByODBC(filePath, "Sheet1");
         if (ds.Tables.Count > 0)
         {
             DataTable dt    = ds.Tables[0];
             string    curId = string.Empty;
             for (int i = 0; i < dt.Rows.Count; ++i)
             {
                 if (dt.Rows[i]["凭证ID"].ToString() != curId)
                 {
                     curId = dt.Rows[i]["凭证ID"].ToString();
                     if (Accvouch.Find(curId))
                     {
                         infos.Add("凭证ID:" + curId + "导入失败!错误提示:该凭证ID已导入");
                         continue;
                     }
                     //判断ERP帐套号与U8账号是否对应
                     if (!AccountArchives.FindByVesselCode(dt.Rows[i]["ERP帐套号"].ToString()))
                     {
                         infos.Add("凭证ID:" + curId + "导入失败! " + "错误提示:对应的ERP帐套号与U8帐套号不匹配");
                         continue;
                     }
                     ImportAccvoch(dt.Select("凭证ID=" + "'" + curId + "'"), filePath, infos);
                 }
             }
         }
         else
         {
             infos.Add("读取Excel文件失败,请检查该文件是否已打开或表Sheet1是否存在!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ",凭证导入失败!");
         infos.Add(ex.Message);
     }
 }