Skip to content

Commit 33cc1b7

Browse files
committed
Version 4.1.
1 parent 029254d commit 33cc1b7

File tree

170 files changed

+1329
-2100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+1329
-2100
lines changed

Evolutility/Common/EvoDB.cs

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2011 Olivier Giulieri - olivier@evolutility.org
1+
// Copyright (c) 2003-2013 Olivier Giulieri - olivier@evolutility.org
22

33
// This file is part of Evolutility CRUD Framework.
44
// Source link <http://www.evolutility.org/download/download.aspx>
@@ -74,8 +74,6 @@ static class EvoDB
7474

7575
// SQL
7676
internal const string SQL_WHERE = " WHERE ";
77-
internal const string SQL_GROUPBY = " GROUP BY ";
78-
internal const string SQL_HAVING = " HAVING ";
7977
internal const string SQL_EXEC = "EXEC ";
8078
internal const string SQL_NULL = "NULL";
8179
internal const string SQL_INSERT = "INSERT INTO ";
@@ -151,10 +149,7 @@ static internal string dbformat2(string myVal, string myType, string language)
151149
case "System.String":
152150
return string.Format("N'{0}'", SQLescape(myVal));
153151
case "System.Boolean":
154-
if (myVal == "True")
155-
return "1";
156-
else
157-
return EvoTC.StrVal(myVal);
152+
return (myVal == "True") ? "1" : EvoTC.StrVal(myVal);
158153
case "System.DateTime":
159154
switch (language)
160155
{
@@ -196,18 +191,10 @@ static internal string dbFormat(string fieldValue, string fieldType, int fieldMa
196191
else
197192
return string.Format("N'{0}'", fieldValue.Replace("'", "''"));
198193
case t_lov:
199-
if (string.IsNullOrEmpty(fieldValue))
200-
return string.Empty;
201-
else
202-
return EvoTC.StrVal(fieldValue);
194+
return string.IsNullOrEmpty(fieldValue) ? string.Empty : EvoTC.StrVal(fieldValue);
203195
case t_bool:
204196
case t_int:
205-
if (!string.IsNullOrEmpty(fieldValue))
206-
{
207-
return EvoTC.StrVal(fieldValue);
208-
}
209-
else
210-
return SQL_NULL;
197+
return string.IsNullOrEmpty(fieldValue)? SQL_NULL : EvoTC.StrVal(fieldValue);
211198
case t_dec:
212199
string tDecStr;
213200
if (EvoTC.isInteger(fieldValue))
@@ -328,10 +315,7 @@ static internal string SQLec(string SQLColumn, string FieldType, string FieldVal
328315
static internal string SQLescape(string aString)
329316
{
330317
//simple SQL escaping to avoid SQL injection attack
331-
if (string.IsNullOrEmpty(aString))
332-
return string.Empty;
333-
else
334-
return aString.Replace("'", "''");
318+
return string.IsNullOrEmpty(aString) ? string.Empty : aString.Replace("'", "''");
335319
}
336320

337321
static internal string SQLescape2(string aString)
@@ -350,22 +334,20 @@ static internal string SQLescape2(string aString)
350334

351335
static internal string SPcall_Paging(string SPname, string spSelect, string spFrom, string spWhere, string spOrderBy, string sqlPK, int spPageID, int spPageSize, int spUserID, string myDBtable)
352336
{
353-
string sql;
354-
sql = SPname.Replace("@SQLselect", quotedVar(spSelect));
355-
sql = sql.Replace("@SQLtable", quotedVar(myDBtable));
356-
sql = sql.Replace("@SQLfrom", quotedVar(spFrom));
357-
sql = sql.Replace("@SQLwhere", quotedVar(spWhere));
358-
sql = sql.Replace("@SQLorderby", quotedVar(spOrderBy));
359-
sql = sql.Replace("@SQLpk", quotedVar(sqlPK));
360-
sql = sql.Replace("@pageid", string.Format("'{0}'", spPageID));
361-
sql = sql.Replace("@pagesize", string.Format("'{0}'", spPageSize));
362-
sql = sql.Replace("@userid", string.Format("'{0}'", spUserID));
363-
return sql;
337+
return SPname.Replace("@SQLselect", quotedVar(spSelect))
338+
.Replace("@SQLtable", quotedVar(myDBtable))
339+
.Replace("@SQLfrom", quotedVar(spFrom))
340+
.Replace("@SQLwhere", quotedVar(spWhere))
341+
.Replace("@SQLorderby", quotedVar(spOrderBy))
342+
.Replace("@SQLpk", quotedVar(sqlPK))
343+
.Replace("@pageid", string.Format("'{0}'", spPageID))
344+
.Replace("@pagesize", string.Format("'{0}'", spPageSize))
345+
.Replace("@userid", string.Format("'{0}'", spUserID));
364346
}
365347

366348
static internal string quotedVar(string myVar)
367349
{
368-
return string.Format("'{0}'", myVar.Replace("'", "''"));
350+
return string.Format("N'{0}'", myVar.Replace("'", "''"));
369351
}
370352

371353
static internal string SPcall_Get(string SPname, int itemID, int userID)
@@ -416,7 +398,6 @@ static internal string wDateIsValue(string DBcolumn, string DBformatedDate, stri
416398

417399
static internal string wBoolIsFalse(string DBcolumn)
418400
{
419-
420401
return String.Format(SQL_ISNULL_0, DBcolumn);
421402
}
422403

@@ -463,9 +444,11 @@ static internal string BuildSQL(string SQLselect, string SQLfrom, string SQLwher
463444
if (! string.IsNullOrEmpty(SQLwhere))
464445
sql.Append(SQL_WHERE).Append(SQLwhere);
465446
if (!string.IsNullOrEmpty(SQLgroupby))
466-
sql.Append(SQL_GROUPBY).Append(SQLgroupby);
467-
if (!string.IsNullOrEmpty(SQLhaving))
468-
sql.Append(SQL_HAVING).Append(SQLhaving);
447+
{
448+
sql.Append(" GROUP BY ").Append(SQLgroupby);
449+
if (!string.IsNullOrEmpty(SQLhaving))
450+
sql.Append(" HAVING ").Append(SQLhaving);
451+
}
469452
if (! string.IsNullOrEmpty(SQLorderby))
470453
sql.Append(" ORDER BY ").Append(SQLorderby);
471454
#if DB_MySQL
@@ -480,7 +463,7 @@ static internal string BuildSQL(string SQLselect, string SQLfrom, string SQLwher
480463

481464
static internal string sqlINSERT(string SQLTable, string SQLColumns, string SQLvalues)
482465
{
483-
return (new StringBuilder()).Append(SQL_INSERT).Append(SQLTable).Append("(").Append(SQLColumns).Append(") VALUES (").Append(SQLvalues).Append(");").ToString();
466+
return new StringBuilder().Append(SQL_INSERT).Append(SQLTable).Append("(").Append(SQLColumns).Append(") VALUES (").Append(SQLvalues).Append(");").ToString();
484467
}
485468

486469
static internal string sqlUPDATE(string SQLTable, string SQLColumnsValuesTuples, string SQLWhere)
@@ -490,12 +473,12 @@ static internal string sqlUPDATE(string SQLTable, string SQLColumnsValuesTuples,
490473

491474
static internal string sqlDELETE(string SQLTable, string SQLWhere)
492475
{
493-
return (new StringBuilder()).AppendFormat("DELETE FROM {0}{1}{2};", SQLTable, SQL_WHERE, SQLWhere).ToString();
476+
return new StringBuilder().AppendFormat("DELETE FROM {0}{1}{2};", SQLTable, SQL_WHERE, SQLWhere).ToString();
494477
}
495478

496479
static internal string sqlTRANSACTION(string mySQL)
497480
{
498-
return (new StringBuilder()).Append(SQL_BEGIN_TRANS).Append(mySQL).Append(SQL_COMMIT_TRANS).ToString();
481+
return new StringBuilder().Append(SQL_BEGIN_TRANS).Append(mySQL).Append(SQL_COMMIT_TRANS).ToString();
499482
}
500483

501484
static internal string IDequals(int ID)
@@ -682,11 +665,11 @@ static internal bool ColumnExists(DataTable Table, string ColumnName)
682665
#region "Misc"
683666

684667
// Having this function here saves the dependency on EvoLibUI which makes it easier to include.
685-
static private String HTMLtextMore(string myText, string myOptions)
668+
static private String HTMLtextMore(string myText, string myOptions)
686669
{
687-
StringBuilder zHTML = new StringBuilder();
688-
zHTML.Append(myText).Append("<div class=\"Foot\">").Append(myOptions).Append("</div>");
689-
return zHTML.ToString();
670+
return new StringBuilder()
671+
.Append(myText).Append("<div class=\"Foot\">").Append(myOptions).Append("</div>")
672+
.ToString();
690673
}
691674

692675
#endregion

Evolutility/Common/EvoDDL.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2011 Olivier Giulieri - olivier@evolutility.org
1+
// Copyright (c) 2003-2012 Olivier Giulieri - olivier@evolutility.org
22

33
// This file is part of Evolutility CRUD Framework.
44
// Source link <http://www.evolutility.org/download/download.aspx>

Evolutility/Common/EvoDico.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2011 Olivier Giulieri - olivier@evolutility.org
1+
// Copyright (c) 2003-2013 Olivier Giulieri - olivier@evolutility.org
22

33
// This file is part of Evolutility CRUD Framework.
44
// Source link <http://www.evolutility.org/download/download.aspx>
@@ -22,7 +22,6 @@
2222
//#define DB_MySQL
2323
#undef DB_MySQL
2424

25-
using System.Web;
2625
using System.Xml;
2726
using System.Data;
2827

@@ -55,11 +54,10 @@ internal static DataSet GetForm(int FormID, int UserID, string sqlConnectionDico
5554
{
5655
/// <summary>Generate XML from DB dico query.</summary>
5756

58-
string sql = null;
5957
string errorMsg = null;
6058
DataSet ds = new DataSet();
6159

62-
sql = string.Format("EXEC EvoDico_Form_Get @FormID, {0}", EvoDB.p_userid);
60+
string sql = string.Format("EXEC EvoDico_Form_Get @FormID, {0}", EvoDB.p_userid);
6361
#if DB_MySQL
6462
ds = EvoDB.GetDataParameters(sql, sqlConnectionDico, new MySqlParameter[] { new MySqlParameter("@FormID", FormID), new MySqlParameter(EvoDB.p_userid, UserID) }, ref errorMsg);
6563
#else
@@ -73,9 +71,6 @@ internal static string dicoDB2XML(int FormID, int UserID, bool showIDs, string s
7371
/// <summary>Generate XML from DB dico query.</summary>
7472

7573
string errorMsg = null;
76-
int MaxLoop;
77-
//bool UseTabs = false;
78-
//bool UseDetails = false;
7974
DataSet ds = new DataSet();
8075

8176
ds = GetForm(FormID, UserID, sqlConnectionDico);
@@ -84,7 +79,9 @@ internal static string dicoDB2XML(int FormID, int UserID, bool showIDs, string s
8479
{
8580
//built hierarchical relationships between recordsets
8681
ds.DataSetName = "EvoL";
87-
MaxLoop = ds.Tables.Count;
82+
//bool UseTabs = false;
83+
//bool UseDetails = false;
84+
int MaxLoop = ds.Tables.Count;
8885
if (MaxLoop > 0)
8986
{
9087
//'UseTabs = false

Evolutility/Common/EvoJSON.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2011 Olivier Giulieri - olivier@evolutility.org
1+
// Copyright (c) 2013 Olivier Giulieri - olivier@evolutility.org
22

33
// This file is part of Evolutility CRUD Framework.
44
// Source link <http://www.evolutility.org/download/download.aspx>
@@ -65,6 +65,13 @@ static internal string JSONEncode(String Value)
6565
else
6666
return HttpUtility.HtmlEncode(Value.Replace("\n\r", "\\n").Replace("\n", "\\n").Replace("\r", "").Replace("'", "\\'"));
6767
}
68+
static internal string JSONEncodeDoubleQuote(String Value)
69+
{
70+
if (string.IsNullOrEmpty(Value))
71+
return string.Empty;
72+
else
73+
return HttpUtility.HtmlEncode(Value.Replace("\n\r", "\\n").Replace("\n", "\\n").Replace("\r", "").Replace("\"", "\\\""));
74+
}
6875

6976
#endregion
7077

Evolutility/Common/EvoModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2003-2011 Olivier Giulieri - olivier@evolutility.org
1+
// Copyright (c) 2003-2013 Olivier Giulieri - olivier@evolutility.org
22

33
// This file is part of Evolutility CRUD Framework.
44
// Source link <http://www.evolutility.org/download/download.aspx>
@@ -95,7 +95,7 @@ public class Data
9595

9696
//added
9797
[XmlAttribute()]
98-
public string title;
98+
public string title="";
9999
[XmlAttribute()]
100100
public string js_script;
101101
[XmlAttribute()]

Evolutility/Common/EvoTC.cs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2003-2011 Olivier Giulieri - olivier@evolutility.org
1+
// Copyright (c) 2003-2013 Olivier Giulieri - olivier@evolutility.org
22

33
// This file is part of Evolutility CRUD Framework.
44
// Source link <http://www.evolutility.org/download/download.aspx>
@@ -71,10 +71,10 @@ static internal void LoadFormats(string LanguageKey)
7171
// DateFormatSD = "{0:dd/MM-yyyy}";
7272
// DateFormatSDT = "{0:dd/MM-yyyy} {0:t}";
7373
break;
74-
case "FA":
75-
DateFormatSD = "{0:yy/MM/dd}";
76-
DateFormatSDT = "{0:yy/MM/dd} {0:t}";
77-
break;
74+
case "FA":
75+
DateFormatSD = "{0:yy/MM/dd}";
76+
DateFormatSDT = "{0:yy/MM/dd} {0:t}";
77+
break;
7878
default: // All other languages
7979
DateFormatSD = "{0:dd/MM/yyyy}";
8080
DateFormatSDT = "{0:dd/MM/yyyy} {0:t}";
@@ -87,8 +87,8 @@ static internal string DefaultDateFormat(string fType)
8787
/// <summary>Returns DefaultDateFormat for fieldtype (date, time, datetime).</summary>
8888
switch (fType)
8989
{
90-
case "date":
91-
return DateFormatSD;
90+
//case "date":
91+
// return DateFormatSD;
9292
case "datetime":
9393
return DateFormatSDT;
9494
case "time":
@@ -134,16 +134,13 @@ static internal string ToUpperLowers(string myString)
134134
case 1:
135135
return myString.ToUpper();
136136
default:
137-
return myString.Substring(0, 1).ToUpper() + myString.Substring(1).ToLower();
137+
return myString.Substring(0, 1).ToUpper() + myString.Substring(1);
138138
}
139139
}
140140

141141
static internal string Text2HTML(string myText)
142142
{
143-
if (string.IsNullOrEmpty(myText))
144-
return string.Empty;
145-
else
146-
return HttpUtility.HtmlEncode(myText);
143+
return string.IsNullOrEmpty(myText) ? string.Empty : HttpUtility.HtmlEncode(myText);
147144
}
148145

149146
static internal string Text2HTMLwBR(string myText)
@@ -156,10 +153,7 @@ static internal string Text2HTMLwBR(string myText)
156153

157154
static internal string HTML2SQL(string myHTML)
158155
{
159-
if (myHTML.IndexOf("&") > -1)
160-
return System.Web.HttpUtility.HtmlDecode(myHTML);
161-
else
162-
return myHTML;
156+
return (myHTML.IndexOf("&") > -1) ? System.Web.HttpUtility.HtmlDecode(myHTML) : myHTML;
163157
}
164158

165159
static internal int String2Int(string myString)
@@ -191,10 +185,7 @@ static internal DateTime String2DateTime(string myString)
191185

192186
static internal int Bool2Int(bool myBool)
193187
{
194-
if (myBool)
195-
return 1;
196-
else
197-
return 0;
188+
return myBool ? 1 : 0;
198189
}
199190

200191
static internal bool isInteger(string myString)
@@ -235,10 +226,7 @@ static internal string Right(string param, int length)
235226

236227
static internal string StrVal(string s)
237228
{
238-
if (string.IsNullOrEmpty(s))
239-
return "0";
240-
else
241-
return String2Int(s).ToString();
229+
return string.IsNullOrEmpty(s) ? "0" : String2Int(s).ToString();
242230
}
243231

244232
#endregion

0 commit comments

Comments
 (0)