Exemple #1
0
        private void CreateFiles()
        {
            int i = 0;

            try
            {
                int fileCount = _listTableName == null ? 0 : _listTableName.Count;
                while (i < fileCount)
                {
                    FileHelper.SaveCSharpFile(_dbConnection, _dataBase, _listTableName[i], _nameSpace, _dirPath + "\\" + _listTableName[i] + ".cs");
                    SetTextMesssage(i, fileCount, "");
                    Model.TableFileInfo model = new Model.TableFileInfo();
                    model.TableName  = _listTableName[i];
                    model.FileStatus = "文件已生成,目录为:" + _dirPath + "\\" + _listTableName[i] + ".cs";
                    EventListener.OnUpdateFMainDataGridView(Model.AddUpdateDelete.Update, model);
                    i++;
                }
                SetTextMesssage(fileCount, fileCount, "");
                //System.Threading.Thread.CurrentThread.Abort();
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Threading.Thread.CurrentThread.ThreadState.ToString());
                Model.TableFileInfo model = new Model.TableFileInfo();
                model.TableName  = _listTableName[i - 1 < 0 ? 0 : i - 1];
                model.FileStatus = "生成文件报错,错误原因为" + ex.Message;
                EventListener.OnUpdateFMainDataGridView(Model.AddUpdateDelete.Update, model);

                MessageBox.Show("生成文件报错,错误原因为" + ex.Message, "报错", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.CloseForm();
            }
        }
Exemple #2
0
        private void UpdateDVTableFile(AddUpdateDelete aud, Model.TableFileInfo tableFileInfo, bool isErr = false, bool clearRows = false)
        {
            try
            {
                if (this.dv_tableList.InvokeRequired)
                {
                    object[] wrk = { aud, tableFileInfo, isErr, clearRows };
                    delDataGridView = new DelegateDataGridView(UpdateDVTableFile);
                    this.dv_tableList.Invoke(this.delDataGridView, wrk);
                }
                else
                {
                    if (clearRows)
                    {
                        this.dv_tableList.Rows.Clear();
                    }
                    else
                    {
                        switch (aud)
                        {
                        case AddUpdateDelete.Add:
                            if (tableFileInfo.TableName != string.Empty)
                            {
                                this.dv_tableList.Rows.Add();
                                DataGridViewRow r = this.dv_tableList.Rows[this.dv_tableList.Rows.Count - 1];
                                r.SetValues(tableFileInfo.CheckValue, tableFileInfo.TableName, tableFileInfo.FilePath, tableFileInfo.FileStatus);
                                tableFileInfo.DataRow = r;
                            }
                            break;

                        case AddUpdateDelete.Update:
                            if (tableFileInfo.TableName != string.Empty)     //&& tableFileInfo.DataRow != null)
                            {
                                foreach (DataGridViewRow dgvRow in dv_tableList.Rows)
                                {
                                    if (tableFileInfo.TableName == (string)dgvRow.Cells[1].Value)
                                    {
                                        dgvRow.Cells[3].Value = tableFileInfo.FileStatus;
                                        continue;
                                    }
                                }

                                //DataGridViewRow r = tableFileInfo.DataRow;
                                ////r.SetValues(tableFileInfo.CheckValue, tableFileInfo.TableName, tableFileInfo.FilePath, tableFileInfo.FileStatus);
                                //r.SetValues(r.Cells[0].Value,
                                //    r.Cells[1].Value,
                                //    r.Cells[2].Value,
                                //    tableFileInfo.FileStatus);
                                //if (isErr)
                                //    this.dv_tableList.Rows[this.dv_tableList.Rows.IndexOf(r)].Cells[3].Style.ForeColor = Color.Red;
                            }
                            break;

                        case AddUpdateDelete.Delete:
                            if (tableFileInfo.TableName != string.Empty)
                            {
                                this.dv_tableList.Rows.Remove(tableFileInfo.DataRow);
                            }
                            break;

                        default: break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }