示例#1
0
        public bool UpdateColumns(string filePath)
        {
            DataTable distinct = MyXlsHelper.GetData(filePath).Tables[0];

            if (distinct == null)
            {
                return(false);
            }
            if (distinct.Columns.Contains("字段名称") && distinct.Columns.Contains("字段说明"))
            {
                DataTable dt = BLLFactory.Instance.idb.GetTablesColumnsList(Utils.dbName, "");
                foreach (DataRow dict in distinct.Rows)
                {
                    string dicoumName = dict["字段名称"].ToString();
                    string dicoumInfo = dict["字段说明"].ToString();
                    foreach (DataRow row in dt.Rows)
                    {
                        string tableName      = row["表名"].ToString();
                        string columnName     = row["字段名"].ToString().Trim().ToLower();
                        string columnInfoInfo = row["字段说明"].ToString();
                        if (dicoumName.Equals(columnName))
                        {
                            if (!string.IsNullOrEmpty(columnInfoInfo))
                            {
                                //存在就更新
                                BLLFactory.Instance.idb.ExtendedProperty(false, dicoumInfo, tableName, columnName);
                            }
                            else
                            {
                                BLLFactory.Instance.idb.ExtendedProperty(true, dicoumInfo, tableName, columnName);
                            }
                        }
                    }
                }
                return(true);
            }
            else
            {
                // MessageBox.Show("xls文件里面必须包含 字段名称,字段说明 这两列,并且文件工作表的名字必须是Sheet1$ ");
                return(false);
            }
        }
示例#2
0
 private void 导出数据库里相同的字段ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("导出数据库里相同的字段", "提示",
                             MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             DataTable table = BLLFactory.Instance.idb.GetEqualColumnsList(Utils.dbName);
             MyXlsHelper.LeadOutToExcel(table);
         }
         else
         {
             DataTable table = BLLFactory.Instance.idb.GetTablesColumnsList("", Utils.dbName);
             MyXlsHelper.LeadOutToExcel(table);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }