示例#1
0
        /// <summary>
        /// 创建文件目录和文件
        /// </summary>
        /// <param name="tables">所有表</param>
        /// <param name="fileDir">文件目录</param>
        public static void Create(List <TableName> tables, string fileDir)
        {
            CreateDirectory(fileDir);
            foreach (TableName table in tables)
            {
                //实体类名称
                string entityName = GenVarName(table.Name);
                //实体类文件名
                string filePath = fileDir + entityName + ".cs";
                //文件是否存在
                bool exists = File.Exists(filePath);

                //创建文件
                FileStream   fs = new FileStream(filePath, exists ? FileMode.Open : FileMode.Create, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs);

                //生成代码
                string code = CreateFileHelper.BuilderCode(table.Name);

                //写入代码到文件
                sw.WriteLine(code);

                sw.Close();
                fs.Close();
            }
        }
示例#2
0
文件: Form1.cs 项目: willianyy/Z
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)//当单击复选框,同时处于组合编辑状态时
            {
                DataGridViewCell cell     = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
                bool             ifcheck1 = Convert.ToBoolean(cell.FormattedValue);
                bool             ifcheck2 = Convert.ToBoolean(cell.EditedFormattedValue);

                if (ifcheck1 != ifcheck2)
                {
                    TableName tb = m_tables[e.RowIndex];
                    reLoadColumns(tb.Name);
                    string code = CreateFileHelper.BuilderCode(tb.Name);
                    code           = code.Replace("\n", "\r\n");
                    txtSyntax.Text = code;
                }
            }
        }