private void but_Build_Click(object sender, EventArgs e) { try { string path = string.Empty; FolderBrowserDialog dialog = new FolderBrowserDialog(); if (dialog.ShowDialog(this) == DialogResult.OK) { path = dialog.SelectedPath + "\\Template"; } #region List<TableColumn> List<TableColumn> SelectWhere = new List<TableColumn>(); List<TableColumn> ShowFields = new List<TableColumn>(); TableModel LeftTree = null; List<TableColumn> CheckFields = new List<TableColumn>(); List<TableColumn> CheckFepeat = new List<TableColumn>(); for (int i = 0; i < chk_SelectWhere.CheckedItems.Count; i++) { SandData sandData = chk_SelectWhere.CheckedItems[i] as SandData; TableColumn column = sandData.Value as TableColumn; SelectWhere.Add(column); } for (int i = 0; i < chk_ShowFields.CheckedItems.Count; i++) { SandData sandData = chk_ShowFields.CheckedItems[i] as SandData; TableColumn column = sandData.Value as TableColumn; ShowFields.Add(column); } for (int i = 0; i < chk_CheckFields.CheckedItems.Count; i++) { SandData sandData = chk_CheckFields.CheckedItems[i] as SandData; TableColumn column = sandData.Value as TableColumn; CheckFields.Add(column); } for (int i = 0; i < chk_CheckFepeat.CheckedItems.Count; i++) { SandData sandData = chk_CheckFepeat.CheckedItems[i] as SandData; TableColumn column = sandData.Value as TableColumn; CheckFepeat.Add(column); } if (checkBox1.Checked) { LeftTree = new TableModel(); LeftTree.TableName = cmb_Tables.Text; TableColumn column = (TableColumn)cmbTree_Name.Tag; LeftTree.TablePK = column.ColumnName; } #endregion WinFromComplexBuild wfcb = new WinFromComplexBuild(); wfcb.Library(path, tableModel, SelectWhere, ShowFields, LeftTree, CheckFields, CheckFields); MessageBox.Show("已完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void AddNewRow(TableModel model, NodeViewModelBase itemToRemove) { if (model.IsCollapsed) model.IsCollapsed = false; if (itemToRemove == null) model.AddItem(new RowModel() { ColumnName = "NewRow", DataType = DataType.String }); else model.AddItem(itemToRemove); }
public ContributorsPanel(List contributors) { base.\u002Ector(); ContributorsPanel contributorsPanel = this; ((Container) this).setLayout((LayoutManager) new BorderLayout()); this.model = (TableModel) new ContributorsTableModel(contributors); JTable.__\u003Cclinit\u003E(); this.table = new JTable(this.model); JScrollPane.__\u003Cclinit\u003E(); ((Container) this).add((Component) new JScrollPane((Component) this.table)); }
public TableModel GetTableModel(string TableName, string dbName = "master") { TableModel model = new TableModel(); model.TableName = TableName; model.TableNameRemark = this.GetTableAlone(dbName, model.TableName, TableFlg.表说明); model.TablePK = this.GetTableAlone(dbName, model.TableName, TableFlg.主键列); bool istree = false; List<TableColumn> columnsList = this.GetColumnsList(TableName, dbName, out istree); model.Columns = columnsList; model.IsTree = istree; return model; }
private void RemoveRow(TableModel model, NodeViewModelBase itemToRemove) { var dc = this.DataContext as TablesGraphSource; if (dc != null && model != null && itemToRemove != null) { if (model.IsCollapsed) model.IsCollapsed = false; dc.RemoveItem(itemToRemove); } CommandManager.InvalidateRequerySuggested(); }
private List<TableModel> GetTableModelList(bool flg = true) { List<TableModel> list = new List<TableModel>(); DataTable dt = this.GetTablesColumnsList(""); DataRow[] drs = dt.Select(TableFlg.表名.ToString()); for (int i = 0; i < drs.Length; i++) { TableModel tm = new TableModel(); tm.TableName = drs[i]["表名"].ToString(); tm.TableNameRemark = drs[i]["表说明"].ToString(); tm.TablePK = this.GetTableAlone(tm.TableName, TableFlg.主键列); bool istree = false; tm.Columns = this.GetColumnsList(tm.TableName, out istree); tm.IsTree = istree; list.Add(tm); } return list; }
public BillPage(TableModel selectedTable) { InitializeComponent(); LoadData(selectedTable); }
public int insertData_serie_documento_user(string name) { string ruta = "C:/Users/rober/Desktop/test/"; string text; try { TextReader reader = new StreamReader(ruta + name); text = reader.ReadToEnd(); reader.Close(); } catch (Exception) { return(404); } var tableJson = JsonConvert.DeserializeObject(text); var tableString = JsonConvert.SerializeObject(tableJson); listajson = JsonConvert.DeserializeObject <List <TableModel> >(tableString); List <TableModel> objectDetailList = new List <TableModel>(); using (var connection = Connection.ConnectionSql.getConnection()) { connection.Open(); //filtra registros por id para no dupilacar las transacciones foreach (var row in listajson) { //verifica si el registro ya exxiste SqlDataAdapter cmd = new SqlDataAdapter("select Id from dbo.serie_documento_user where Id = " + row.Id, connection); DataSet dataSet = new DataSet(); cmd.Fill(dataSet); string contentFile = JsonConvert.SerializeObject(dataSet.Tables[0]); if (contentFile.Length != 2) { //si existe no pasa nada } else { var detail = new TableModel() { Tipo_Documento = row.Tipo_Documento, Serie_Documento = row.Serie_Documento, Empresa = row.Empresa, UserName = row.UserName }; objectDetailList.Add(detail); } } using (SqlTransaction transaction = connection.BeginTransaction()) { using (var command = new SqlCommand()) { command.Connection = connection; command.Transaction = transaction; command.CommandType = CommandType.Text; command.CommandText = "insert into dbo.serie_documento_user values (" + "@Tipo_Documento," + "@Serie_Documento," + "@Empresa, " + "@UserName " + ")"; command.Parameters.Add("@Tipo_Documento", SqlDbType.Int); command.Parameters.Add("@Serie_Documento", SqlDbType.VarChar); command.Parameters.Add("@Empresa", SqlDbType.Int); command.Parameters.Add("@UserName", SqlDbType.VarChar); try { foreach (var item in objectDetailList) { command.Parameters["@Tipo_Documento"].Value = item.Tipo_Documento; command.Parameters["@Serie_Documento"].Value = item.Serie_Documento; command.Parameters["@Empresa"].Value = item.Empresa; command.Parameters["@UserName"].Value = item.UserName; command.ExecuteNonQuery(); } transaction.Commit(); return(201); } catch (Exception) { transaction.Rollback(); connection.Close(); return(500); } } } } }
public string ApplyTemplate(TableModel table, List <TableModel> tables = null, string textToAppend = null) { _messages.Add(new ProjectConsoleMessages() { erro = false, data = DateTime.Now, mensagem = string.Format("{0} - Processando Tabela [{1}]", this.CommandID, table.Name) }); string className = table.Alias.Replace("DTO", "") + "Base"; _fileName = className; StringBuilder classCode = new StringBuilder(); if (table.IgnoreDTO) { return(""); } string variables = ""; string constructorParameters = ""; string constructorVariableAssign = ""; var dependencyTables = base.GetAllDependencies(table, tables); var relatedTables = base.MainTableRelations(table, tables); var baseConstructorParam = ""; Dependencies(table, dependencyTables, true, out variables, out constructorParameters, out constructorVariableAssign, out baseConstructorParam); classCode.AppendLine("using Light;"); classCode.AppendLine("using Light.Validation;"); classCode.AppendLine("using SwServices;"); classCode.AppendLine("using SwServices.Common.DTOs;"); classCode.AppendLine("using SwServices.Common.Business;"); classCode.AppendLine(string.Format("using {0}.Common.DTOs;", this.NameSpace)); classCode.AppendLine(string.Format("using {0}.Data.Models;", this.NameSpace)); classCode.AppendLine(string.Format("using {0}.Common.Business;", this.NameSpace)); classCode.AppendLine("using System;"); classCode.AppendLine("using System.Collections.Generic;"); classCode.AppendLine("using System.Data;"); classCode.AppendLine("using System.Linq;"); classCode.AppendLine("using System.Text;"); classCode.AppendLine("using System.Threading.Tasks;"); classCode.AppendLine(""); classCode.AppendLine(""); classCode.AppendLine("namespace " + base.NameSpace + ".Core.Business"); classCode.AppendLine("{"); classCode.AppendLine(""); #region BaseClass classCode.AppendLine("\tpublic class " + className + ": I" + table.Alias.Replace("DTO", "") + ""); classCode.AppendLine("\t{"); #region Variaveis Membro classCode.AppendLine("\t\t#region Variables"); classCode.AppendLine(variables); classCode.AppendLine("\t\t#endregion Variables"); classCode.AppendLine(""); #endregion Variaveis Membro #region Construtor classCode.AppendLine("\t\t#region Construtor"); classCode.AppendLine(string.Format("\t\tpublic {0}Base({1})", table.Alias.Replace("DTO", ""), constructorParameters)); classCode.AppendLine("\t\t{"); classCode.AppendLine(constructorVariableAssign); classCode.AppendLine("\t\t}"); classCode.AppendLine("\t\t#endregion Construtor"); classCode.AppendLine(""); #endregion Construtor #region Save classCode.AppendLine("\t\tpublic OutputTransport<" + table.Alias + "> Save(InputTransport<" + table.Alias + "> model, bool openTransaction = false)"); classCode.AppendLine("\t\t{"); classCode.AppendLine("\t\t\tvar ret = new OutputTransport<" + table.Alias + ">();"); classCode.AppendLine("\t\t\t\tret.Data = model.Data;"); classCode.AppendLine("\t\t\t\tret.success = false;"); classCode.AppendLine("\t\t\t"); classCode.AppendLine("\t\t\ttry"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\t"); classCode.AppendLine("\t\t\t\tvar data = new " + table.ModelName + "();"); classCode.AppendLine(string.Format("\t\t\t\tSwServices.Core.Utils.Helper.CopyToBusiness<{0}, {1}>(model.Data, ref data);", table.Alias, table.ModelName)); classCode.AppendLine("\t\t\t\t"); var keyColumns = table.Columns.Where(c => c.IsPK).ToList(); var strKeys = ""; for (var i = 0; i < keyColumns.Count; i++) { strKeys += strKeys == "" ? "" : ", "; strKeys += "model.Data." + keyColumns[i].DTOName; } classCode.AppendLine("\t\t\t\tint affected = -1;"); classCode.AppendLine(string.Format("\t\t\t\tvar tmp = _{0}Data.Get({1});", table.ModelName, strKeys)); classCode.AppendLine("\t\t\t\tif( tmp == null )"); classCode.AppendLine(string.Format("\t\t\t\t\taffected = _{0}Data.Add(data);", table.ModelName)); classCode.AppendLine("\t\t\t\telse"); classCode.AppendLine(string.Format("\t\t\t\t\taffected = _{0}Data.Update(data);", table.ModelName)); classCode.AppendLine("\t\t\t\t"); classCode.AppendLine("\t\t\t\tif(affected == 1)"); classCode.AppendLine("\t\t\t\t{"); if (table.Columns.Where(c => c.IsIdentity).Count() > 0) { classCode.AppendLine("\t\t\t\t\tOutputTransport<" + table.Alias + "> retGet = Get(data." + table.Columns.Where(c => c.IsIdentity).First().ColumnName + ");"); classCode.AppendLine("\t\t\t\t\tif (retGet.success)"); classCode.AppendLine("\t\t\t\t\t\tret.Data = retGet.Data;"); classCode.AppendLine(""); classCode.AppendLine(""); } classCode.AppendLine("\t\t\t\t\t//SAVE RELATED DATA"); classCode.AppendLine("\t\t\t\t\tif(openTransaction)"); classCode.AppendLine("\t\t\t\t\t\t_{0}Data.DB.Commit();".Replace("{0}", table.ModelName)); classCode.AppendLine("\t\t\t\t\t"); classCode.AppendLine("\t\t\t\t\tret.success = true;"); classCode.AppendLine("\t\t\t\t\t}"); classCode.AppendLine("\t\t\t\telse"); classCode.AppendLine("\t\t\t\t{"); classCode.AppendLine("\t\t\t\t\tret.code = Parameters.Default.NOTFOUND_CODE;"); classCode.AppendLine("\t\t\t\t\tret.message = Parameters.Default.NOTFOUND_MESSAGE;"); classCode.AppendLine("\t\t\t\t}"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\tcatch (Exception err)"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\tvar Exc = new ExceptionOutputTransport<" + table.Alias + ">();"); classCode.AppendLine("\t\t\t\t\tExc.Exception = err;"); classCode.AppendLine("\t\t\t\t\tExc.code = Parameters.Default.ERR_CODE;"); classCode.AppendLine("\t\t\t\t\tExc.message = string.Format(Parameters.Default.ERR_MESSAGE, err.Message);"); classCode.AppendLine("\t\t\t\t\tExc.success = false;"); classCode.AppendLine("\t\t\t\t\tret = Exc;"); classCode.AppendLine("\t\t\t\t\t"); classCode.AppendLine("\t\t\t\t\tif(openTransaction)"); classCode.AppendLine("\t\t\t\t\t\t_{0}Data.DB.Rollback();".Replace("{0}", table.ModelName)); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\treturn ret;"); classCode.AppendLine("\t\t}"); classCode.AppendLine(""); #endregion Save #region Search classCode.AppendLine("\t\tpublic TableTransport<List<" + table.Alias + ">> Search(Criteria" + table.Alias + " args)"); classCode.AppendLine("\t\t{"); classCode.AppendLine("\t\t\treturn Search(args, 1, 100);"); classCode.AppendLine("\t\t}"); classCode.AppendLine(""); classCode.AppendLine("\t\tpublic TableTransport<List<" + table.Alias + ">> Search(Criteria" + table.Alias + " args, int currentPage, int pageSize)"); classCode.AppendLine("\t\t{"); classCode.AppendLine("\t\t\tint pageCount;"); classCode.AppendLine("\t\t\tvar ret = new TableTransport<List<" + table.Alias + ">>();"); classCode.AppendLine("\t\t\t ret.Data = new List<" + table.Alias + ">();"); classCode.AppendLine(""); #region Criteria classCode.AppendLine("\t\t\t#region Criteria to Query"); classCode.AppendLine(string.Format("\t\t\tvar strQuery = \"{0} is not null\";", table.Columns.Where(c => c.IsPK).First().ColumnName)); classCode.AppendLine("\t\t\tList<IParameter> parameters = new List<IParameter>();"); for (var i = 0; i < table.Columns.Count; i++) { if (table.Columns[i].IgnoreOnDTO == false && table.Columns[i].UseAsSearchParameter) { switch (table.Columns[i].DataType.Trim().Replace("?", "")) { case "bool": classCode.AppendLine(string.Format("\t\t\tif(args.{0}.HasValue)", table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t{"); classCode.AppendLine(string.Format("\t\t\t\tstrQuery+= \" AND {0}=@{1}Value\";", table.Columns[i].ColumnName, table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t\tparameters.Add(" + ParameterFromColumn(table.Columns[i], "args") + ");"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine(""); break; case "int": case "long": case "decimal": classCode.AppendLine(string.Format("\t\t\tif(args.{0}.HasValue)", table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t{"); classCode.AppendLine(string.Format("\t\t\t\tstrQuery+= \" AND {0}=@{1}Value\";", table.Columns[i].ColumnName, table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t\tparameters.Add(" + ParameterFromColumn(table.Columns[i], "args") + ");"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine(""); break; case "Guid": classCode.AppendLine(string.Format("\t\t\tif(args.{0}.HasValue)", table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t{"); classCode.AppendLine(string.Format("\t\t\t\tstrQuery+= \" AND {0}=@{1}Value\";", table.Columns[i].ColumnName, table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t\tparameters.Add(" + ParameterFromColumn(table.Columns[i], "args") + ");"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine(""); break; case "DateTime": classCode.AppendLine(string.Format("\t\t\tif(args.{0}Start.HasValue)", table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t{"); classCode.AppendLine(string.Format("\t\t\t\tstrQuery+= \" AND {0} >= @{1}StartValue\";", table.Columns[i].ColumnName, table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t\tparameters.Add(" + ParameterFromColumn(table.Columns[i], "args", "Start") + ");"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine(""); classCode.AppendLine(string.Format("\t\t\tif(args.{0}Finish.HasValue)", table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t{"); classCode.AppendLine(string.Format("\t\t\t\tstrQuery+= \" AND {0} <= @{1}FinishValue\";", table.Columns[i].ColumnName, table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t\tparameters.Add(" + ParameterFromColumn(table.Columns[i], "args", "Finish") + ");"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine(""); break; default: classCode.AppendLine(string.Format("\t\t\tif(string.IsNullOrEmpty(args.{0}) == false)", table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t{"); classCode.AppendLine(string.Format("\t\t\t\tstrQuery+= \" AND {0} LIKE '%' + @{1}Value + '%'\";", table.Columns[i].ColumnName, table.Columns[i].DTOName)); classCode.AppendLine("\t\t\t\tparameters.Add(" + ParameterFromColumn(table.Columns[i], "args") + ");"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine(""); break; } } } classCode.AppendLine("\t\t\t#endregion Criteria to Query"); #endregion Criteria classCode.AppendLine(""); classCode.AppendLine("\t\t\ttry"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine(string.Format("\t\t\t\tvar lstTmp = _{0}Data.List(new Query(strQuery, parameters.ToArray()), pageSize, currentPage, out pageCount);", table.ModelName)); classCode.AppendLine("\t\t\t\tif (lstTmp != null)"); classCode.AppendLine("\t\t\t\t{"); classCode.AppendLine("\t\t\t\t\tforeach (var tmp in lstTmp)"); classCode.AppendLine("\t\t\t\t\t{"); classCode.AppendLine("\t\t\t\t\t\tvar dto = new " + table.Alias + "();"); classCode.AppendLine(string.Format("\t\t\t\t\t\tSwServices.Core.Utils.Helper.CopyFromBusiness<{0}, {1}>(tmp, ref dto);", table.Alias, table.ModelName)); classCode.AppendLine("\t\t\t\t\t\tLoadRelatedData(ref dto);"); classCode.AppendLine("\t\t\t\t\t\tret.Data.Add(dto);"); classCode.AppendLine("\t\t\t\t\t}"); classCode.AppendLine("\t\t\t\t}"); classCode.AppendLine(""); classCode.AppendLine("\t\t\t\tret.pages = pageCount;"); classCode.AppendLine("\t\t\t\tret.success = true;"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\tcatch(Exception err)"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\tret.Exception = err;"); classCode.AppendLine("\t\t\t\tret.success = false;"); classCode.AppendLine("\t\t\t\tret.code = Parameters.Default.ERR_CODE;"); classCode.AppendLine("\t\t\t\tret.message = string.Format(Parameters.Default.ERR_MESSAGE, err.Message);"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\treturn ret;"); classCode.AppendLine("\t\t}"); classCode.AppendLine(""); #endregion Save #region Protected Methods classCode.AppendLine("\t\tprotected void LoadRelatedData(ref " + table.Alias + " dto)"); classCode.AppendLine("\t\t{"); var relatedColumns = table.Columns.Where(c => string.IsNullOrEmpty(c.RelatedTable) == false && c.IgnoreOnDTO == false).ToList(); for (var i = 0; i < relatedColumns.Count; i++) { var relatedTable = tables.Where(t => t.Name == relatedColumns[i].RelatedTable).Single(); var dtoName = "dto" + relatedTable.Alias.Replace("DTO", ""); var modelName = "result" + relatedTable.ModelName; if (relatedTable.MainDTO) { dtoName = relatedTable.Alias.Replace("DTO", ""); classCode.AppendLine(string.Format("\t\t\tvar result{0} = _{1}BS.Get( dto.{2}.{3} );", dtoName, dtoName, dtoName, relatedTable.Columns.Where(c => c.IsPK).First().DTOName)); classCode.AppendLine("\t\t\tif( result{0}.success ) ".Replace("{0}", dtoName)); classCode.AppendLine(string.Format("\t\t\t\tdto.{0} = result{1}.Data;", dtoName, dtoName)); classCode.AppendLine(""); } else { classCode.AppendLine(string.Format("\t\t\tvar {0} = new {1}();", dtoName, relatedTable.Alias)); classCode.AppendLine(string.Format("\t\t\tvar {0} = _{1}Data.Get( dto.{2}.{3} );", modelName, relatedTable.ModelName, relatedTable.Alias.Replace("DTO", ""), relatedTable.Columns.Where(c => c.IsPK).First().DTOName)); classCode.AppendLine("\t\t\tif( {0}.success ) {".Replace("{0}", modelName)); classCode.AppendLine(string.Format("\t\t\t\tUtils.Helper.CopyFromBusiness<{0}, {1}>({2}.Data, ref {3});", relatedTable.Alias, (relatedTable.ModelName + "Model"), modelName, dtoName)); classCode.AppendLine(string.Format("\t\t\t\tdto.{0} = {1};", relatedTable.Alias.Replace("DTO", ""), dtoName)); classCode.AppendLine("\t\t\t}"); classCode.AppendLine(""); } } for (var i = 0; i < relatedTables.Count; i++) { var columnPK = table.Columns.Where(c => c.IsPK).First().ColumnName; var queryStr = "\"" + columnPK + "='\" + model." + columnPK + " + \"'\""; if (relatedTables[i].Type == enumTableType.Dictionary) { var keyColumn = relatedTables[i].Columns.Where(c => c.IgnoreOnDTO == false && c.IsUniqueKey).FirstOrDefault(); if (keyColumn == null) { _messages.Add(new ProjectConsoleMessages() { erro = true, data = DateTime.Now, mensagem = string.Format("Key Column not found on Dicionary Table [{0}]", relatedTables[i].Name) }); continue; } var valColumn = relatedTables[i].Columns.Where(c => c.IgnoreOnDTO == false && c.IsUniqueKey == false && c.ColumnName != keyColumn.ColumnName).FirstOrDefault(); if (valColumn == null) { _messages.Add(new ProjectConsoleMessages() { erro = true, data = DateTime.Now, mensagem = string.Format("Value Column not found on Dicionary Table [{0}]", relatedTables[i].Name) }); continue; } var varName = "lstDic" + i.ToString("00"); classCode.AppendLine(string.Format("\t\t\tdto.{0}s = new Dictionary<{1}, {2}>();", relatedTables[i].Alias.Replace("DTO", ""), keyColumn.DataType, valColumn.DataType)); classCode.AppendLine(string.Format("\t\t\tvar {0} = _{1}Data.List( new Query({2}) );", varName, relatedTables[i].ModelName, queryStr)); classCode.AppendLine(string.Format("\t\t\tfor( var i=0; i < {0}.Count; i++)", varName)); classCode.AppendLine(string.Format("\t\t\t\tdto.{0}s.Add({1}[i].{2}, {3}[i].{4});", relatedTables[i].Alias.Replace("DTO", ""), varName, keyColumn.ColumnName, varName, valColumn.ColumnName)); classCode.AppendLine(""); } else { var dtoName = "dto" + relatedTables[i].Alias.Replace("DTO", ""); var varName = "lstTemp" + i.ToString("00"); var dtoType = relatedTables[i].Alias; var singleColumnDTO = relatedTables[i].Columns.Where(c => c.IgnoreOnDTO == false).FirstOrDefault(); if (relatedTables[i].Columns.Where(c => c.IgnoreOnDTO == false).Count() == 1) { dtoType = singleColumnDTO.DataType; } classCode.AppendLine(string.Format("\t\t\tdto.{0}s = new List<{1}>();", relatedTables[i].Alias.Replace("DTO", ""), dtoType)); classCode.AppendLine(string.Format("\t\t\tvar {0} = _{1}Data.List( new Query({2}) );", varName, relatedTables[i].ModelName, queryStr)); classCode.AppendLine(string.Format("\t\t\tfor( var i=0; i < {0}.Count; i++)", varName)); classCode.AppendLine("\t\t\t{"); if (relatedTables[i].Columns.Where(c => c.IgnoreOnDTO == false).Count() == 1) { classCode.AppendLine(string.Format("\t\t\t\tdto.{0}s.Add({1}[i].{2});", relatedTables[i].Alias.Replace("DTO", ""), varName, singleColumnDTO.ColumnName)); } else { classCode.AppendLine(string.Format("\t\t\t\tvar {0} = new {1}();", dtoName, relatedTables[i].Alias)); classCode.AppendLine(string.Format("\t\t\t\tUtils.Helper.CopyFromBusiness<{0}, {1}>({2}[i], ref {3});", relatedTables[i].Alias, (relatedTables[i].ModelName + "Model"), varName, dtoName)); classCode.AppendLine(""); LoadRelatedData(dtoName, varName + "[i]", relatedTables[i], tables, ref classCode); classCode.AppendLine(string.Format("\t\t\t\tdto.{0}s.Add({1});", relatedTables[i].Alias.Replace("DTO", ""), dtoName)); } classCode.AppendLine("\t\t\t}"); classCode.AppendLine(""); } } classCode.AppendLine("\t\t}"); classCode.AppendLine(""); #endregion #region By PK var pkColumn = table.Columns.Where(c => c.IsPK).FirstOrDefault(); if (pkColumn != null) { string methodGet = ""; string methodDel = ""; string parameterNames = ""; var pks = table.Columns.Where(c => c.IsPK).ToList(); if (pks != null) { for (var i = 0; i < pks.Count; i++) { methodGet += methodGet != "" ? ", " : ""; methodGet += pks[i].DataType.Replace("?", "") + " " + pks[i].DTOName.ToLowerInvariant(); methodDel += methodDel != "" ? ", " : ""; methodDel += pks[i].DataType.Replace("?", "") + " " + pks[i].DTOName.ToLowerInvariant(); parameterNames += parameterNames != "" ? ", " : ""; parameterNames += pks[i].DTOName.ToLowerInvariant(); } } classCode.AppendLine("\t\tpublic OutputTransport<" + table.Alias + "> Get(" + methodGet + ")"); classCode.AppendLine("\t\t{"); classCode.AppendLine("\t\t\tvar ret = new OutputTransport<" + table.Alias + ">();"); classCode.AppendLine("\t\t\tvar model = _" + table.ModelName + "Data.Get(" + parameterNames + ");"); classCode.AppendLine("\t\t\tif( model == null )"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\tret.code = Parameters.Default.NOTFOUND_CODE;"); classCode.AppendLine("\t\t\t\tret.message = Parameters.Default.NOTFOUND_MESSAGE;"); classCode.AppendLine("\t\t\t\tret.success = false;"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\telse"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\tvar dto = new " + table.Alias + "();"); classCode.AppendLine("\t\t\t\tSwServices.Core.Utils.Helper.CopyFromBusiness<" + table.Alias + ", " + table.ModelName + ">(model, ref dto);"); classCode.AppendLine("\t\t\t\tLoadRelatedData(ref dto);"); classCode.AppendLine("\t\t\t\tret.Data = dto;"); classCode.AppendLine("\t\t\t\tret.success = true;"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\treturn ret;"); classCode.AppendLine("\t\t}"); classCode.AppendLine(""); classCode.AppendLine("\t\tpublic OutputTransport<string> Delete(" + methodDel + ")"); classCode.AppendLine("\t\t{"); classCode.AppendLine("\t\t\tvar ret = new OutputTransport<string>();"); classCode.AppendLine("\t\t\ttry"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\tvar model = _" + table.ModelName + "Data.Get(" + parameterNames + ");"); classCode.AppendLine("\t\t\t\t_" + table.ModelName + "Data.Delete(model);"); classCode.AppendLine("\t\t\t\tret.success = true;"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\tcatch(Exception err)"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\tvar exc = new ExceptionOutputTransport<string>();"); classCode.AppendLine("\t\t\t\texc.Exception = err;"); classCode.AppendLine("\t\t\t\texc.success = false;"); classCode.AppendLine("\t\t\t\texc.code = Parameters.Default.ERR_CODE;"); classCode.AppendLine("\t\t\t\texc.message = string.Format(Parameters.Default.ERR_MESSAGE, err.Message);"); classCode.AppendLine("\t\t\t\tret = exc;"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\treturn ret;"); classCode.AppendLine("\t\t}"); classCode.AppendLine(""); } #endregion By PK #region By Unique Key var uniqueKey = ""; var uniqueQuery = ""; var uniqueKeyColumns = table.Columns.Where(c => c.IsUniqueKey).ToList(); if (uniqueKeyColumns != null) { for (var i = 0; i < uniqueKeyColumns.Count; i++) { uniqueKey += (uniqueKey != "" ? ", " : ""); uniqueKey += uniqueKeyColumns[i].DataType; uniqueKey += " "; uniqueKey += uniqueKeyColumns[i].DTOName; uniqueQuery += uniqueQuery == "" ? "" : " AND "; uniqueQuery += uniqueKeyColumns[i].ColumnName + "='\" + " + uniqueKeyColumns[i].DTOName + " + \"'"; } if (string.IsNullOrEmpty(uniqueKey) == false) { classCode.AppendLine("\t\tpublic OutputTransport<" + table.Alias + "> Get(" + uniqueKey + ")"); classCode.AppendLine("\t\t{"); classCode.AppendLine("\t\t\tvar ret = new OutputTransport<" + table.Alias + ">();"); classCode.AppendLine("\t\t\tvar lst = _" + table.ModelName + "Data.List(new Query(\"" + uniqueQuery + "\"));"); classCode.AppendLine("\t\t\tif( lst != null && lst.Count > 0 )"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\tvar dto = new " + table.Alias + "();"); classCode.AppendLine("\t\t\t\tvar model = lst.First();"); classCode.AppendLine("\t\t\t\tUtils.Helper.CopyFromBusiness<" + table.Alias + ", " + table.ModelName + "Model>(model, ref dto);"); classCode.AppendLine("\t\t\t\tLoadRelatedData(ref dto);"); classCode.AppendLine("\t\t\t\tret.Data = dto;"); classCode.AppendLine("\t\t\t\tret.success = true;"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\telse"); classCode.AppendLine("\t\t\t{"); classCode.AppendLine("\t\t\t\tret.code = Parameters.Default.NOTFOUND_CODE;"); classCode.AppendLine("\t\t\t\tret.message = Parameters.Default.NOTFOUND_MESSAGE;"); classCode.AppendLine("\t\t\t\tret.success = false;"); classCode.AppendLine("\t\t\t}"); classCode.AppendLine("\t\t\treturn ret;"); classCode.AppendLine("\t\t}"); classCode.AppendLine(""); } } #endregion By Unique Key classCode.AppendLine("\t}"); classCode.AppendLine(""); classCode.AppendLine(""); #endregion BaseClass #region Business Class classCode.AppendLine("\tpublic class " + table.Alias.Replace("DTO", "") + ": " + className + ""); classCode.AppendLine("\t{"); #region Construtor classCode.AppendLine("\t\t#region Construtor"); classCode.AppendLine(string.Format("\t\tpublic {0}({1}) : base({2})", table.Alias.Replace("DTO", ""), ("" + constructorParameters), baseConstructorParam)); classCode.AppendLine("\t\t{"); classCode.AppendLine("\t\t}"); classCode.AppendLine("\t\t#endregion Construtor"); classCode.AppendLine(""); #endregion Construtor classCode.AppendLine("\t}"); classCode.AppendLine(""); classCode.AppendLine(""); #endregion Business Class classCode.AppendLine("}"); return(classCode.ToString()); }
static string TableKey(TableModel table) => TableKey(table.Name, table.SchemaName);
private void InitFrm() { try { #region MyRegion tableModel = BLLFactory.Instance.idb.GetTableModel(tableName, Utils.dbName); for (int i = 0; i < tableModel.Columns.Count; i++) { TableColumn column = tableModel.Columns[i]; chk_CheckFepeat.Items.Add(new SandData(column.ColumnNameRemark, column), true); chk_CheckFields.Items.Add(new SandData(column.ColumnNameRemark, column), true); chk_EditShow.Items.Add(new SandData(column.ColumnNameRemark, column), true); chk_SelectWhere.Items.Add(new SandData(column.ColumnNameRemark, column), true); chk_ShowFields.Items.Add(new SandData(column.ColumnNameRemark, column), true); } List<TableModel> tmList = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName); cmb_Tables.DataSource = tmList; cmb_Tables.DisplayMember = "TableName"; cmb_Tables.ValueMember = "TableName"; //Grid列 WinFromComplexBuild build = new WinFromComplexBuild(); richTextBox1.Text = build.GetGridColumn(Utils.dbName, tableModel.Columns); //DataTable列 StringBuilder list = new StringBuilder(); string famt = @" this.entityFrm1.AddColumnAlias(""{0}"", ""{1}"", {2});"; foreach (var item in tableModel.Columns) { string proStr = item.ColumnType; string property = item.ColumnName; string propertyinfo = item.ColumnRemark; if (propertyinfo.Length == 0) propertyinfo = property; if (property.ToLower().Equals("id") || property.ToLower().Equals("isdeleted")) { list.AppendLine(string.Format(famt, property, propertyinfo, "false")); } else { list.AppendLine(string.Format(famt, property, propertyinfo, "true")); } } richTextBox2.Text = list.ToString(); //Entity EntityFrameworkBuild bb = new EntityFrameworkBuild(); string context= bb.BuildEntity("", tableModel, null); richTextBox3.Text = context; #endregion } catch { } }
/// <summary> /// This row of data has been updated. /// </summary> public TableModelEvent(TableModel @source, int @row) { }
public HeapCellDistributionCustomComparerDouble(TableModel aModel, int aColumn, SortOrder aSortOrder) : base(aModel, aColumn, aSortOrder) { }
public static JPanel createTablePanel(TableModel model) { JPanel.__\u003Cclinit\u003E(); JPanel jpanel = new JPanel((LayoutManager) new BorderLayout()); JTable jtable = new JTable(model); for (int index = 0; index < model.getColumnCount(); ++index) { TableColumn column = jtable.getColumnModel().getColumn(index); if (Object.instancehelper_equals((object) model.getColumnClass(index), RefineryUtilities.class\u0024java\u0024lang\u0024Number != null ? (object) RefineryUtilities.class\u0024java\u0024lang\u0024Number : (object) (RefineryUtilities.class\u0024java\u0024lang\u0024Number = RefineryUtilities.class\u0024("java.lang.Number")))) column.setCellRenderer((TableCellRenderer) new NumberCellRenderer()); } ((Container) jpanel).add((Component) new JScrollPane((Component) jtable)); return jpanel; }
/// <summary> /// Constructs a <code>JTable</code> that is initialized with /// <code>dm</code> as the data model, <code>cm</code> /// as the column model, and a default selection model. /// </summary> public JTable(TableModel @dm, TableColumnModel @cm) { }
/// <summary> /// Constructs a <code>JTable</code> that is initialized with /// <code>dm</code> as the data model, <code>cm</code> as the /// column model, and <code>sm</code> as the selection model. /// </summary> public JTable(TableModel @dm, TableColumnModel @cm, ListSelectionModel @sm) { }
/// <summary> /// Constructs a <code>JTable</code> that is initialized with /// <code>dm</code> as the data model, a default column model, /// and a default selection model. /// </summary> public JTable(TableModel @dm) { }
/// <summary> /// Sets the data model for this table to <code>newModel</code> and registers /// with it for listener notifications from the new data model. /// </summary> public void setModel(TableModel @dataModel) { }
private static string ColumnKey(TableModel table, string columnName) => TableKey(table) + ".[" + columnName + "]";
private void button3_Click(object sender, EventArgs e) { TableModel.Delete(num); TableModel.ShowTable(dataGridView1); }
/// <summary> /// Initializes a new instance of the <see cref="TableViewModel"/> class. /// </summary> public TableViewModel(TableModel table) { Argument.IsNotNull("table", table); Table = table; }
internal static string ClassName(this TableModel model) { return(model.Name.ClassName()); }
public BoxScoreDefenseRecord(int record, TableModel tableModel, EditorModel EditorModel) : base(record, tableModel, EditorModel) { }
/// <summary> /// The data in rows [<I>firstRow</I>, <I>lastRow</I>] have been updated. /// </summary> public TableModelEvent(TableModel @source, int @firstRow, int @lastRow) { }
public Object EditAuditSave(string parameters) { TableModel model = JsonConvert.DeserializeObject <TableModel>(parameters); using (DBHelper db = new DBHelper()) { //检查是否已经审核过 if (model.content["auditorid"] != null) { return(new { message = StringHelper.GetString("单据已经审核过,不能修改!") }); } //检查是否已经开账 var options = db.First("select * from option"); if (options.content["initoverdate"] == null) { return(new { message = StringHelper.GetString("系统还没有开账,不能保存单据!") }); } //单据日期不能早于开账日期 if (model.content.Value <DateTime>("billdate").CompareTo(options.content.Value <DateTime>("initoverdate")) < 0) { return(new { message = StringHelper.GetString("单据日期不能早于开账日期!") }); } //单据日期不能早于月结存日期 var lastbalance = db.FirstOrDefault("select * from monthbalance order by id desc"); if (lastbalance != null && model.content.Value <DateTime>("billdate").CompareTo(lastbalance.content.Value <DateTime>("balancedate")) <= 0) { return(new { message = StringHelper.GetString("单据日期不能早于月结存日期!") }); } //检查编号重复 int cnt = db.Count("select count(0) as cnt from bill where id<>" + model.id + " and content->>'billname'='" + billname + "' and content->>'billcode'='" + model.content.Value <string>("billcode") + "'"); if (cnt > 0) { return(new { message = StringHelper.GetString("编号有重复") }); } foreach (var item in model.content.Value <JArray>("details").Values <JObject>()) { item.Remove("product"); } //model.content["billname"] = billname; model.content["makerid"] = PluginContext.Current.Account.Id; //model.content["createtime"] = DateTime.Now; model.content["auditorid"] = PluginContext.Current.Account.Id; model.content["audittime"] = DateTime.Now; model.content["auditstatus"] = 1; string result = model.Audit(db); if (!string.IsNullOrEmpty(result)) { return new { message = result } } ; db.SaveChanges(); } return(new { message = "ok", id = model.id }); }
private static string TableKey(TableModel table) => TableKey(table.Name);
/// <summary> /// 工资专户显示数据源 /// </summary> /// <param name="form"></param> /// <returns></returns> public ActionResult GetPaySoure(FormCollection form) { TableModel model = operateContext.bllSession.T_PayAccount.GetPageViewSoure(form); return(Json(model, JsonRequestBehavior.AllowGet)); }
void Instance_OnGameTablePlayerMoveEvent(UserModel user, TableModel oldTable, TableModel newTable) { //Jeśli zmiana uzytkownika dotyczy zalogowanego uzytkownika if (user.ID == Session.Data.User.ID) { //Jeśli zmiana stołu dotyczy tego okna if (oldTable.ID == TableModel.ID) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { AddMessageLine(null, "Przeniesiono Cię do stołu: " + newTable.Name); //Odłączamy stare eventy od stołu gry i czyscimy okno stolu do gry this.GameTable.Clear(); //Rejestrujemy nowy stół this.TableModel = newTable; //Inicjalizujemy nowy stół do gry this.InitializeGameTable(); })); } } }
/// <summary> /// Initializes a new instance of the TableModelEventArgs class with /// the specified TableModel source, start index, end index and affected Column /// </summary> /// <param name="source">The TableModel that originated the event</param> public TableModelEventArgs(TableModel source) : this(source, null, -1, -1) { }
/// <summary> /// 载入数据表到表格控件中 /// </summary> /// <param name="table"></param> /// <param name="dt"></param> public static void LoadDataTable(Table table, DataTable dt) { if (table.ColumnModel == null) { table.ColumnModel = new ColumnModel(); ColumnModel columnModel = table.ColumnModel; foreach (DataColumn dc in dt.Columns) { switch (dc.DataType.Name.ToLower()) { case "string": columnModel.Columns.Add(new TextColumn(dc.ColumnName, dc.DataType)); break; case "boolean": columnModel.Columns.Add(new CheckBoxColumn(dc.ColumnName, dc.DataType)); break; case "datetime": columnModel.Columns.Add(new DateTimeColumn(dc.ColumnName, dc.DataType)); break; case "image": columnModel.Columns.Add(new ImageColumn(dc.ColumnName, dc.DataType)); break; case "int32": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "uint32": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "int16": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "uint16": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "byte": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "sbyte": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "int64": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "uint64": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "single": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "double": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "decimal": columnModel.Columns.Add(new NumberColumn(dc.ColumnName, dc.DataType)); break; case "color": columnModel.Columns.Add(new ColorColumn(dc.ColumnName, dc.DataType)); break; default: //columnModel.Columns.Add(new ProgressBarColumn(dc.ColumnName, dc.DataType)); //columnModel.Columns.Add(new ButtonColumn(dc.ColumnName, dc.DataType)); //columnModel.Columns.Add(new ComboBoxColumn(dc.ColumnName, dc.DataType)); break; } } } if (dt.Columns.Count != table.ColumnModel.Columns.Count) { throw new Exception("DataTable的列数跟KellTable的列数不一致!"); } if (table.TableModel == null) { table.TableModel = new TableModel(); TableModel tableModel = table.TableModel; foreach (DataRow dr in dt.Rows) { List <Cell> cells = new List <Cell>(); foreach (DataColumn dc in dt.Columns) { switch (dc.DataType.Name.ToLower()) { case "string": cells.Add(new Cell(dr[dc].ToString())); break; case "boolean": cells.Add(new Cell(dr[dc].ToString(), Convert.ToBoolean(dr[dc]))); break; case "datetime": cells.Add(new Cell(dr[dc])); break; case "image": cells.Add(new Cell("", (Image)dr[dc])); break; case "int32": case "uint32": case "int16": case "uint16": case "byte": case "sbyte": case "int64": case "uint64": case "single": case "double": case "decimal": cells.Add(new Cell(dr[dc])); break; case "color": cells.Add(new Cell("", (Color)dr[dc])); break; } } Row row = new Row(cells.ToArray()); tableModel.Rows.Add(row); } } else { TableModel tableModel = table.TableModel; if (dt.Rows.Count < tableModel.Rows.Count) { for (int i = dt.Rows.Count; i < tableModel.Rows.Count; i++) { tableModel.Rows.RemoveAt(i); } } for (int j = 0; j < dt.Rows.Count; j++) { DataRow dr = dt.Rows[j]; if (j > tableModel.Rows.Count - 1) { List <Cell> cells = new List <Cell>(); foreach (DataColumn dc in dt.Columns) { switch (dc.DataType.Name.ToLower()) { case "string": cells.Add(new Cell(dr[dc].ToString())); break; case "boolean": cells.Add(new Cell(dr[dc].ToString(), Convert.ToBoolean(dr[dc]))); break; case "datetime": cells.Add(new Cell(dr[dc])); break; case "image": cells.Add(new Cell("", (Image)dr[dc])); break; case "int32": case "uint32": case "int16": case "uint16": case "byte": case "sbyte": case "int64": case "uint64": case "single": case "double": case "decimal": cells.Add(new Cell(dr[dc])); break; case "color": cells.Add(new Cell("", (Color)dr[dc])); break; } Row row = new Row(cells.ToArray()); tableModel.Rows.Add(row); } } else { Row row = tableModel.Rows[j]; for (int i = 0; i < dt.Columns.Count; i++) { DataColumn dc = dt.Columns[i]; switch (dc.DataType.Name.ToLower()) { case "string": row.Cells[i].Text = dr[dc].ToString(); break; case "boolean": row.Cells[i].Text = dr[dc].ToString(); row.Cells[i].Checked = Convert.ToBoolean(dr[dc]); break; case "datetime": row.Cells[i].Data = dr[dc]; break; case "image": row.Cells[i].Image = (Image)dr[dc]; break; case "int32": case "uint32": case "int16": case "uint16": case "byte": case "sbyte": case "int64": case "uint64": case "single": case "double": case "decimal": row.Cells[i].Data = dr[dc]; break; case "color": row.Cells[i].Data = dr[dc]; break; } } } } } }
/// <summary> /// Initializes a new instance of the TableModelEventArgs class with /// the specified TableModel source, start index, end index and affected Column /// </summary> /// <param name="source">The TableModel that originated the event</param> /// <param name="fromIndex">The start index of the affected Row(s)</param> /// <param name="toIndex">The end index of the affected Row(s)</param> public TableModelEventArgs(TableModel source, int fromIndex, int toIndex) : this(source, null, fromIndex, toIndex) { }
static string ColumnKey(TableModel table, string columnName) => $"{TableKey(table)}.\"{columnName}\"";
/// <summary> /// Initializes a new instance of the DateTimeComparer class with the specified /// TableModel, Column index and SortOrder /// </summary> /// <param name="tableModel">The TableModel that contains the data to be sorted</param> /// <param name="column">The index of the Column to be sorted</param> /// <param name="sortOrder">Specifies how the Column is to be sorted</param> public DateTimeComparer(TableModel tableModel, int column, SortOrder sortOrder) : base(tableModel, column, sortOrder) { }
public CareerStatsOffenseRecord(int record, TableModel tableModel, EditorModel EditorModel) : base(record, tableModel, EditorModel) { }
/// <summary> /// 验证表 /// </summary> public static void Check(DataQuery item, string tableName, List <PropertyInfo> listInfo, List <Attribute> listAttribute) { try { if (item.Config.DesignModel == FastData.Base.Config.CodeFirst) { var table = new TableModel(); if (IsExistsTable(item, tableName)) { //存在表 table = GetTable(item, tableName); var model = PropertyCache.GetAttributesColumnInfo(tableName, listInfo); if (model.Count >= table.Column.Count) { model.ForEach(p => { var info = table.Column.Find(a => string.Compare(a.Name, p.Name, true) == 0) ?? new ColumnModel(); var result = CheckModel.CompareTo(info, p); if (result.IsUpdate) { UpdateTable(item, result, tableName); } }); } else { var tempColumn = new List <ColumnModel>(); tempColumn = table.Column; tempColumn.ForEach(p => { var info = table.Column.Find(a => string.Compare(a.Name, p.Name, true) == 0) ?? new ColumnModel(); var result = CheckModel.CompareTo(p, info); if (result.IsUpdate) { UpdateTable(item, result, tableName); } if (result.IsDelete) { UpdateTable(item, result, tableName); } }); table.Column = model; } var comments = PropertyCache.GetAttributesTableInfo(listAttribute); if (table.Comments != comments) { table.Comments = comments; UpdateComments(item, table.Comments, tableName); } } else { table.Column = PropertyCache.GetAttributesColumnInfo(tableName, listInfo); table.Name = tableName; table.Comments = PropertyCache.GetAttributesTableInfo(listAttribute); AddTable(item, table.Column, tableName); UpdateComments(item, table.Comments, tableName); } } } catch (Exception ex) { if (FastMap.fastAop != null) { var context = new ExceptionContext(); context.ex = ex; context.name = "Code First table : " + tableName; context.type = AopType.CodeFirst; FastMap.fastAop.Exception(context); } if (string.Compare(item.Config.SqlErrorType, SqlErrorType.Db, true) == 0) { DbLogTable.LogException(item.Config, ex, string.Format("Check_{0}", tableName), ""); } else { DbLog.LogException(item.Config.IsOutError, item.Config.DbType, ex, string.Format("Check_{0}", tableName), ""); } } }
public demoTable() { InitializeComponent(); TableModel.ShowTable(dataGridView1); }
/// <summary> /// 获取表结构 /// </summary> private static TableModel GetTable(DataQuery item, string tableName) { var result = new TableModel(); result.Column = result.Column ?? new List <ColumnModel>(); using (var db = new DataContext(item.Key)) { var param = new List <DbParameter>(); if (item.Config.DbType == DataDbType.Oracle) { #region oracle //参数 var tempParam = DbProviderFactories.GetFactory(item.Config.ProviderName).CreateParameter(); tempParam.ParameterName = "name"; tempParam.Value = tableName.ToUpper(); param.Add(tempParam); //表 var sql = "select a.table_name,comments from user_tables a inner join user_tab_comments b on a.TABLE_NAME = b.TABLE_NAME and a.table_name = :name"; var dic = db.ExecuteSqlList(sql, param.ToArray(), item.Config.IsOutSql, false).DicList[0]; result.Name = dic.GetValue("table_name").ToStr(); result.Comments = dic.GetValue("comments").ToStr(); //列 sql = string.Format(@"select a.column_name,data_type,data_length,b.comments, (select count(0) from user_cons_columns aa, user_constraints bb where aa.constraint_name = bb.constraint_name and bb.constraint_type = 'P' and bb.table_name = :name and aa.column_name = a.column_name) iskey, nullable,data_precision,data_scale from user_tab_columns a inner join user_col_comments b on a.table_name =:name and a.table_name = b.table_name and a.column_name = b.column_name order by a.column_id asc"); var dicList = db.ExecuteSqlList(sql, param.ToArray(), item.Config.IsOutSql, false).DicList; foreach (var temp in dicList) { var model = new ColumnModel(); model.Comments = temp.GetValue("comments").ToStr(); model.DataType = temp.GetValue("data_type").ToStr(); model.IsKey = temp.GetValue("iskey").ToStr() == "1" ? true : false; model.IsNull = temp.GetValue("nullable").ToStr() == "Y" ? true : false; model.Length = temp.GetValue("data_length").ToStr().ToInt(0); model.Name = temp.GetValue("column_name").ToStr(); model.Precision = temp.GetValue("data_precision").ToStr().ToInt(0); model.Scale = temp.GetValue("data_scale").ToStr().ToInt(0); result.Column.Add(model); } #endregion } if (item.Config.DbType == DataDbType.MySql) { #region MySql //参数 var tempParam = DbProviderFactories.GetFactory(item.Config.ProviderName).CreateParameter(); tempParam.ParameterName = "name"; tempParam.Value = tableName.ToUpper(); param.Add(tempParam); //表 var sql = "select table_name,table_comment count from information_schema.tables where upper(table_name)=?name"; var dic = db.ExecuteSqlList(sql, param.ToArray(), item.Config.IsOutSql, false).DicList[0]; result.Name = dic.GetValue("table_name").ToStr(); result.Comments = dic.GetValue("table_comment").ToStr(); //列 sql = string.Format(@"select column_name,data_type,character_maximum_length,column_comment, (select count(0) from INFORMATION_SCHEMA.KEY_COLUMN_USAGE a where upper(TABLE_NAME)=?name and constraint_name='PRIMARY' and c.column_name=a.column_name) iskey, is_nullable,numeric_precision,numeric_scale from information_schema.columns c where upper(table_name)=?name order by ordinal_position asc"); var dicList = db.ExecuteSqlList(sql, param.ToArray(), item.Config.IsOutSql, false).DicList ?? new List <Dictionary <string, object> >(); foreach (var temp in dicList) { var model = new ColumnModel(); model.Comments = temp.GetValue("column_comment").ToStr(); model.DataType = temp.GetValue("data_type").ToStr(); model.IsKey = temp.GetValue("iskey").ToStr() == "1" ? true : false; model.IsNull = temp.GetValue("is_nullabl").ToStr() == "YES" ? true : false; model.Length = temp.GetValue("character_maximum_length").ToStr().ToInt(0); model.Name = temp.GetValue("column_name").ToStr(); model.Precision = temp.GetValue("numeric_precision").ToStr().ToInt(0); model.Scale = temp.GetValue("numeric_scale").ToStr().ToInt(0); result.Column.Add(model); } #endregion } if (item.Config.DbType == DataDbType.SqlServer) { #region SqlServer //参数 var tempParam = DbProviderFactories.GetFactory(item.Config.ProviderName).CreateParameter(); tempParam.ParameterName = "name"; tempParam.Value = tableName.ToUpper(); param.Add(tempParam); //表 var sql = "select name,(select top 1 value from sys.extended_properties where major_id=object_id(a.name) and minor_id=0) as value from sys.objects a where type = 'U'and upper(name) = @name"; var dic = db.ExecuteSqlList(sql, param.ToArray(), item.Config.IsOutSql, false).DicList[0]; result.Name = dic.GetValue("name").ToStr(); result.Comments = dic.GetValue("value").ToStr(); //列 sql = string.Format(@"select a.name,(select top 1 name from sys.systypes c where a.xtype=c.xtype) as type , length,b.value,(select count(0) from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME='@name' and COLUMN_NAME=a.name) as iskey, isnullable,prec,scale from syscolumns a left join sys.extended_properties b on major_id = id and minor_id = colid and b.name ='MS_Description' where a.id=object_id('@name') order by a.colid asc"); var dicList = db.ExecuteSqlList(sql, param.ToArray(), item.Config.IsOutSql, false).DicList; foreach (var temp in dicList) { var model = new ColumnModel(); model.Comments = temp.GetValue("value").ToStr(); model.DataType = temp.GetValue("type").ToStr(); model.IsKey = temp.GetValue("iskey").ToStr() == "1" ? true : false; model.IsNull = temp.GetValue("isnullable").ToStr() == "1" ? true : false; model.Length = temp.GetValue("length").ToStr().ToInt(0); model.Name = temp.GetValue("name").ToStr(); model.Precision = temp.GetValue("prec").ToStr().ToInt(0); model.Scale = temp.GetValue("scale").ToStr().ToInt(0); result.Column.Add(model); } #endregion } } result.Column.ForEach(a => { if (string.Compare(a.DataType, "nchar", true) == 0 || string.Compare(a.DataType, "nvarchar", true) == 0 || string.Compare(a.DataType, "nvarchar2", true) == 0 || string.Compare(a.DataType, "ntext", true) == 0 || string.Compare(a.DataType, "nclob", true) == 0) { a.Length = a.Length / 2; } }); return(result); }
private void OnReceiveBill(TableModel selectedTable) { SelectedTable = selectedTable; }
public TableModel initNormalTable() { TableModel model = new TableModel(); model.getTitles().add(new Title(null, null, "Name", null, null, 0)); model.getTitles().add(new Title(null, null, "Card.", null, null, 0)); model.getTitles().add(new Title(null, null, "Type", null, null, 100)); model.getTitles().add(new Title(null, null, "Description & Constraints", null, null, 0)); return model; }
/// <summary> /// Complete sync entity /// </summary> /// <param name="tableModel"></param> /// <param name="table"></param> private async Task SyncEntityFieldsAsync(SynchronizeTableViewModel tableModel, TableModel table) { var resultModel = await _context.Table .AsNoTracking() .Include(x => x.TableFields) .FirstOrDefaultAsync(x => x.Id == table.Id); if (resultModel == null) { return; } { if (tableModel.IsStaticFromEntityFramework) { await SyncEntityFromEntityFramework(tableModel, resultModel.Id); } else { var fieldTypeList = _context.TableFieldTypes.ToList(); var fieldConfigList = _context.TableFieldConfigs.ToList(); foreach (var item in tableModel.Fields) { foreach (var configViewModel in item.Configurations) { configViewModel.Name = fieldConfigList.FirstOrDefault(x => x.Code == configViewModel.ConfigCode)?.Name; if (configViewModel.ConfigCode != "9999") { continue; } if (configViewModel.Value == "systemcore") { configViewModel.Value = table.EntityType; } } var insertField = _tablesService.AddFieldSql(item, tableModel.Name, _connectionString, true, table.EntityType); // Save field model in the dataBase if (!insertField.Result) { continue; } { var configValues = new List <TableFieldConfigValue>(); var tableFieldType = fieldTypeList.FirstOrDefault(x => x.Code == item.TableFieldCode); if (tableFieldType == null) { continue; } var model = new TableModelField { DataType = item.DataType, TableId = resultModel.Id, Description = item.Description, Name = item.Name, DisplayName = item.DisplayName, AllowNull = item.AllowNull, Synchronized = true, TableFieldTypeId = tableFieldType.Id }; foreach (var configItem in item.Configurations) { var config = fieldConfigList.FirstOrDefault(x => x.Code == configItem.ConfigCode); if (config == null) { continue; } configValues.Add(new TableFieldConfigValue { TableFieldConfigId = config.Id, TableModelFieldId = model.Id, Value = configItem.Value, }); } model.TableFieldConfigValues = configValues; _context.TableFields.Add(model); var dbResult = await _context.SaveAsync(); if (!dbResult.IsSuccess) { Debug.WriteLine(dbResult.Errors); } } } } } }
public TableVertex(TableModel model) { Text = model.Name; Model = model; }
/// <summary> /// The cells from (firstRow, column) to (lastRow, column) have been changed. /// </summary> public TableModelEvent(TableModel @source, int @firstRow, int @lastRow, int @column, int @type) { }
/// <summary> /// Executes an Insert of multiple entities into this class' table. /// </summary> /// <param name="tableModels">A collection of entities of this class</param> /// <param name="transaction">An active MySqlTransaction to execute the Insert statement against</param> /// <returns>Returns a boolean value indicating whether the insertion was successful or not</returns> public static bool GroupInsert <T>(this IEnumerable <T> tableModels, MySqlTransaction transaction) where T : TableModel <T>, new() { return(TableModel <T> .GroupInsert(tableModels, transaction)); }
public static TreeView PropertiesTreeView(TableModel model) { var tree = new TreeView(); var folderUri = GetUriString("Images/folder.png"); if (model.Columns != null) { tree.Items.Add(GetColumnItem(model.Columns, folderUri)); } if (model.Keys != null) { tree.Items.Add(GetKeyItem(model.Keys, folderUri)); } if (model.Trigers != null) { tree.Items.Add(GetTriggerItem(model.Trigers, folderUri)); } if (model.Indexes != null) { tree.Items.Add(GetIndexItem(model.Indexes, folderUri)); } return tree; }
/// <summary> /// Executes an Insert of multiple entities into this class' table. /// </summary> /// <param name="tableModels">A collection of entities of this class</param> /// <returns>Returns a boolean value indicating whether the insertion was successful or not</returns> public static async Task <bool> GroupInsertAsync <T>(this IEnumerable <T> tableModels) where T : TableModel <T>, new() { return(await TableModel <T> .GroupInsertAsync(tableModels)); }
public string ApplyTemplate(TableModel table, List <TableModel> tables = null, string textToAppend = null) { _messages.Add(new ProjectConsoleMessages() { erro = false, data = DateTime.Now, mensagem = string.Format("{0} - Processando Tabela [{1}]", this.CommandID, table.Name) }); _fileName = "WidgetsController"; _directoryName = this.ProjectName + ".Web\\Views\\Widgets"; StringBuilder classCode = new StringBuilder(); StringBuilder variablesCode = new StringBuilder(); StringBuilder constructorAssignCode = new StringBuilder(); StringBuilder constructorParamCode = new StringBuilder(); classCode.AppendLine("// GET: Widget"); classCode.AppendLine("using System;"); classCode.AppendLine("using System.Collections.Generic;"); classCode.AppendLine("using System.Linq;"); classCode.AppendLine("using System.Web;"); classCode.AppendLine("using System.Web.Mvc;"); classCode.AppendLine("using SwServices.Common.Business;"); classCode.AppendLine("using Light;"); classCode.AppendLine(string.Format("using {0}.Data.Models;", this.NameSpace)); classCode.AppendLine(string.Format("using {0}.Common.DTOs;", this.NameSpace)); classCode.AppendLine(string.Format("using {0}.Common.Business;", this.NameSpace)); classCode.AppendLine(""); classCode.AppendLine("namespace " + this.NameSpace + ".Web.Controllers"); classCode.AppendLine("{"); classCode.AppendLine("\tpublic class WidgetsController : Controller"); classCode.AppendLine("\t{"); classCode.AppendLine("\t"); classCode.AppendLine("\t#region Variaveis Membro"); classCode.AppendLine("[VARIAVEIS]"); classCode.AppendLine("\t#endregion Variaveis Membro"); classCode.AppendLine("\t"); classCode.AppendLine("\tpublic WidgetsController([CONSTRUTOR_PARAMETROS])"); classCode.AppendLine("\t{"); classCode.AppendLine("[CONSTRUTOR_ASSIGN]"); classCode.AppendLine("\t}"); classCode.AppendLine("\t"); List <string> dependencies = new List <string>(); foreach (TableModel tbl in tables) { bool processar = false; if (tbl.MainDTO) { processar = true; } else if (tbl.Type != enumTableType.Relation_1_To_N) { for (var i = 0; i < tables.Count; i++) { if (tables[i].Columns.Where(c => c.RelatedTable == table.Name && c.SelectionType == enumSelectionType.SearchModal).Count() > 0) { processar = true; break; } } } if (tbl.Type == enumTableType.Relation_1_To_N) { if (tbl.Columns.Where(c => c.IgnoreOnDTO == false).Count() > 1) { processar = true; } } if (tbl.MainDTO) { string controller = tbl.Alias.Replace("DTO", "") + "SearchWidget"; string service = controller + "Service"; variablesCode.AppendLine("\tprotected I{0} _{0}BS = null;".Replace("{0}", tbl.Alias.Replace("DTO", ""))); constructorParamCode.Append(constructorParamCode.ToString() == "" ? "" : ", "); constructorParamCode.Append("I{0} i{0}".Replace("{0}", tbl.Alias.Replace("DTO", ""))); constructorAssignCode.AppendLine("\t_{0}BS = i{0};".Replace("{0}", tbl.Alias.Replace("DTO", ""))); dependencies.Add("I{0}".Replace("{0}", tbl.Alias.Replace("DTO", ""))); classCode.AppendLine("\t\t[HttpGet]"); classCode.AppendLine("\t\tpublic ActionResult " + controller + "()"); classCode.AppendLine("\t\t{"); var columns = tbl.Columns.Where(c => string.IsNullOrEmpty(c.RelatedTable) == false && c.SelectionType == enumSelectionType.ComboBox).ToList(); for (var i = 0; i < columns.Count; i++) { var relatedTable = tables.Where(t => t.Name == columns[i].RelatedTable).Single(); classCode.AppendLine("\t\t\tvar result" + i.ToString("00") + " = _" + relatedTable.Alias.Replace("DTO", "") + "BS.Search(new Criteria" + relatedTable.Alias + "() {});"); classCode.AppendLine("\t\t\tViewBag.LST_" + relatedTable.Alias + " = result" + i.ToString("00") + ".Data;"); } classCode.AppendLine("\t\t\treturn View();"); classCode.AppendLine("\t\t}"); classCode.AppendLine(""); classCode.AppendLine(""); classCode.AppendLine("\t\t//[Authorize]"); classCode.AppendLine("\t\t[HttpPost]"); classCode.AppendLine("\t\tpublic ActionResult " + controller + "(Criteria" + tbl.Alias + " model, int currentPage = 1, int pageSize = 10)"); classCode.AppendLine("\t\t{"); classCode.AppendLine("\t\t\tvar result = _" + tbl.Alias.Replace("DTO", "") + "BS.Search(model, currentPage, pageSize);"); classCode.AppendLine("\t\t\treturn Content(Newtonsoft.Json.JsonConvert.SerializeObject(result), \"application /json\");"); //htmlCode.AppendLine("\t\t\treturn new JsonResult() { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet };"); classCode.AppendLine("\t\t}"); } } classCode.AppendLine(""); classCode.AppendLine(""); classCode.AppendLine("\t}"); classCode.AppendLine("}"); return(classCode.ToString().Replace("[CONSTRUTOR_PARAMETROS]", constructorParamCode.ToString()).Replace("[CONSTRUTOR_ASSIGN]", constructorAssignCode.ToString()).Replace("[VARIAVEIS]", variablesCode.ToString())); }
public XhtmlNode generate(TableModel model) throws Exception {
/// <summary> /// Executes an Insert of multiple entities into this class' table. /// </summary> /// <param name="tableModels">A collection of entities of this class</param> /// <returns>Returns a boolean value indicating whether the insertion was successful or not</returns> public static bool GroupInsert <T>(this IEnumerable <T> tableModels) where T : TableModel <T>, new() { return(TableModel <T> .GroupInsert(tableModels)); }
/// <summary> /// Executes an Insert of multiple entities into this class' table. /// </summary> /// <param name="tableModels">A collection of entities of this class</param> /// <param name="transaction">An active MySqlTransaction to execute the Insert statement against</param> /// <returns>Returns a boolean value indicating whether the insertion was successful or not</returns> public static async Task <bool> GroupInsertAsync <T>(this IEnumerable <T> tableModels, MySqlTransaction transaction) where T : TableModel <T>, new() { return(await TableModel <T> .GroupInsertAsync(tableModels, transaction)); }
/// <summary> /// All row data in the table has changed, listeners should discard any state /// that was based on the rows and requery the <code>TableModel</code> /// to get the new row count and all the appropriate values. /// </summary> public TableModelEvent(TableModel @source) { }
private void saveCode(TableModel tm, BuildType buildtype) { if (!string.IsNullOrEmpty(this.txtOutPut.Text)) { switch (buildtype) { case BuildType.WebBuild: BuildHelper.FactoryBuild(BuildType.WebBuild).Library(this.txtOutPut.Text, tm, this.progressBar2); break; case BuildType.WPFBuild: BuildHelper.FactoryBuild(BuildType.WPFBuild).Library(this.txtOutPut.Text, tm, this.progressBar2); break; case BuildType.EntityFrameworkBuild: BuildHelper.FactoryBuild(BuildType.EntityFrameworkBuild).Library(this.txtOutPut.Text, tm, this.progressBar2); break; } } }
/// <summary> /// Generates a table with a random number of tables. /// </summary> /// <param name="name">The name of the table.</param> /// <returns>Generated <see cref="TableModel"/>.</returns> public static TableModel GenerateTable(string name) { var table = new TableModel(name); return table; }
/// <summary> /// Initializes a new instance of the ColumnCollectionEditor class /// using the specified collection type /// </summary> /// <param name="type">The type of the collection for this editor to edit</param> public ColumnCollectionEditor(Type type) : base(type) { this.columns = null; this.previewColumnModel = new ColumnModel(); this.previewColumnModel.Columns.Add(new TextColumn("Column", 116)); this.previewTableModel = new TableModel(); this.previewTableModel.Rows.Add(new Row()); Cell cell = new Cell(); cell.Editable = false; cell.ToolTipText = "This is a Cell ToolTip"; this.previewTableModel.Rows[0].Cells.Add(cell); this.previewTableModel.RowHeight = 20; this.previewTable = new Table(); this.previewTable.Preview = true; this.previewTable.Size = new Size(120, 274); this.previewTable.Location = new Point(246, 24); this.previewTable.GridLines = GridLines.Both; this.previewTable.TabStop = false; this.previewTable.EnableToolTips = true; this.previewTable.ColumnModel = this.previewColumnModel; this.previewTable.TableModel = this.previewTableModel; this.previewLabel = new Label(); this.previewLabel.Text = "Preview:"; this.previewLabel.Size = new Size(140, 16); this.previewLabel.Location = new Point(247, 8); }