public void SetDefaults() { if (string.IsNullOrEmpty(this.title) && !string.IsNullOrEmpty(this.entity)) { this.title = EvoTC.ToUpperLowers(this.entity); } if (string.IsNullOrEmpty(this.dbcolumnpk)) { this.dbcolumnpk = "ID"; } if (string.IsNullOrEmpty(this.dbtableusers)) { this.dbtableusers = "EVOL_USER"; } if (string.IsNullOrEmpty(this.dbtablecomments)) { this.dbtablecomments = "evol_comment"; } if (string.IsNullOrEmpty(this.dbcolumncomments)) { this.dbcolumncomments = "itemid"; } if (string.IsNullOrEmpty(this.dbcolumnuserid)) { this.dbcolumnuserid = "userID"; } }
private string HTMLrecordCount(int TotalNbRecords, int MaxLoopSQL) { if ((TotalNbRecords > MaxLoopSQL + 1) || pageID > 1) { string htmlRecCount = null; int i = ((pageID - 1) * _RowsPerPage) + 1; if (MaxLoopSQL == 0) { htmlRecCount = string.Format("{0} {1}", EvoTC.ToUpperLowers(def_Data.entity), i); } else { htmlRecCount = string.Format("{0} {1}{2}{3}", EvoTC.ToUpperLowers(def_Data.entities), i, HTML_Sep, (i + MaxLoopSQL)); } htmlRecCount += EvoLang.sOf + TotalNbRecords.ToString(); return(htmlRecCount); } else { switch (MaxLoopSQL) { case -1: return(string.Empty); case 0: return(string.Format("1 {0}", def_Data.entity)); default: return(string.Format("{0} {1}", TotalNbRecords, def_Data.entities)); } } }
private string FormMapDB_Objects() { //Strategies (proposal universes like BO) StringBuilder myHTML = new StringBuilder(); StringBuilder html = new StringBuilder(); string sql, buffer, buffer2, pkName = "ID"; int j, f = 0; DataSet ds = new DataSet(); string myTable, prevTable; int myFormID = 0, myPanelID = 0; StringBuilder sqlsb = new StringBuilder(); const string coma = ","; sqlsb.Append("SELECT sc.id,so.name as dbtable,sc.name as dbcolumn,sc.xtype,sc.length,sc.isnullable "); sqlsb.Append("FROM sysobjects as so, syscolumns as sc (nolock) "); sqlsb.Append("WHERE sc.id=so.id AND "); sqlsb.Append(whereMapDB); if ((GetPageRequest("table2map") != null)) { buffer = GetPageRequest("table2map").ToString(); sqlsb.Append(" AND so.id in (").Append(EvoDB.SQLescape(buffer)).Append(") "); } sqlsb.Append(" order by so.name,sc.colid"); ds = EvoDB.GetData(sqlsb.ToString(), _SqlConnection, ref ErrorMsg); if (ds != null) { html.Append("<p>Your tables are roughly mapped. The Web UI is ready to use, refine, and tune.</p>"); prevTable = ""; //######### Form ######### int MaxLoop = ds.Tables[0].Rows.Count; html.Append("<ul>"); for (int i = 0; i < MaxLoop; i++) { myTable = ds.Tables[0].Rows[i][xAttribute.dbTable].ToString(); myTable = myTable.Replace("'", ""); if (myTable != prevTable) { //get PK name sqlsb = new StringBuilder(); sqlsb.Append("SELECT CU.Column_Name "); sqlsb.Append("FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE CU inner join "); sqlsb.Append(" INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC on CU.Constraint_Name=TC.Constraint_Name "); sqlsb.Append("WHERE CU.table_name = '").Append(myTable).Append("' AND TC.Constraint_Type='PRIMARY KEY' "); sqlsb.Append("ORDER BY CU.Table_Name "); pkName = EvoDB.GetDataScalar(sqlsb.ToString(), _SqlConnection, ref ErrorMessage).ToUpper(); if (string.IsNullOrEmpty(pkName)) { pkName = "ID"; } //+ dborder, spget, spdelete, entity, xmlfile) " sqlsb = new StringBuilder(); sqlsb.AppendFormat("'{0}','{1}','{2}',", EvoTC.ToUpperLowers(myTable.Replace("_", " ")), myTable, pkName); sqlsb.AppendFormat("'Definition obtained from scan table ''{0}'' with Evolutility wizard on {1}.'", myTable, EvoTC.TextNow()); sqlsb.Append(",'").Append(PagingSPCall); sqlsb.Append("','EvoSP_Login @login, @password'"); sql = EvoDB.sqlINSERT("EvoDico_form", "title, dbtable, dbcolumnpk, description, sppaging, splogin", sqlsb.ToString()); sql += EvoDB.SQL_IDENTITY; myFormID = EvoTC.String2Int(EvoDB.GetDataScalar(sql, _SqlConnectionDico, ref ErrorMessage)); if (myFormID > 0) { //######### Panel ######### myPanelID = EvoTC.String2Int(EvoDB.GetDataScalar("SELECT max(ID) FROM EvoDico_Panel WHERE FormID=" + myFormID.ToString(), _SqlConnectionDico, ref ErrorMessage)); if (myPanelID == 0) { sqlsb = new StringBuilder(); sqlsb.Append("INSERT INTO EvoDico_Panel (FormID, label, Width) VALUES("); sqlsb.AppendFormat("{0},'{1}',100)", myFormID, myTable); sqlsb.Append(EvoDB.SQL_IDENTITY); myPanelID = EvoTC.String2Int(EvoDB.GetDataScalar(sqlsb.ToString(), _SqlConnectionDico, ref ErrorMessage)); } } else { ErrorMsg += "BAD SQL<br/>" + sql; } html.AppendFormat("<li>{0} : ", myTable); html.Append(" <a href=\"evodicoTest.aspx?formID=").Append(myFormID).Append("\" target=\"r\">Run").Append(EvoUI.HTMLFlagPopup).Append("</a>"); html.Append(" - <a href=\"evodicoForm.aspx?ID=").Append(myFormID).Append("\" target=\"d\">Design").Append(EvoUI.HTMLFlagPopup).Append("</a></li>"); prevTable = myTable; f = 0; } //######### Fields ######### //'buffer = CStr(ds.Tables[0].Rows[i][xAttribute.dbColumn)) buffer = ds.Tables[0].Rows[i][xAttribute.dbColumn].ToString(); if (buffer.ToUpper() != pkName) { f += 1; sqlsb = new StringBuilder(); sqlsb.Append("INSERT INTO EvoDico_Field (FormID, fpos, label, dbcolumn, dbcolumnread, typeid, height, width, maxlength, required, panelid, search, searchlist, searchadv)"); sqlsb.AppendFormat(" VALUES ({0},", myFormID); if (buffer == "title") { sqlsb.Append("5,"); } else if (buffer == "name") { sqlsb.Append("1,"); } else { sqlsb.AppendFormat("{0},", i * 10); } buffer2 = buffer.Replace("_", " ").Replace("'", "''"); j = buffer2.Length - 1; if (j > 0) { buffer2 = EvoTC.ToUpperLowers(buffer2); } sqlsb.AppendFormat("'{0}','{1}','{1}',", buffer2, buffer); j = -1; int maxlength = EvoTC.String2Int(ds.Tables[0].Rows[i]["length"].ToString()); switch (EvoTC.String2Int(ds.Tables[0].Rows[i]["xtype"].ToString())) { case 127: case 56: case 52: case 48: case 36: sqlsb.Append("10,1,20"); //"integer" maxlength = 12; break; case 104: sqlsb.Append("1,1,20"); //bool maxlength = 0; break; case 61: sqlsb.Append("17,1,30"); // t_datetime maxlength = 25; break; case 106: case 62: case 60: case 108: case 59: case 122: sqlsb.Append("9,1,20"); //t_dec maxlength = 12; break; case 58: sqlsb.Append("2,1,30"); //t_date maxlength = 20; break; case 189: sqlsb.Append("18,1,30"); // t_time maxlength = 12; break; case 99: case 35: sqlsb.Append("6,3,100"); // t_txtm maxlength = maxlength / 2; break; default: //175, 239, 231, 167 maxlength = maxlength / 2; if (maxlength < 100) { sqlsb.Append("5,1,50"); //"text" } else if (maxlength < 200) { sqlsb.Append("5,1,100"); //"text" } else if (maxlength < 500) { sqlsb.Append("6,3,100"); //"textmul" } else { sqlsb.Append("6,5,100"); //"textmul" } break; } sqlsb.AppendFormat(",{0},", maxlength); if (Convert.ToInt32(ds.Tables[0].Rows[i]["isnullable"]) > 0) { sqlsb.Append("0,"); } else { sqlsb.Append("1,"); } sqlsb.Append(myPanelID + coma); if (f < 6) { sqlsb.Append("1,1"); //search, searchlist } else if (f < 20) { sqlsb.Append("1,0"); } else { sqlsb.Append("0,0"); } sqlsb.Append(",1)"); buffer = EvoDB.RunSQL(sqlsb.ToString(), _SqlConnectionDico, false); if (buffer != string.Empty) { ErrorMsg += string.Format("BAD SQL<br/>{0}<br/>{1}", sqlsb.ToString(), buffer); } } } html.Append("</ul>"); } else { html.Append(EvoUI.HTMLMessage("No database tables were found. There is nothing to map.", EvoUI.MsgType.Warn)); } html.Append("<br/> "); return(html.ToString()); }
private string ModeName(int cDisplayMode) { /// <summary>Form/view/mode name.</summary> StringBuilder buffer = new StringBuilder(); const string s = "{0} {1}"; if (def_Data != null) { switch (cDisplayMode) { case 0: // View buffer.AppendFormat(s, EvoLang.View, def_Data.entity); break; case 1: // Edit, New if (_ItemID > 0) { buffer.AppendFormat(s, EvoLang.Edit, def_Data.entity); } else { buffer.AppendFormat(s, EvoLang.New, def_Data.entity); } break; case 3: // Search buffer.AppendFormat(s, EvoLang.Search, def_Data.entities); break; case 4: // AdvSearch buffer.AppendFormat(s, EvoLang.AdvSearch, def_Data.entities); break; case 60: // Selections buffer.AppendFormat(s, EvoTC.ToUpperLowers(def_Data.entity), EvoLang.Selections); break; case 70: // Export buffer.AppendFormat(s, EvoLang.Export, def_Data.entities); break; case 80: // MassUpdate buffer.AppendFormat(s, EvoLang.MassUpdate, def_Data.entities); break; case 90: buffer.AppendFormat("{0}: {1}", EvoLang.Charts, string.Format(EvoLang.AllEntities, def_Data.entities)); break; default: if (_DisplayMode > 101 && _DisplayMode < 111) { buffer.AppendFormat(s, EvoTC.ToUpperLowers(def_Data.entity), EvoLang.SearchRes); } else { buffer.Append(string.Empty); } break; } } return(buffer.ToString()); }