コード例 #1
0
        /// <summary>
        /// 检查是否存在记录
        /// </summary>
        /// <param name="inData"></param>
        /// <returns></returns>
        public static bool CheckData(DataSet inData)
        {
            bool flag1 = false;

            if (EmedFunc.CheckTable(inData))
            {
                for (int num1 = 0; num1 < inData.Tables.Count; num1++)
                {
                    if (inData.Tables[num1].Rows.Count > 0)
                    {
                        flag1 = true;
                    }
                }
                return(flag1);
            }
            return(false);
        }
コード例 #2
0
 public static bool WriteTxt(DataTable inDT, string inTxtName)
 {
     if (inDT.Rows.Count > 0)
     {
         StringBuilder builder1 = new StringBuilder();
         for (int num1 = 0; num1 < (inDT.Columns.Count - 1); num1++)
         {
             builder1.Append(inDT.Columns[num1].ColumnName + ",");
         }
         builder1.Append(inDT.Columns[inDT.Columns.Count - 1].ColumnName);
         builder1.Append("\n");
         for (int num2 = 0; num2 < inDT.Rows.Count; num2++)
         {
             for (int num3 = 0; num3 < (inDT.Columns.Count - 1); num3++)
             {
                 builder1.Append("\"" + inDT.Rows[num2][num3].ToString().Replace('"', '\'') + "\",");
             }
             builder1.Append("\"" + inDT.Rows[num2][inDT.Columns.Count - 1].ToString() + "\"");
             if (num2 < (inDT.Rows.Count - 1))
             {
                 builder1.Append("\n");
             }
         }
         try
         {
             if (!Directory.Exists(Path.GetDirectoryName(inTxtName)))
             {
                 Directory.CreateDirectory(Path.GetDirectoryName(inTxtName));
             }
             EmedFunc.SaveTextFile(inTxtName, builder1.ToString());
             return(true);
         }
         catch (Exception exception1)
         {
             EmedFunc.SaveTextFile("ErrorLog.txt", exception1.Message);
             return(false);
         }
     }
     return(true);
 }