//---------------------------------- private string GenerateControls() { string dataGridID = "dg" + global.TableProgramatlyName; StringBuilder controls = new StringBuilder(); controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"Result\" align=\"center\" colspan=\"2\">"); controls.Append("\n\t\t\t\t\t\t<asp:Label ID=\"lblResult\" runat=\"server\" ForeColor=\"Red\" Text=\"\"></asp:Label>"); controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); #region DataGrid Declaretion And Propreties controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"GridControl\" align=\"center\" colspan=\"2\">"); controls.Append("\n\t\t\t\t\t\t<asp:DataGrid id=\"" + dataGridID + "\" runat=\"server\" SkinId=\"GridViewSkin\" "); controls.Append("\n\t\t\t\t\t\tOnDeleteCommand=\"" + dataGridID + "_DeleteCommand\" OnItemDataBound=\"" + dataGridID + "_ItemDataBound\" >"); #endregion // if (Fields.Count > 0) { controls.Append("\n\t\t\t\t\t\t<Columns>"); int i = 0; controls.Append("\n\t\t\t\t\t\t\t<asp:BoundColumn ItemStyle-Width=\"20\" ItemStyle-CssClass=\"ItemStyle\" DataField=\"Index\" HeaderText=\"Index\"></asp:BoundColumn>"); foreach (SQLDMO.Column column in Fields) { if ((ID == null || column.Name != ID.Name) && i < 2) { controls.Append("\n\t\t\t\t\t\t\t<asp:BoundColumn DataField=\"" + column.Name + "\" ItemStyle-Width=\"100%\" ItemStyle-CssClass=\"ItemStyleTitle\" HeaderText=\"" + ResourcesTesxtsBuilder.AddUserText(column.Name, TextType.ServerControl) + "\"></asp:BoundColumn>"); } ++i; } if (ID != null) { controls.Append("\n\t\t\t\t\t\t\t<asp:TemplateColumn ItemStyle-Width=\"20px\" ItemStyle-CssClass=\"ItemStyleButton\" HeaderText=\"" + ResourcesTesxtsBuilder.AddAdminGlobalText("Update", TextType.ServerControl) + "\">"); controls.Append("\n\t\t\t\t\t\t\t<ItemTemplate>"); controls.Append("\n\t\t\t\t\t\t\t\t<a href='<%# \"Edit.aspx?" + Globals.GetProgramatlyName(ID.Name) + "=\"+DataBinder.Eval(Container.DataItem, \"" + ID.Name + "\")+\"&iK=" + global.TableProgramatlyName + "\" %>' class='Link'>"); controls.Append("\n\t\t\t\t\t\t\t\t\t<img src=\"/App_Design/Admin/Icons/edit.gif\" style=\"border-width:0px\" alt=\"<%#" + ResourcesTesxtsBuilder.AddAdminGlobalText("Update", TextType.Text) + "%>\" /></a>"); controls.Append("\n\t\t\t\t\t\t\t</ItemTemplate>"); controls.Append("\n\t\t\t\t\t\t\t</asp:TemplateColumn>"); //Delete column. controls.Append("\n\t\t\t\t\t\t\t<asp:TemplateColumn ItemStyle-Width=\"20px\" ItemStyle-CssClass=\"ItemStyleButton\" HeaderText=\"" + ResourcesTesxtsBuilder.AddAdminGlobalText("Delete", TextType.ServerControl) + "\">"); controls.Append("\n\t\t\t\t\t\t\t<ItemTemplate>"); controls.Append("\n\t\t\t\t\t\t\t\t<asp:ImageButton ID=\"lbtnDelete\" AlternateText=\"\" ImageUrl=\"/App_Design/Admin/Icons/delete.gif\" CommandName=\"Delete\" runat=\"server\"></asp:ImageButton>"); controls.Append("\n\t\t\t\t\t\t\t</ItemTemplate>"); controls.Append("\n\t\t\t\t\t\t\t</asp:TemplateColumn>"); } controls.Append("\n\t\t\t\t\t\t</Columns>"); controls.Append("\n\t\t\t\t\t\t</asp:DataGrid>"); } controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"Control\" align=\"center\" colspan=\"2\">"); controls.Append("\n\t\t\t\t\t\t<cc1:OurPager ID=\"pager\" runat=\"server\" OnPageIndexChang=\"Pager_PageIndexChang\"></cc1:OurPager>"); controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); //-------------------------------- return(controls.ToString()); }
//------------------------------------- #endregion //---------------------------------------------------------- #region CreateGetChacheKeyMethod public string CreateGetChacheKeyMethod() { if (ID != null) { try { string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); // string MethodName = "GetChacheKey"; string MethodReturn = "string"; //Method Body StringBuilder methodBody = new StringBuilder(); methodBody.Append("\n\t#region --------------" + MethodName + "--------------"); methodBody.Append("\n\tpublic static " + MethodReturn + " " + MethodName + "(" + Globals.GetAliasDataType(ID.Datatype) + " " + id + ")"); methodBody.Append("\n\t{"); methodBody.Append("\n\t\treturn \" " + global.TableProgramatlyName + "-\" + " + id + ";"); methodBody.Append("\n\t}"); methodBody.Append("\n\t" + Globals.MetthodsSeparator); methodBody.Append("\n\t#endregion"); return(methodBody.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } } else { return(""); } }
// private string CreateDeleteCommandHandler() { string dataGridID = "dg" + global.TableProgramatlyName; string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); StringBuilder pageIndexHandler = new StringBuilder(); pageIndexHandler.Append("\n\tprotected void " + dataGridID + "_DeleteCommand(object source, DataGridCommandEventArgs e)"); pageIndexHandler.Append("\n\t{"); // pageIndexHandler.Append("\n\t\tTestData.Tables[0].Rows.Remove(TestData.Tables[0].Rows.Find(" + global.ViewAllDataGrid + ".DataKeys[e.Item.ItemIndex]));"); pageIndexHandler.Append("\n\t\t" + Globals.GetAliasDataType(ID.Datatype) + " " + id + " = Convert.To" + Globals.GetDataType(ID.Datatype) + "(" + dataGridID + ".DataKeys[e.Item.ItemIndex]);"); pageIndexHandler.Append("\n\t\tif(" + global.TableFactoryClass + "." + MethodType.Delete.ToString() + "(" + id + "))"); pageIndexHandler.Append("\n\t\t{"); pageIndexHandler.Append("\n\t\tint x = " + dataGridID + ".CurrentPageIndex;"); pageIndexHandler.Append("\n\t\tif (" + dataGridID + ".PageCount - 1 > x) " + dataGridID + ".CurrentPageIndex = x;"); pageIndexHandler.Append("\n\t\telse"); pageIndexHandler.Append("\n\t\t{"); pageIndexHandler.Append("\n\t\tif (" + dataGridID + ".PageCount != 1)" + dataGridID + ".CurrentPageIndex = x - 1;"); pageIndexHandler.Append("\n\t\t}"); pageIndexHandler.Append("\n\t\t\tLoadData();"); pageIndexHandler.Append("\n\t\t}"); pageIndexHandler.Append("\n\t}"); return(pageIndexHandler.ToString()); // }
//---------------------------------- private string GenerateControls() { string dataGridID = "dg" + global.TableProgramatlyName; StringBuilder controls = new StringBuilder(); controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"Result\" align=\"center\" >"); controls.Append("\n\t\t\t\t\t\t<asp:Label ID=\"lblResult\" runat=\"server\" ForeColor=\"Red\" Text=\"\"></asp:Label>"); controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); #region DataGrid Declaretion And Propreties controls.Append("\n\t\t\t\t\t<td class=\"Control\" align=\"center\" >"); controls.Append("\n\t\t\t\t\t\t<asp:datagrid id=\"" + dataGridID + "\" runat=\"server\" SkinId=\"GridViewSkin\" "); controls.Append("\n\t\t\t\t\t\tOnDeleteCommand=\"" + dataGridID + "_DeleteCommand\" OnItemDataBound=\"" + dataGridID + "_ItemDataBound\" OnPageIndexChanged=\"" + dataGridID + "_PageIndexChanged\" >"); #endregion // if (Fields.Count > 0) { controls.Append("\n\t\t\t\t\t\t<Columns>"); int i = 0; foreach (SQLDMO.Column column in Fields) { if ((ID == null || column.Name != ID.Name) && i < 4) { if (allParameters != null && !allParameters.Contains(column.Name)) { continue; } controls.Append("\n\t\t\t\t\t\t\t<asp:BoundColumn DataField=\"" + column.Name + "\" HeaderText=\"" + column.Name + "\"></asp:BoundColumn>"); } ++i; } if (ID != null) { controls.Append("\n\t\t\t\t\t\t\t<asp:TemplateColumn HeaderText=\"\">"); controls.Append("\n\t\t\t\t\t\t\t<ItemTemplate>"); controls.Append("\n\t\t\t\t\t\t\t\t<a href='<%# \"Edit.aspx?" + Globals.GetProgramatlyName(ID.Name) + "=\"+DataBinder.Eval(Container.DataItem, \"" + ID.Name + "\")+\"&iK=" + global.TableProgramatlyName + "\" %>' class='Link'>"); controls.Append("\n\t\t\t\t\t\t\t\t\t<img src=\"/App_Design/Globals/Images/Admin/edit.gif\" border=\"0\" alt=\"<%#" + LanguageXmlBuilder.AddText("Update", TextType.Text) + "%>\" /></a>"); controls.Append("\n\t\t\t\t\t\t\t</ItemTemplate>"); controls.Append("\n\t\t\t\t\t\t\t</asp:TemplateColumn>"); //Delete column. controls.Append("\n\t\t\t\t\t\t\t<asp:TemplateColumn HeaderText=\"\">"); controls.Append("\n\t\t\t\t\t\t\t<ItemTemplate>"); controls.Append("\n\t\t\t\t\t\t\t\t<asp:ImageButton ID=\"lbtnDelete\" AlternateText=\"\" ImageUrl=\"/App_Design/Globals/Images/Admin/delete.gif\" CommandName=\"Delete\" runat=\"server\"></asp:ImageButton>"); controls.Append("\n\t\t\t\t\t\t\t</ItemTemplate>"); controls.Append("\n\t\t\t\t\t\t\t</asp:TemplateColumn>"); } controls.Append("\n\t\t\t\t\t\t</Columns>"); controls.Append("\n\t\t\t\t\t\t</asp:datagrid>"); } controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); //-------------------------------- return(controls.ToString()); }
//---------------------------------------------------------- #region CreateUpdateMethod public string CreateUpdateMethod() { try { string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); string MethodName = StoredProcedureTypes.Update.ToString(); string sqlDataProviderMethodName = StoredProcedureTypes.Update.ToString(); string MethodParameters = "(" + global.TableEntityClass + " " + global.EntityClassObject + ")"; string MethodReturn = "bool"; if (ProjectBuilder.ISExcuteScaler) { MethodReturn = "ExecuteCommandStatus"; } //XML Documentaion string xmlUpdateDocumentation = "\n\t/// <summary>\n"; xmlUpdateDocumentation += "\t/// Updates " + SqlProvider.obj.TableName + " object by calling " + SqlProvider.obj.TableName + " data provider update method.\n"; xmlUpdateDocumentation += "\t/// <example>[Example]" + MethodReturn + " status=" + ClassName + "." + MethodName + "(" + global.EntityClassObject + ");.</example>\n"; xmlUpdateDocumentation += "\t/// </summary>\n"; xmlUpdateDocumentation += "\t/// <param name=\"" + global.EntityClassObject + "\">The " + SqlProvider.obj.TableName + " object.</param>\n"; xmlUpdateDocumentation += "\t/// <returns>Status of update operation.</returns>"; // //method body StringBuilder methodBody = new StringBuilder(); methodBody.Append("\n\t#region --------------" + MethodName + "--------------"); methodBody.Append(xmlUpdateDocumentation); methodBody.Append("\n\tpublic static " + MethodReturn + " " + MethodName + MethodParameters); methodBody.Append("\n\t{"); if (!ProjectBuilder.ISExcuteScaler) { methodBody.Append("\n\t\tbool status =" + global.SqlDataProviderClass + ".Instance." + sqlDataProviderMethodName + "(" + global.EntityClassObject + ");"); methodBody.Append("\n\t\tif (status)"); } else { methodBody.Append("\n\t\tExecuteCommandStatus status =" + global.SqlDataProviderClass + ".Instance." + sqlDataProviderMethodName + "(" + global.EntityClassObject + ");"); methodBody.Append("\n\t\tif (status == ExecuteCommandStatus.Done)"); } methodBody.Append("\n\t\t{"); methodBody.Append("\n\t\t\tstring cacheKey = GetChacheKey(" + global.EntityClassObject + "." + Globals.GetProgramatlyName(ID.Name) + ");"); methodBody.Append("\n\t\t\tOurCache.Remove(cacheKey);"); methodBody.Append("\n\t\t}"); methodBody.Append("\n\t\treturn status;"); methodBody.Append("\n\t}"); methodBody.Append("\n\t" + Globals.MetthodsSeparator); methodBody.Append("\n\t#endregion"); return(methodBody.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } }
public static string AddSiteOption(string key) { key = Globals.GetProgramatlyName(key); if (!SiteGlobalOptions.Contains(key)) { SiteGlobalOptions.Add(key, ""); } return("SiteOptions.CheckOption(" + SiteOptionsBuilder.GetFullPropertyPath(key) + ")"); }
//--------------------------------- /// <summary> /// Generates code for an Get One Stored Procedure /// </summary> /// <param name="sptypeGenerate">The type of SP to generate, INSERT or UPDATE</param> /// <param name="Fields">A SQLDMO.Columns collection</param> /// <returns>The SP code</returns> private void GenerateGetOne4ShowProcedure() { try { StringBuilder sGeneratedCode = new StringBuilder(); StringBuilder sParamDeclaration = new StringBuilder(); StringBuilder sBody = new StringBuilder(); StringBuilder sINSERTValues = new StringBuilder(); string finnal = ""; // Setup SP code, begining is the same no matter the type sGeneratedCode.AppendFormat("CREATE PROCEDURE {0}.[{1}_{2}]", new string[] { SqlProvider.obj.DatabaseOwner, Globals.GetProgramatlyName(Table), StoredProcedureTypes.GetOneByID4Show.ToString() }); sGeneratedCode.Append(Environment.NewLine); // Setup body code, different for UPDATE and INSERT sBody.AppendFormat("Select * From [{0}] ", Table); sBody.Append(Environment.NewLine); if (ID != null) { sParamDeclaration.AppendFormat(" @{0} {1}", new string[] { Globals.GetProgramatlyName(ID.Name), ID.Datatype }); // Only binary, char, nchar, nvarchar, varbinary and varchar may have their length declared if ( ID.Datatype == "binary" || ID.Datatype == "char" || ID.Datatype == "nchar" || ID.Datatype == "nvarchar" || ID.Datatype == "varbinary" || ID.Datatype == "varchar") { sParamDeclaration.AppendFormat("({0})", ID.Length); } sParamDeclaration.Append(","); sParamDeclaration.Append(Environment.NewLine); finnal = "Where [" + ID.Name + "] = @" + Globals.GetProgramatlyName(ID.Name); } // Now stitch the body parts together into the SP whole sGeneratedCode.Append(sParamDeclaration.Remove(sParamDeclaration.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append("AS"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sBody.Remove(sBody.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(finnal); WriteStoredProcedure(sGeneratedCode.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); } }
// private string CreateClearControlsMethod() { // StringBuilder method = new StringBuilder(); method.Append("\n\tprivate void " + global.ClearControlsMethod); method.Append("\n\t{"); string datatype; foreach (SQLDMO.Column column in Fields) { if (ID == null || column.Name != ID.Name || !Globals.CheckIsAddedBySql(ID)) { if (allParameters != null && !allParameters.Contains(column.Name)) { continue; } datatype = Globals.GetAliasDataType(column.Datatype); if (datatype == "bool") { method.Append("\n\t\tcb" + Globals.GetProgramatlyName(column.Name) + ".Checked=false;"); } else if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.NText) { method.Append("\n\t\tfck" + Globals.GetProgramatlyName(column.Name) + ".Value=\"\";"); } else if (datatype != "byte[]" && datatype != "Object" && datatype != "Guid") { TableConstraint cnstr = SqlProvider.obj.GetParentColumn(column.Name); if (cnstr == null) { //dateTime if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.DateTime) { method.Append("\n\t\ttxt" + Globals.GetProgramatlyName(column.Name) + ".Value=\"\";"); } //datetime else { method.Append("\n\t\ttxt" + Globals.GetProgramatlyName(column.Name) + ".Text=\"\";"); } } else { method.Append("\n\t\tddl" + Globals.GetProgramatlyName(cnstr.ParentTable) + ".SelectedIndex=-1;"); method.Append("\n\t\tddl" + Globals.GetProgramatlyName(cnstr.ParentTable) + ".DataBind();"); } } } } method.Append("\n\t}"); return(method.ToString()); }
// #region ClassMember public string CreateEntityPropreties() { try { string xmlDocumentation = ""; // StringBuilder EntityPropreties = new StringBuilder(); // string dataType; foreach (Column colCurrent in Fields) { dataType = Globals.GetAliasDataType(colCurrent.Datatype); if (dataType == "string") { EntityPropreties.Append("\n\tprivate " + Globals.GetAliasDataType(colCurrent.Datatype) + " _" + Globals.GetProgramatlyName(colCurrent.Name) + "= \"\";"); } else if (dataType == "Guid") { EntityPropreties.Append("\n\tprivate " + Globals.GetAliasDataType(colCurrent.Datatype) + " _" + Globals.GetProgramatlyName(colCurrent.Name) + "= Guid.NewGuid();"); } else { EntityPropreties.Append("\n\tprivate " + Globals.GetAliasDataType(colCurrent.Datatype) + " _" + Globals.GetProgramatlyName(colCurrent.Name) + ";"); } //XML Documentaion xmlDocumentation = "\n"; xmlDocumentation += "\t/// <summary>\n"; xmlDocumentation += "\t/// Gets or sets " + SqlProvider.obj.TableName + " " + Globals.GetProgramatlyName(colCurrent.Name) + ". \n"; xmlDocumentation += "\t/// </summary>"; EntityPropreties.Append(xmlDocumentation); //Propretie body EntityPropreties.Append("\n\tpublic " + Globals.GetAliasDataType(colCurrent.Datatype) + " " + Globals.GetProgramatlyName(colCurrent.Name)); EntityPropreties.Append("\n\t{"); EntityPropreties.Append("\n\t\tget { return _" + Globals.GetProgramatlyName(colCurrent.Name) + " ; }"); EntityPropreties.Append("\n\t\tset { _" + Globals.GetProgramatlyName(colCurrent.Name) + "= value ; }"); EntityPropreties.Append("\n\t}"); EntityPropreties.Append("\n\t" + Globals.MetthodsSeparator); } // EntityPropreties.Append("\n"); return(EntityPropreties.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } }
// private void CreateSupLoadMethod(TableConstraint cnstr) { string ddl = "ddl" + Globals.GetProgramatlyName(cnstr.ParentTable); loadMethodsBuilder.Append("\n\t\tprivate void Load_" + ddl + "()"); loadMethodsBuilder.Append("\n\t\t{"); loadMethodsBuilder.Append("\n\t\t\tDataTable dtSource= " + Globals.GetProgramatlyName(cnstr.ParentTable) + "Factory.GetAll();"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".DataSource=dtSource;"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".DataTextField=\"" + SqlProvider.obj.GetExpectedNameForParent(cnstr.ParentTable) + "\";"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".DataValueField=\"" + Globals.GetProgramatlyName(cnstr.ParentColID) + "\";"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".DataBind();"); loadMethodsBuilder.Append("\n\t\t}"); // loadDataMethodBody.Append("\n\t\t\tLoad_" + ddl + "();"); }
//------------------------------------- public static string AddTableOption(string tableId, string key) { key = Globals.GetProgramatlyName(key); TableOptions tableOptions; if (!TablesOptions.Contains(tableId)) { tableOptions = new TableOptions(tableId); tableOptions.Key = tableId; TablesOptions.Add(tableId, tableOptions); } else { tableOptions = (TableOptions)TablesOptions[tableId]; } tableOptions.AddTableOption(key); //------------------------- return("SiteOptions.CheckOption(" + SiteOptionsBuilder.GetFullPropertyPath(key) + ")"); }
//------------------------------------- #endregion //---------------------------------------------------------- #region CreateDeleteMethod public string CreateDeleteMethod() { try { string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); string MethodName = StoredProcedureTypes.Delete.ToString(); string sqlDataProviderMethodName = StoredProcedureTypes.Delete.ToString(); string MethodParameters = "(" + Globals.GetAliasDataType(ID.Datatype) + " " + id + ")"; //XML Documentaion string xmlDeleteDocumentation = "\n\t/// <summary>\n"; xmlDeleteDocumentation += "\t/// Deletes single " + SqlProvider.obj.TableName + " object .\n"; xmlDeleteDocumentation += "\t/// <example>[Example]bool status=" + ClassName + "." + MethodName + "(" + id + ");.</example>\n"; xmlDeleteDocumentation += "\t/// </summary>\n"; xmlDeleteDocumentation += "\t/// <param name=\"" + id + "\">The " + global.EntityClassObject + " id.</param>\n"; xmlDeleteDocumentation += "\t/// <returns>Status of delete operation.</returns>"; //method body StringBuilder methodBody = new StringBuilder(); methodBody.Append("\n\t#region --------------" + MethodName + "--------------"); methodBody.Append(xmlDeleteDocumentation); methodBody.Append("\n\tpublic static bool " + MethodName + MethodParameters); methodBody.Append("\n\t{"); // methodBody.Append("\n\t\tbool status =" + global.SqlDataProviderClass + ".Instance." + sqlDataProviderMethodName + "(" + id + ");"); methodBody.Append("\n\t\tif (status)"); methodBody.Append("\n\t\t{"); methodBody.Append("\n\t\t\tstring cacheKey = GetChacheKey(" + id + ");"); methodBody.Append("\n\t\t\tOurCache.Remove(cacheKey);"); methodBody.Append("\n\t\t}"); methodBody.Append("\n\t\treturn status;"); // methodBody.Append("\n\t}"); methodBody.Append("\n\t" + Globals.MetthodsSeparator); methodBody.Append("\n\t#endregion"); return(methodBody.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } }
//------------------------------------- public static string AddTableUrl(string tableId, string key, string url, UrlType type) { key = Globals.GetProgramatlyName(key); TableUrls tableUrls; if (!TablesUrls.Contains(tableId)) { tableUrls = new TableUrls(tableId); tableUrls.Key = tableId; TablesUrls.Add(tableId, tableUrls); } else { tableUrls = (TableUrls)TablesUrls[tableId]; } tableUrls.AddUrl(key, url, type); //------------------------- return(tableId + "Urls.Instance." + key);; }
//------------------------------------- public static string AddTableSetting(string tableId, string key, SettingType type) { key = Globals.GetProgramatlyName(key); TableSettings tableSettings; if (!TablesSettings.Contains(tableId)) { tableSettings = new TableSettings(tableId); tableSettings.Key = tableId; TablesSettings.Add(tableId, tableSettings); } else { tableSettings = (TableSettings)TablesSettings[tableId]; } tableSettings.AddSetting(key, type); //------------------------- return(tableId + "Settings.Instance." + key);; }
private string CreatePopulateObjectMethod() { try { // string MethodName = "Populate" + global.TableEntityClass + "FromIDataReader"; string MethodReturn = global.TableEntityClass; //XML Documentaion string xmlDocumentation = "\t/// <summary>\n"; xmlDocumentation += "\t/// Populates " + SqlProvider.obj.TableName + " Entity From IDataReader .\n"; xmlDocumentation += "\t/// <example>[Example]" + global.TableEntityClass + global.EntityClassObject + "=" + MethodName + "(reader);.</example>\n"; xmlDocumentation += "\t/// </summary>\n"; xmlDocumentation += "\t/// <param name=\"reader\"></param>\n"; xmlDocumentation += "\t/// <returns>" + SqlProvider.obj.TableName + " object.</returns>"; //Method Body StringBuilder methodBody = new StringBuilder(); methodBody.Append(xmlDocumentation); methodBody.Append("\n\tprivate " + global.TableEntityClass + " " + MethodName + "(IDataReader reader)"); methodBody.Append("\n\t{"); methodBody.Append("\n\t\t//Create a new " + SqlProvider.obj.TableName + " object"); methodBody.Append("\n\t\t" + global.TableEntityClass + " " + global.EntityClassObject + " = new " + global.TableEntityClass + "();"); methodBody.Append("\n\t\t//Fill the object with data"); // foreach (SQLDMO.Column colCurrent in Fields) { methodBody.Append("\n\t\tif (reader[\"" + Globals.GetProgramatlyName(colCurrent.Name) + "\"] != DBNull.Value)"); methodBody.Append("\n\t\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(colCurrent.Name) + " = (" + Globals.GetAliasDataType(colCurrent.Datatype) + ") reader[\"" + Globals.GetProgramatlyName(colCurrent.Name) + "\"];"); } // methodBody.Append("\n\t\t//Return the populated object"); methodBody.Append("\n\t\treturn " + global.EntityClassObject + ";"); methodBody.Append("\n\t}"); methodBody.Append("\n\t" + Globals.MetthodsSeparator); return(methodBody.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } }
// private void CreateSupLoadMethod(TableConstraint cnstr) { string ddl = "ddl" + Globals.GetProgramatlyName(cnstr.ParentTable); loadMethodsBuilder.Append("\n\t\tprivate void Load_" + ddl + "()"); loadMethodsBuilder.Append("\n\t\t{"); loadMethodsBuilder.Append("\n\t\t\tDataTable dtSource= " + Globals.GetProgramatlyName(cnstr.ParentTable) + "Factory.GetAll();"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".DataSource=dtSource;"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".DataTextField=\"" + SqlProvider.obj.GetExpectedNameForParent(cnstr.ParentTable) + "\";"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".DataValueField=\"" + Globals.GetProgramatlyName(cnstr.ParentColID) + "\";"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".DataBind();"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".UpdateAfterCallBack = true;"); loadMethodsBuilder.Append("\n\t\t\tif (" + ddl + ".Items.Count > 0)"); loadMethodsBuilder.Append("\n\t\t\t{"); loadMethodsBuilder.Append("\n\t\t\t" + ddl + ".Items.Insert(0, new ListItem(\"----ÇÎÊÜÜÜÑ----\",\" \"));"); loadMethodsBuilder.Append("\n\t\t\t}"); loadMethodsBuilder.Append("\n\t\t}"); // loadDataMethodBody.Append("\n\t\t\tLoad_" + ddl + "();"); }
// public string CreateGetOneMethod(StoredProcedureTypes type) { if (ID != null) { try { string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); // string MethodName = "Get" + global.TableProgramatlyName + "Object"; string MethodReturn = global.TableEntityClass; //XML Documentaion string xmlDocumentation = "\t/// <summary>\n"; xmlDocumentation += "\t/// Gets single " + SqlProvider.obj.TableName + " object .\n"; xmlDocumentation += "\t/// <example>[Example]" + global.TableEntityClass + " " + global.EntityClassObject + "=" + ClassName + "." + MethodName + "(" + id + ");.</example>\n"; xmlDocumentation += "\t/// </summary>\n"; xmlDocumentation += "\t/// <param name=\"" + id + "\">The " + global.EntityClassObject + " id.</param>\n"; xmlDocumentation += "\t/// <returns>" + SqlProvider.obj.TableName + " object.</returns>"; //Method Body StringBuilder methodBody = new StringBuilder(); methodBody.Append(xmlDocumentation); methodBody.Append("\n\tpublic static " + MethodReturn + " " + MethodName + "(" + Globals.GetAliasDataType(ID.Datatype) + " " + id + ")"); methodBody.Append("\n\t{"); methodBody.Append("\n\t\treturn " + global.SqlDataProviderClass + ".Instance." + MethodName + "(" + id + ");"); methodBody.Append("\n\t}"); methodBody.Append("\n\t" + Globals.MetthodsSeparator); return(methodBody.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } } else { return(""); } }
//Scimple Creation Method----------------------------------- public string CreateInsertUpdateDeleteMethod(StoredProcedureTypes type, string MethodName, Hashtable allParameters) { string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); // string ProcName = global.TableProgramatlyName + "_" + MethodName; string MethodReturn = "bool"; //XML Documentaion string xmlInsertDocumentation = "\t/// <summary>\n"; xmlInsertDocumentation += "\t/// Converts the " + SqlProvider.obj.TableName + " object properties to SQL paramters and executes the create " + SqlProvider.obj.TableName + " procedure \n"; xmlInsertDocumentation += "\t/// and updates the " + SqlProvider.obj.TableName + " object with the SQL data by reference.\n"; xmlInsertDocumentation += "\t/// <example>[Example]bool result=" + ClassName + ".Instance." + MethodName + "(" + global.EntityClassObject + ");.</example>\n"; xmlInsertDocumentation += "\t/// </summary>\n"; xmlInsertDocumentation += "\t/// <param name=\"" + global.EntityClassObject + "\">The " + SqlProvider.obj.TableName + " object.</param>\n"; xmlInsertDocumentation += "\t/// <returns>The result of create query.</returns>"; // string xmlUpdateDocumentation = "\t/// <summary>\n"; xmlUpdateDocumentation += "\t/// Converts the " + SqlProvider.obj.TableName + " object properties to SQL paramters and executes the update " + SqlProvider.obj.TableName + " procedure.\n"; xmlUpdateDocumentation += "\t/// <example>[Example]bool result=" + ClassName + ".Instance." + MethodName + "(" + global.EntityClassObject + ");.</example>\n"; xmlUpdateDocumentation += "\t/// </summary>\n"; xmlUpdateDocumentation += "\t/// <param name=\"" + global.EntityClassObject + "\">The " + SqlProvider.obj.TableName + " object.</param>\n"; xmlUpdateDocumentation += "\t/// <returns>The result of update query.</returns>"; // string xmlDeleteDocumentation = "\t/// <summary>\n"; xmlDeleteDocumentation += "\t/// Deletes single " + SqlProvider.obj.TableName + " object .\n"; xmlDeleteDocumentation += "\t/// <example>[Example]bool result=" + ClassName + ".Instance." + MethodName + "(" + id + ");.</example>\n"; xmlDeleteDocumentation += "\t/// </summary>\n"; xmlDeleteDocumentation += "\t/// <param name=\"" + id + "\">The " + global.EntityClassObject + " id.</param>\n"; xmlDeleteDocumentation += "\t/// <returns>The result of delete query.</returns>"; //method body try { StringBuilder methodBody = new StringBuilder(); if (type == StoredProcedureTypes.Create) { methodBody.Append(xmlInsertDocumentation); } else if (type == StoredProcedureTypes.Update) { methodBody.Append(xmlUpdateDocumentation); } else if (type == StoredProcedureTypes.Delete) { methodBody.Append(xmlDeleteDocumentation); } // if (type == StoredProcedureTypes.Delete) { methodBody.Append("\n\tpublic " + MethodReturn + " " + MethodName + "(" + Globals.GetAliasDataType(ID.Datatype) + " " + id + ")"); } else { methodBody.Append("\n\tpublic " + MethodReturn + " " + MethodName + "(" + global.TableEntityClass + " " + global.EntityClassObject + ")"); } methodBody.Append("\n\t{"); methodBody.Append("\n\t\tbool result=false;"); methodBody.Append("\n\t\tusing( SqlConnection myConnection = GetSqlConnection()) "); methodBody.Append("\n\t\t{"); methodBody.Append("\n\t\t\tSqlCommand myCommand = new SqlCommand(\"" + ProcName + "\", myConnection);"); methodBody.Append("\n\t\t\tmyCommand.CommandType = CommandType.StoredProcedure;"); methodBody.Append("\n\t\t\t// Set the parameters"); if (type == StoredProcedureTypes.Delete) { methodBody.Append("\n\t\t\tmyCommand.Parameters.Add(\"@" + Globals.GetProgramatlyName(ID.Name) + "\", SqlDbType." + Globals.GetSqlDataType(ID.Datatype).ToString() + "," + ID.Length + ").Value = " + id + ";"); } else { foreach (SQLDMO.Column colCurrent in Fields) { if (!allParameters.Contains(colCurrent.Name)) { continue; } if (ID != null && colCurrent.Name == ID.Name && type == StoredProcedureTypes.Create && ID.IdentityIncrement > 0) { methodBody.Append("\n\t\t\tmyCommand.Parameters.Add(\"@" + Globals.GetProgramatlyName(colCurrent.Name) + "\", SqlDbType." + Globals.GetSqlDataType(colCurrent.Datatype).ToString() + "," + colCurrent.Length + ").Direction = ParameterDirection.Output;"); } else if (colCurrent.Datatype.ToLower() == SqlDbType.NText.ToString().ToLower()) { methodBody.Append("\n\t\t\tmyCommand.Parameters.Add(\"@" + Globals.GetProgramatlyName(colCurrent.Name) + "\", SqlDbType." + Globals.GetSqlDataType(colCurrent.Datatype).ToString() + ").Value = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(colCurrent.Name) + ";"); } else { methodBody.Append("\n\t\t\tmyCommand.Parameters.Add(\"@" + Globals.GetProgramatlyName(colCurrent.Name) + "\", SqlDbType." + Globals.GetSqlDataType(colCurrent.Datatype).ToString() + "," + colCurrent.Length + ").Value = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(colCurrent.Name) + ";"); } } } methodBody.Append("\n\t\t\t// Execute the command"); methodBody.Append("\n\t\t\tmyConnection.Open();"); methodBody.Append("\n\t\t\tif(myCommand.ExecuteNonQuery()>0)"); methodBody.Append("\n\t\t\t{"); methodBody.Append("\n\t\t\t\tresult=true;"); if (ID != null && type == StoredProcedureTypes.Create && ID.IdentityIncrement > 0) { methodBody.Append("\n\t\t\t\t//Get ID value from database and set it in object"); methodBody.Append("\n\t\t\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(ID.Name) + "= (" + Globals.GetAliasDataType(ID.Datatype) + ") myCommand.Parameters[\"@" + Globals.GetProgramatlyName(ID.Name) + "\"].Value;"); } if (ID.Name.ToLower() == "id" && global.EntityClassObject == "Site_RolesObj") { MessageBox.Show(SqlProvider.obj.ID.Name); } methodBody.Append("\n\t\t\t}"); methodBody.Append("\n\t\t\tmyConnection.Close();"); methodBody.Append("\n\t\t\treturn result;"); methodBody.Append("\n\t\t}"); methodBody.Append("\n\t}"); methodBody.Append("\n\t" + Globals.MetthodsSeparator); return(methodBody.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } }
private string CreateLoadData() { StringBuilder loadDataStart = new StringBuilder(); StringBuilder loadDataChecks = new StringBuilder(); StringBuilder loadDataBody = new StringBuilder(); StringBuilder loadDataEnd = new StringBuilder(); string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); loadDataStart.Append("\n\t#region ---------------LoadData---------------"); loadDataStart.Append("\n\t//-----------------------------------------------"); loadDataStart.Append("\n\t//LoadData"); loadDataStart.Append("\n\t//-----------------------------------------------"); loadDataStart.Append("\n\tprotected void LoadData()"); loadDataStart.Append("\n\t{"); //Add Urls Property SiteUrlsBuilder.AddParameter(Globals.GetProgramatlyName(ID.Name)); loadDataStart.Append("\n\t\tif(MoversFW.Components.UrlManager.ChechIsValidIntegerParameter(" + SiteUrlsBuilder.GetIdentifire() + Globals.GetProgramatlyName(ID.Name) + "))"); loadDataStart.Append("\n\t\t{"); loadDataStart.Append("\n\t\t\t" + Globals.GetAliasDataType(ID.Datatype) + " " + id + " = Convert.To" + Globals.GetDataType(ID.Datatype) + "(Request.QueryString[" + SiteUrlsBuilder.GetIdentifire() + Globals.GetProgramatlyName(ID.Name) + "]);"); loadDataStart.Append("\n\t\t\t" + global.TableEntityClass + " " + global.EntityClassObject + " =" + global.TableFactoryClass + ".Get" + global.TableProgramatlyName + "Object(" + id + ");"); loadDataChecks.Append("\n\t\t\tif (" + global.EntityClassObject + " != null)"); loadDataChecks.Append("\n\t\t\t{"); if (ProjectBuilder.HasMultiLanguages && SqlProvider.CheckISATableIsMultiLanguage(SqlProvider.obj.TableName)) { loadDataChecks.Append("\n\t\t\t\t//"); loadDataChecks.Append("\n\t\t\t\t//Check Valid Language to avoid changing query string manualy"); loadDataChecks.Append("\n\t\t\t\tLanguages langid = (Languages)ResourceManager.GetCurrentLanguage();"); loadDataChecks.Append("\n\t\t\t\tif (langid != " + global.EntityClassObject + ".LangID)"); loadDataChecks.Append("\n\t\t\t\t{"); loadDataChecks.Append("\n\t\t\t\t\tResponse.Redirect(\"default.aspx\");"); loadDataChecks.Append("\n\t\t\t\t}"); } //----------------------------------------------------------*/ string datatype; string propertyName; string trPropertyName; string lblPropertyName; string optionalPropertyName; foreach (SQLDMO.Column column in Fields) { propertyName = Globals.GetProgramatlyName(column.Name); trPropertyName = "tr" + propertyName; lblPropertyName = "lbl" + propertyName; optionalPropertyName = SiteOptionsBuilder.GetHasPropertyString(propertyName); //if ((ID == null || column.Name != ID.Name) && (column.Default == null || column.Default.Length != 0) && column.Name.ToLower() != ProjectBuilder.LangID) if ((ID == null || column.Name != ID.Name) && (column.Name.IndexOf("_") < 0) && column.Name.ToLower().IndexOf("password") < 0 && column.Name.ToLower().IndexOf("shortdescription") < 0 && column.Name.ToLower().IndexOf(ProjectBuilder.PriorityColumnName.ToLower()) < 0 && column.Name.ToLower().IndexOf(ProjectBuilder.IsAvailable.ToLower()) < 0 && column.Name.ToLower() != ProjectBuilder.LangID) { TableConstraint cnstr = SqlProvider.obj.GetParentColumn(column.Name); datatype = Globals.GetAliasDataType(column.Datatype); if (datatype == "string") { if (cnstr == null) { if (column.Name == ProjectBuilder.PhotoExtensionColumnName) { // hasPhoto = true; loadDataBody.Append("\n\t\t\t\tif (" + global.EntityClassObject + ".HasPhotoExtension)"); loadDataBody.Append("\n\t\t\t\t{"); //Add Urls Property SiteUrlsBuilder.AddDirectoryUrl("PhotoNormalThumbs", SiteUrlsBuilder.photoNormalUrl, Globals.GetProgramatlyName(Table), ""); loadDataBody.Append("\n\t\t\t\t\t" + imageName + ".Text = \" <a href='\" + " + SiteUrlsBuilder.GetIdentifire() + "BigPhotoThumbs + " + global.EntityClassObject + ".BigPhotoThumbs+\"' rel='lightbox'>\";"); loadDataBody.Append("\n\t\t\t\t\t" + imageName + ".Text += \"<img border='0' src='\" +" + SiteUrlsBuilder.GetIdentifire() + "PhotoNormalThumbs + " + global.EntityClassObject + ".NormalPhotoThumbs+\"' class='Image' alt='\" + " + global.EntityClassObject + ".Title+\"' /></a>\";"); loadDataBody.Append("\n\t\t\t\t}"); loadDataBody.Append("\n\t\t\t\telse"); loadDataBody.Append("\n\t\t\t\t{"); loadDataBody.Append("\n\t\t\t\t\t" + PhotoContainerTr + ".Visible = false;"); loadDataBody.Append("\n\t\t\t\t}"); //loadDataBody.Append("\n\t\t\t\t//------------------------------------------"); //loadDataBody.Append("\n\t\t\t\tViewState[\"" + ProjectBuilder.PhotoExtensionColumnName + "\"] = " + global.EntityClassObject + "." + ProjectBuilder.PhotoExtensionColumnName + ";"); //loadDataBody.Append("\n\t\t\t\t//------------------------------------------"); } else if (column.Name == "LogoExtension") { //hasPhoto = true; loadDataBody.Append("\n\t\t\t\tif (" + global.EntityClassObject + ".HasLogoExtension)"); loadDataBody.Append("\n\t\t\t\t{"); //Add Urls Property SiteUrlsBuilder.AddDirectoryUrl("LogoNormalThumbs", SiteUrlsBuilder.logoNormalUrl, Globals.GetProgramatlyName(Table), ""); loadDataBody.Append("\n\t\t\t\t\t" + logoName + ".Text = \" <a href='\" + " + SiteUrlsBuilder.GetIdentifire() + "BigLogoThumbs + " + global.EntityClassObject + ".BigLogoThumbs+\"' rel='lightbox'>\";"); loadDataBody.Append("\n\t\t\t\t\t" + logoName + ".Text += \"<img border='0' src='\" +" + SiteUrlsBuilder.GetIdentifire() + "LogoNormalThumbs + " + global.EntityClassObject + ".NormalLogoThumbs+\"' class='Image' alt='\" + " + global.EntityClassObject + ".Title+\"' /></a>\";"); loadDataBody.Append("\n\t\t\t\t}"); loadDataBody.Append("\n\t\t\t\telse"); loadDataBody.Append("\n\t\t\t\t{"); loadDataBody.Append("\n\t\t\t\t\t" + LogoContainerTr + ".Visible = false;"); loadDataBody.Append("\n\t\t\t\t}"); //loadDataBody.Append("\n\t\t\t\t//------------------------------------------"); //loadDataBody.Append("\n\t\t\t\tViewState[\"" + ProjectBuilder.LogoExtensionColumnName + "\"] = " + global.EntityClassObject + "." + ProjectBuilder.LogoExtensionColumnName + ";"); //loadDataBody.Append("\n\t\t\t\t//------------------------------------------"); } else if (column.Name == "FileExtension") { //hasFile = true; loadDataBody.Append("\n\t\t\t\tif (" + global.EntityClassObject + ".HasFileExtension)"); loadDataBody.Append("\n\t\t\t\t{"); //Add Urls Property SiteUrlsBuilder.AddDirectoryUrl("Files", SiteUrlsBuilder.filesUrl, Globals.GetProgramatlyName(Table), ""); loadDataBody.Append("\n\t\t\t\t\t" + fileName + ".NavigateUrl = " + SiteUrlsBuilder.GetIdentifire() + "Files + " + global.EntityClassObject + ".File;"); loadDataBody.Append("\n\t\t\t\t\t" + fileName + ".Text = " + ResourcesTesxtsBuilder.AddAdminGlobalText("DownLoadExistFile", TextType.Text) + ";"); loadDataBody.Append("\n\t\t\t\t}"); loadDataBody.Append("\n\t\t\t\telse"); loadDataBody.Append("\n\t\t\t\t{"); loadDataBody.Append("\n\t\t\t\t\t" + trPropertyName + ".Visible=false ;"); loadDataBody.Append("\n\t\t\t\t}"); //loadDataBody.Append("\n\t\t\t\t//------------------------------------------"); //loadDataBody.Append("\n\t\t\t\tViewState[\"" + ProjectBuilder.FileExtensionColumnName + "\"] = " + global.EntityClassObject + "." + ProjectBuilder.FileExtensionColumnName + ";"); //loadDataBody.Append("\n\t\t\t\t//------------------------------------------"); } else if (column.Name.IndexOf("Extension") > -1) { string[] stringSeparators = new string[] { "Extension" }; string[] separatingResult = column.Name.Split(stringSeparators, StringSplitOptions.None); propertyName = separatingResult[0]; string uploaderID = "fu" + propertyName; string downloadLinkID = "hl" + propertyName; //hasFile = true; loadDataBody.Append("\n\t\t\t\tif (" + global.EntityClassObject + ".Has" + propertyName + "Extension)"); loadDataBody.Append("\n\t\t\t\t{"); //Add Urls Property SiteUrlsBuilder.AddDirectoryUrl(propertyName + "s", SiteUrlsBuilder.otherFilesUrl, Globals.GetProgramatlyName(Table), propertyName + "s"); loadDataBody.Append("\n\t\t\t\t\t" + downloadLinkID + ".NavigateUrl = " + SiteUrlsBuilder.GetIdentifire() + propertyName + "s + " + global.EntityClassObject + "." + propertyName + ";"); loadDataBody.Append("\n\t\t\t\t\t" + downloadLinkID + ".Text =" + ResourcesTesxtsBuilder.AddAdminGlobalText("DownLoadExistFile", TextType.Text) + ";"); loadDataBody.Append("\n\t\t\t\t}"); loadDataBody.Append("\n\t\t\t\telse"); loadDataBody.Append("\n\t\t\t\t{"); loadDataBody.Append("\n\t\t\t\t\t" + trPropertyName + ".Visible=false ;"); loadDataBody.Append("\n\t\t\t\t}"); //loadDataBody.Append("\n\t\t\t\t//------------------------------------------"); //loadDataBody.Append("\n\t\t\t\tViewState[\"" + Globals.GetProgramatlyName(column.Name) + "\"] = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ";"); //loadDataBody.Append("\n\t\t\t\t//------------------------------------------"); } else if (column.Name.IndexOf("Date") > -1) { loadDataBody.Append("\n\t\t\t\t//-------------------------------"); loadDataBody.Append("\n\t\t\t\t//" + Globals.GetProgramatlyName(column.Name)); loadDataBody.Append("\n\t\t\t\tif (" + global.EntityClassObject + "." + optionalPropertyName + ")"); loadDataBody.Append("\n\t\t\t\t\tlbl" + Globals.GetProgramatlyName(column.Name) + ".Text = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ".ToString();"); loadDataBody.Append("\n\t\t\t\telse"); loadDataBody.Append("\n\t\t\t\t\t" + trPropertyName + ".Visible=false ;"); loadDataBody.Append("\n\t\t\t\t//-------------------------------"); } else if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.NText) { loadDataBody.Append("\n\t\t\t\t//-------------------------------"); loadDataBody.Append("\n\t\t\t\t//" + Globals.GetProgramatlyName(column.Name)); loadDataBody.Append("\n\t\t\t\tif (" + global.EntityClassObject + "." + optionalPropertyName + ")"); loadDataBody.Append("\n\t\t\t\t\tlbl" + Globals.GetProgramatlyName(column.Name) + ".Text = Globals.SetLines(" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ");"); loadDataBody.Append("\n\t\t\t\telse"); loadDataBody.Append("\n\t\t\t\t\t" + lblPropertyName + ".Visible=false ;"); loadDataBody.Append("\n\t\t\t\t//-------------------------------"); } else { loadDataBody.Append("\n\t\t\t\t//-------------------------------"); loadDataBody.Append("\n\t\t\t\t//" + Globals.GetProgramatlyName(column.Name)); loadDataBody.Append("\n\t\t\t\tif (" + global.EntityClassObject + "." + optionalPropertyName + ")"); loadDataBody.Append("\n\t\t\t\t\tlbl" + Globals.GetProgramatlyName(column.Name) + ".Text = Globals.SetLines(" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ");"); loadDataBody.Append("\n\t\t\t\telse"); loadDataBody.Append("\n\t\t\t\t\t" + trPropertyName + ".Visible=false ;"); loadDataBody.Append("\n\t\t\t\t//-------------------------------"); } } else { } } else if (datatype == "bool") { //loadDataBody.Append("\n\t\t\t\tcb" + Globals.GetProgramatlyName(column.Name) + ".Checked = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ";"); loadDataBody.Append("\n\t\t\t\tlbl" + Globals.GetProgramatlyName(column.Name) + ".Text = " + ResourcesTesxtsBuilder.AddUserText("True", TextType.Text) + ";"); } else if (datatype != "byte[]" && datatype != "Object" && datatype != "Guid") { if (cnstr == null) { loadDataBody.Append("\n\t\t\t\tlbl" + Globals.GetProgramatlyName(column.Name) + ".Text = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ".ToString();"); } else { //string text = SqlProvider.obj.GetExpectedNameForParent(cnstr.ParentTable); //string _value = Globals.GetProgramatlyName(cnstr.ParentColID); //string ddl; //string methodName; //BuildDropDownListsLoaderMethod(cnstr.ParentTable, text, _value, out ddl, out methodName); //loadDataBody.Append("\n\t\t\t\t" + methodName + ";"); //loadDataBody.Append("\n\t\t\t\t" + ddl + ".SelectedValue = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ".ToString();"); } } } } //End of object null value check loadDataEnd.Append("\n\t\t\t}"); loadDataEnd.Append("\n\t\t\telse"); loadDataEnd.Append("\n\t\t\t{"); loadDataEnd.Append("\n\t\t\t\tResponse.Redirect(\"default.aspx\");"); loadDataEnd.Append("\n\t\t\t}"); //------------------------------------- //End of envalid parammeter check loadDataEnd.Append("\n\t\t}"); loadDataEnd.Append("\n\t\telse"); loadDataEnd.Append("\n\t\t{"); loadDataEnd.Append("\n\t\t\tResponse.Redirect(\"default.aspx\");"); loadDataEnd.Append("\n\t\t}"); loadDataEnd.Append("\n\t}"); loadDataEnd.Append("\n\t//-----------------------------------------------"); loadDataEnd.Append("\n\t#endregion"); return(loadDataStart.ToString() + loadDataChecks.ToString() + loadDataBody.ToString() + loadDataEnd.ToString()); }
// public void CreateTemplate() { StringBuilder template = new StringBuilder(); StringBuilder propreties = new StringBuilder(); string repeaterID = "dl" + global.TableProgramatlyName; //xmlTag //template.Append("\n\t\t\t"); //-------------------------- string datatype; string propertyName; string fullOptionalPropertyName; string idName = Globals.GetProgramatlyName(ID.Name);; string detailsPageName = "DetailsPage"; string detailsPagePath = "App_Forms/" + Table + "/details.aspx?" + Globals.GetProgramatlyName(ID.Name) + "={0}"; SiteUrlsBuilder.AddUrl(detailsPageName, detailsPagePath); foreach (SQLDMO.Column column in Fields) { propertyName = Globals.GetProgramatlyName(column.Name); fullOptionalPropertyName = SiteOptionsBuilder.GetFullHasPropertyString(propertyName); if ((ID == null || column.Name != ID.Name) && (column.Name.IndexOf("_") < 0) && column.Name.ToLower().IndexOf("password") < 0 && column.Name.ToLower().IndexOf("shortdescription") < 0 && column.Name.ToLower().IndexOf("priority") < 0 && column.Name.ToLower().IndexOf("isavailable ") < 0 && column.Name.ToLower() != ProjectBuilder.LangID) { TableConstraint cnstr = SqlProvider.obj.GetParentColumn(column.Name); datatype = Globals.GetAliasDataType(column.Datatype); if (datatype == "bool") { } else if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.NText) { if (column.Name.ToLower().IndexOf("details") > -1) { hasDetails = true; detailsProprety = Globals.GetProgramatlyName(column.Name); } else if (column.Name.ToLower().IndexOf("description") > -1) { hasDescription = true; descriptionProprety = Globals.GetProgramatlyName(column.Name); } } else if (datatype != "byte[]" && datatype != "Object" && datatype != "Guid" && column.Name.ToLower().IndexOf("password") < 0 && column.Name.ToLower() != ProjectBuilder.LangID) { if (column.Name.IndexOf(ProjectBuilder.ExtensionInColumnName) > -1) { if (column.Name == ProjectBuilder.PhotoExtensionColumnName) { hasPhoto = true; photoProprety = Globals.GetProgramatlyName(column.Name); } else if (column.Name == "LogoExtension") { hasLogo = true; logoProprety = Globals.GetProgramatlyName(column.Name); } } else if (column.Name.ToLower().IndexOf("description") > -1) { hasDescription = true; descriptionProprety = Globals.GetProgramatlyName(column.Name); } else if (column.Name.ToLower().IndexOf("title") > -1) { hasTitle = true; titleProprety = Globals.GetProgramatlyName(column.Name); } else { //---------------------------------------- if (ProjectBuilder.HasConfiguration) { propreties.Append("\n\t\t\t\t<tr runat=\"server\" visible=\"<%# SiteOptions.CheckOption(" + SiteOptionsBuilder.GetFullPropertyPath(fullOptionalPropertyName) + ") %>\">"); } else { propreties.Append("\n\t\t\t\t<tr>"); } propreties.Append("\n\t\t\t\t\t<td class=\"GText\">"); propreties.Append("\n\t\t\t\t\t\t<span class=\"GText\">" + ResourcesTesxtsBuilder.AddUserText(Globals.GetProgramatlyName(column.Name), TextType.HtmlClassic) + ": </span>"); propreties.Append("\n\t\t\t\t\t\t<span class=\"GValue\"><%#Eval(\"" + propertyName + "\") %></span>"); propreties.Append("\n\t\t\t\t\t</td>"); propreties.Append("\n\t\t\t\t\t</tr>"); //---------------------------------------- } } } } template.Append("\n<!-- ------------------------ " + repeaterID + " ------------------------ -->"); template.Append("\n<asp:DataList Width=\"100%\" ID=\"" + repeaterID + "\" RepeatColumns=\"1\" runat=\"server\">"); template.Append("\n\t<ItemTemplate>"); template.Append("\n\t\t<table cellspacing=\"0\" cellpadding=\"0\" class=\"GTable\" border=\"0\">"); template.Append("\n\t\t\t<tr>"); template.Append("\n\t\t\t\t<td style=\"width: 100%; vertical-align:top;\">"); template.Append("\n\t\t\t\t\t<table class=\"GData\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">"); if (hasTitle) { string titleFullOptionalPropertyName = SiteOptionsBuilder.GetFullHasPropertyString(titleProprety); if (ProjectBuilder.HasConfiguration) { template.Append("\n\t\t\t\t\t<tr runat=\"server\" visible=\"<%# SiteOptions.CheckOption(" + SiteOptionsBuilder.GetFullPropertyPath(titleFullOptionalPropertyName) + ") %>\">"); } else { template.Append("\n\t\t\t\t\t<tr>"); } template.Append("\n\t\t\t\t\t\t<td class=\"GTitle\">"); template.Append("\n\t\t\t\t\t\t\t<a class=\"GTitle\" href='<%# " + SiteUrlsBuilder.GetTheGetUrlMethodIdentifire() + "(\"" + detailsPageName + "\",Eval(\"" + idName + "\")) %>'>"); template.Append("\n\t\t\t\t\t\t\t\t<%# Globals.SubStringByWords(DataBinder.Eval(Container, \"DataItem." + titleProprety + "\"),10) %>"); template.Append("\n\t\t\t\t\t\t\t</a>"); template.Append("\n\t\t\t\t\t\t</td>"); template.Append("\n\t\t\t\t\t</tr>"); } if (hasDetails) { string detailsFullOptionalPropertyName = SiteOptionsBuilder.GetFullHasPropertyString(detailsProprety); if (ProjectBuilder.HasConfiguration) { template.Append("\n\t\t\t\t\t<tr runat=\"server\" visible=\"<%# SiteOptions.CheckOption(" + SiteOptionsBuilder.GetFullPropertyPath(detailsFullOptionalPropertyName) + ") %>\">"); } else { template.Append("\n\t\t\t\t\t<tr>"); } template.Append("\n\t\t\t\t\t\t<td class=\"GDetails\">"); template.Append("\n\t\t\t\t\t\t\t\t<%# Globals.SubStringByWords(DataBinder.Eval(Container, \"DataItem." + detailsProprety + "\"), 30)%>"); template.Append("\n\t\t\t\t\t\t\t</td>"); template.Append("\n\t\t\t\t\t\t</tr>"); } if (hasDescription) { string descriptionFullOptionalPropertyName = SiteOptionsBuilder.GetFullHasPropertyString(descriptionProprety); if (ProjectBuilder.HasConfiguration) { template.Append("\n\t\t\t\t\t<tr runat=\"server\" visible=\"<%# SiteOptions.CheckOption(" + SiteOptionsBuilder.GetFullPropertyPath(descriptionFullOptionalPropertyName) + ") %>\">"); } else { template.Append("\n\t\t\t\t\t<tr>"); } template.Append("\n\t\t\t\t\t\t<td class=\"GDetails\">"); template.Append("\n\t\t\t\t\t\t\t\t<%# Globals.SubStringByWords(DataBinder.Eval(Container, \"DataItem." + descriptionProprety + "\"), 30)%>"); template.Append("\n\t\t\t\t\t\t\t</td>"); template.Append("\n\t\t\t\t\t\t</tr>"); } template.Append(propreties.ToString()); template.Append("\n\t\t\t\t\t</table>"); template.Append("\n\t\t\t\t</td>"); if (hasPhoto || hasLogo) { template.Append("\n\t\t\t\t<td style=\"text-align:center; vertical-align:top;\">"); if (hasPhoto) { string photoFullOptionalPropertyName = SiteOptionsBuilder.GetFullHasPropertyString(photoProprety); if (ProjectBuilder.HasConfiguration) { template.Append("\n\t\t\t\t\t<table runat=\"server\" visible=\"<%# SiteOptions.CheckOption(" + SiteOptionsBuilder.GetFullPropertyPath(photoFullOptionalPropertyName) + ") %>\" cellpadding=\"0\" cellspacing=\"0\" class=\"GImageContainer\">"); } else { template.Append("\n\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" class=\"GImageContainer\">"); } template.Append("\n\t\t\t\t\t\t<tr>"); template.Append("\n\t\t\t\t\t\t\t<td>"); template.Append("\n\t\t\t\t\t\t\t\t<a href='<%# " + SiteUrlsBuilder.GetTheGetUrlMethodIdentifire() + "(\"" + detailsPageName + "\",Eval(\"" + idName + "\")) %>'>"); template.Append("\n\t\t\t\t\t\t\t\t\t<img alt=\"<%# DataBinder.Eval(Container, \"DataItem." + titleProprety + "\") %>\""); template.Append("\n\t\t\t\t\t\t\t\t\t\tclass=\"GImage\" src='<%# " + global.TableFactoryClass + ".Get" + global.TableProgramatlyName + "PhotoThumbnail(Eval(\"" + idName + "\"),Eval(\"" + photoProprety + "\")) %>' /></a>"); template.Append("\n\t\t\t\t\t\t\t</td>"); template.Append("\n\t\t\t\t\t\t</tr>"); template.Append("\n\t\t\t\t\t</table>"); } if (hasLogo) { string logoFullOptionalPropertyName = SiteOptionsBuilder.GetFullHasPropertyString(logoProprety); if (ProjectBuilder.HasConfiguration) { template.Append("\n\t\t\t\t\t<table runat=\"server\" visible=\"<%# SiteOptions.CheckOption(" + SiteOptionsBuilder.GetFullPropertyPath(logoFullOptionalPropertyName) + ") %>\" cellpadding=\"0\" cellspacing=\"0\" class=\"GImageContainer\">"); } else { template.Append("\n\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" class=\"GImageContainer\">"); } template.Append("\n\t\t\t\t\t\t<tr>"); template.Append("\n\t\t\t\t\t\t\t<td>"); template.Append("\n\t\t\t\t\t\t\t\t<a href='<%# " + SiteUrlsBuilder.GetTheGetUrlMethodIdentifire() + "(\"" + detailsPageName + "\",Eval(\"" + idName + "\")) %>'>"); template.Append("\n\t\t\t\t\t\t\t\t\t<img alt=\"<%# DataBinder.Eval(Container, \"DataItem." + titleProprety + "\") %>\""); template.Append("\n\t\t\t\t\t\t\t\t\t\tclass=\"GImage\" src='<%# " + global.TableFactoryClass + ".Get" + global.TableProgramatlyName + "LogoThumbnail(Eval(\"" + idName + "\"),Eval(\"" + logoProprety + "\")) %>' /></a>"); template.Append("\n\t\t\t\t\t\t\t</td>"); template.Append("\n\t\t\t\t\t\t</tr>"); template.Append("\n\t\t\t\t\t</table>"); } template.Append("\n\t\t\t\t</td>"); } template.Append("\n\t\t\t</tr>"); template.Append("\n\t\t</table>"); template.Append("\n\t</ItemTemplate>"); template.Append("\n</asp:DataList>"); template.Append("\n<!-- ------------------------ --------------- ------------------------ -->"); // AppTemplates.Append(template.ToString()); }
//---------------------------------- #region Old and Unused code /// <summary> /// Generates code for an UPDATE or INSERT Stored Procedure /// </summary> /// <param name="sptypeGenerate">The type of SP to generate, INSERT or UPDATE</param> /// <param name="Fields">A ColumnCollection collection</param> /// <returns>The SP code</returns> private void Generate(StoredProcedureTypes sptypeGenerate, SqlProvider dmoMain) { try { StringBuilder sGeneratedCode = new StringBuilder(); StringBuilder sParamDeclaration = new StringBuilder(); StringBuilder sBody = new StringBuilder(); StringBuilder sINSERTValues = new StringBuilder(); string finnal = ""; // Setup SP code, begining is the same no matter the type sGeneratedCode.AppendFormat("CREATE PROCEDURE {0}.[{1}_{2}]", new string[] { SqlProvider.obj.DatabaseOwner, Globals.GetProgramatlyName(Table), sptypeGenerate.ToString() }); sGeneratedCode.Append(Environment.NewLine); // Setup body code, different for UPDATE and INSERT switch (sptypeGenerate) { case StoredProcedureTypes.Create: sBody.AppendFormat("INSERT INTO [{0}] (", Table); sBody.Append(Environment.NewLine); sINSERTValues.Append("VALUES ("); sINSERTValues.Append(Environment.NewLine); break; case StoredProcedureTypes.Update: sBody.AppendFormat("UPDATE [{0}]", Table); sBody.Append(Environment.NewLine); sBody.Append("SET"); sBody.Append(Environment.NewLine); break; case StoredProcedureTypes.GetAll: sBody.AppendFormat("Select * From [{0}] ", Table); sBody.Append(Environment.NewLine); break; case StoredProcedureTypes.GetOneByID: sBody.AppendFormat("Select * From [{0}] ", Table); sBody.Append(Environment.NewLine); break; case StoredProcedureTypes.Delete: sBody.AppendFormat("Delete * From [{0}] ", Table); sBody.Append(Environment.NewLine); break; } #region Add Parametars if (sptypeGenerate == StoredProcedureTypes.GetAll) { sGeneratedCode.Append("AS"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sBody.Remove(sBody.Length - 3, 3)); } else if (sptypeGenerate != StoredProcedureTypes.GetOneByID || sptypeGenerate != StoredProcedureTypes.Delete) { //The finanal of procedure if (ID != null) { sParamDeclaration.AppendFormat(" @{0} {1}", new string[] { Globals.GetProgramatlyName(ID.Name), ID.Datatype }); finnal = "Where [" + ID.Name + "] =@" + Globals.GetProgramatlyName(ID.Name); } } else { foreach (Column colCurrent in Fields) { if (ID != null && colCurrent.Name == ID.Name) { sParamDeclaration.AppendFormat(" @{0} {1}", new string[] { Globals.GetProgramatlyName(colCurrent.Name), colCurrent.Datatype }); } if (ID != null && colCurrent.Name == ID.Name && Globals.CheckIsAddedBySql(colCurrent) && sptypeGenerate == StoredProcedureTypes.Create) { sParamDeclaration.AppendFormat(" out"); } // Only binary, char, nchar, nvarchar, varbinary and varchar may have their length declared if ( colCurrent.Datatype == "binary" || colCurrent.Datatype == "char" || colCurrent.Datatype == "nchar" || colCurrent.Datatype == "nvarchar" || colCurrent.Datatype == "varbinary" || colCurrent.Datatype == "varchar") { sParamDeclaration.AppendFormat("({0})", colCurrent.Length); } sParamDeclaration.Append(","); sParamDeclaration.Append(Environment.NewLine); // Body construction, different for INSERT and UPDATE switch (sptypeGenerate) { case StoredProcedureTypes.Create: //not Added BySQL if (ID == null && colCurrent.Name != ID.Name || !Globals.CheckIsAddedBySql(colCurrent)) { sINSERTValues.AppendFormat(" @{0},", Globals.GetProgramatlyName(colCurrent.Name)); sINSERTValues.Append(Environment.NewLine); sBody.AppendFormat(" [{0}],", colCurrent.Name); sBody.Append(Environment.NewLine); } break; case StoredProcedureTypes.Update: if (ID == null && colCurrent.Name != ID.Name) { sBody.AppendFormat(" [{0}] = @{1},", new string[] { colCurrent.Name, Globals.GetProgramatlyName(colCurrent.Name) }); sBody.Append(Environment.NewLine); } break; case StoredProcedureTypes.GetOneByID: // sBody.AppendFormat("Where {0} = @{0},", new string[]{colCurrent.Name, }); sBody.Append(Environment.NewLine); break; } } //The finanal of procedure if (ID != null) { if (sptypeGenerate == StoredProcedureTypes.Create && Globals.CheckIsAddedBySql(ID)) { finnal = "Set @" + Globals.GetProgramatlyName(ID.Name) + " = @@Identity"; } else if (sptypeGenerate == StoredProcedureTypes.Update) { finnal = "Where [" + ID.Name + "] =@" + Globals.GetProgramatlyName(ID.Name); } } #endregion // Now stitch the body parts together into the SP whole sGeneratedCode.Append(sParamDeclaration.Remove(sParamDeclaration.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append("AS"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sBody.Remove(sBody.Length - 3, 3)); if (sptypeGenerate == StoredProcedureTypes.Create) { sGeneratedCode.Append(")"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sINSERTValues.Remove(sINSERTValues.Length - 3, 3)); sGeneratedCode.Append(")"); } } sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(finnal); WriteStoredProcedure(sGeneratedCode.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); } }
//--------------------------------- /// <summary> /// Generates code for INSERT Stored Procedure /// </summary> /// <param name="sptypeGenerate">The type of SP to generate, INSERT</param> /// <param name="Fields">A ColumnCollection collection</param> /// <returns>The SP code</returns> private void GenerateInsertProcedure() { try { StringBuilder sGeneratedCode = new StringBuilder(); StringBuilder sParamDeclaration = new StringBuilder(); StringBuilder sBody = new StringBuilder(); StringBuilder sINSERTValues = new StringBuilder(); string finnal = ""; // Setup SP code, begining is the same no matter the type sGeneratedCode.AppendFormat("CREATE PROCEDURE {0}.[{1}_{2}]", new string[] { SqlProvider.obj.DatabaseOwner, Globals.GetProgramatlyName(Table), StoredProcedureTypes.Create.ToString() }); sGeneratedCode.Append(Environment.NewLine); // Setup body code, different for UPDATE and INSERT sBody.AppendFormat("INSERT INTO [{0}] (", Table); sBody.Append(Environment.NewLine); sINSERTValues.Append("VALUES ("); sINSERTValues.Append(Environment.NewLine); #region Add Parametars foreach (Column colCurrent in Fields) { sParamDeclaration.AppendFormat(" @{0} {1}", new string[] { Globals.GetProgramatlyName(colCurrent.Name), colCurrent.Datatype }); if (ID != null && colCurrent.Name == ID.Name && Globals.CheckIsAddedBySql(colCurrent)) { sParamDeclaration.AppendFormat(" out"); } // Only binary, char, nchar, nvarchar, varbinary and varchar may have their length declared if ( colCurrent.Datatype == "binary" || colCurrent.Datatype == "char" || colCurrent.Datatype == "nchar" || colCurrent.Datatype == "nvarchar" || colCurrent.Datatype == "varbinary" || colCurrent.Datatype == "varchar") { sParamDeclaration.AppendFormat("({0})", colCurrent.Length); } sParamDeclaration.Append(","); sParamDeclaration.Append(Environment.NewLine); // Body construction //not Added BySQL if (ID == null || colCurrent.Name != ID.Name || !Globals.CheckIsAddedBySql(colCurrent)) { sINSERTValues.AppendFormat(" @{0},", Globals.GetProgramatlyName(colCurrent.Name)); sINSERTValues.Append(Environment.NewLine); sBody.AppendFormat(" [{0}],", colCurrent.Name); sBody.Append(Environment.NewLine); } } if (ID != null && Globals.CheckIsAddedBySql(ID)) { finnal = "Set @" + Globals.GetProgramatlyName(ID.Name) + " = @@Identity"; } #endregion // Now stitch the body parts together into the SP whole sGeneratedCode.Append(sParamDeclaration.Remove(sParamDeclaration.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append("AS"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sBody.Remove(sBody.Length - 3, 3)); sGeneratedCode.Append(")"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sINSERTValues.Remove(sINSERTValues.Length - 3, 3)); sGeneratedCode.Append(")"); // sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(finnal); WriteStoredProcedure(sGeneratedCode.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); } }
//--------------------------------- /// <summary> /// Generates code for an GetAll Stored Procedure /// </summary> /// <param name="sptypeGenerate">The type of SP to generate, INSERT or UPDATE</param> /// <param name="Fields">A ColumnCollection collection</param> /// <returns>The SP code</returns> private void GenerateGetAllProcedure() { try { StringBuilder sGeneratedCode = new StringBuilder(); StringBuilder sParamDeclaration = new StringBuilder(); StringBuilder sBody = new StringBuilder(); StringBuilder sINSERTValues = new StringBuilder(); string finnal = ""; // Setup SP code, begining is the same no matter the type sGeneratedCode.AppendFormat("CREATE PROCEDURE {0}.[{1}_{2}]", new string[] { SqlProvider.obj.DatabaseOwner, Globals.GetProgramatlyName(Table), StoredProcedureTypes.GetAll.ToString() }); sGeneratedCode.Append(Environment.NewLine); // Setup body code, different for UPDATE and INSERT sBody.AppendFormat("Select * From [{0}] ", Table); sBody.Append(Environment.NewLine); sGeneratedCode.Append("AS"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sBody.Remove(sBody.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(finnal); WriteStoredProcedure(sGeneratedCode.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); } }
// private string Create_CreateButtonHandler() { StringBuilder _CreateButtonHandler = new StringBuilder(); _CreateButtonHandler.Append("\n\tprotected void btnCreate_Click(object sender, System.EventArgs e)"); _CreateButtonHandler.Append("\n\t{"); _CreateButtonHandler.Append("\n\t\tif (!Page.IsValid)"); _CreateButtonHandler.Append("\n\t\t{"); _CreateButtonHandler.Append("\n\t\t\treturn;"); _CreateButtonHandler.Append("\n\t\t}"); _CreateButtonHandler.Append("\n\t\t" + global.TableEntityClass + " " + global.EntityClassObject + " = new " + global.TableEntityClass + "();"); string datatype; foreach (SQLDMO.Column column in Fields) { if (allParameters != null && !allParameters.Contains(column.Name)) { continue; } if (ID == null || column.Name != ID.Name || !Globals.CheckIsAddedBySql(ID)) { datatype = Globals.GetAliasDataType(column.Datatype); TableConstraint cnstr = SqlProvider.obj.GetParentColumn(column.Name); if (datatype == "string") { if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.NText) { _CreateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = fck" + Globals.GetProgramatlyName(column.Name) + ".Value;"); } else { if (cnstr == null) { _CreateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = txt" + Globals.GetProgramatlyName(column.Name) + ".Text;"); } else { _CreateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = ddl" + Globals.GetProgramatlyName(cnstr.ParentTable) + ".SelectedValue;"); } } } //DateTime else if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.DateTime) { _CreateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = Convert.To" + Globals.GetDataType(column.Datatype) + "(txt" + Globals.GetProgramatlyName(column.Name) + ".Value);"); } //DateTime else if (datatype == "bool") { _CreateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = cb" + Globals.GetProgramatlyName(column.Name) + ".Checked;"); } else if (datatype == "Guid") { _CreateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = Guid.NewGuid();"); } else if (datatype != "byte[]" && datatype != "Object") { if (cnstr == null) { _CreateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = Convert.To" + Globals.GetDataType(column.Datatype) + "(txt" + Globals.GetProgramatlyName(column.Name) + ".Text);"); } else { _CreateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = Convert.To" + Globals.GetDataType(column.Datatype) + "(ddl" + Globals.GetProgramatlyName(cnstr.ParentTable) + ".SelectedValue);"); } } } } _CreateButtonHandler.Append("\n\t\tbool result = " + global.TableFactoryClass + "." + MethodType.Create.ToString() + "(" + global.EntityClassObject + ");"); _CreateButtonHandler.Append("\n\t\tif(result)"); _CreateButtonHandler.Append("\n\t\t{"); _CreateButtonHandler.Append("\n\t\t\tlblResult.ForeColor=Color.Blue ;"); _CreateButtonHandler.Append("\n\t\t\tlblResult.Text=\"Êã ÇáÅÖÇÝÉ ÈäÌÇÍ\";"); _CreateButtonHandler.Append("\n\t\t\t" + global.ClearControlsMethod + ";"); _CreateButtonHandler.Append("\n\t\t}"); _CreateButtonHandler.Append("\n\t\telse"); _CreateButtonHandler.Append("\n\t\t{"); _CreateButtonHandler.Append("\n\t\t\tlblResult.ForeColor=Color.Red ;"); _CreateButtonHandler.Append("\n\t\t\tlblResult.Text=\"ÝÔáÊ ÚãáíÉ ÇáÅÖÇÝÉ\";"); _CreateButtonHandler.Append("\n\t\t}"); _CreateButtonHandler.Append("\n\t}"); return(_CreateButtonHandler.ToString()); }
//------------------------------------- #endregion //---------------------------------------------------------- //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX //---------------------------------------------------------- //---------------------------------------------------------- //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #region CreateGetOneMethod public string CreateGetOneMethod() { if (ID != null) { try { string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); string factoryClass = global.TableFactoryClass; string entityClass = global.TableEntityClass; string entityObject = global.EntityClassObject; //------------------------------------------------ string MethodName = "GetObject"; string MethodReturn = global.TableEntityClass; string methodParameters = id; string sqlMethodParameters = id; //XML Documentaion string xmlDocumentation = "\n\t/// <summary>\n"; xmlDocumentation += "\t/// Gets single " + SqlProvider.obj.TableName + " object .\n"; xmlDocumentation += "\t/// <example>[Example]" + MethodReturn + " " + global.EntityClassList + "=" + ClassName + "." + MethodName + "(" + sqlMethodParameters + ");.</example>\n"; xmlDocumentation += "\t/// </summary>\n"; xmlDocumentation += "\t/// <param name=\"" + id + "\">The " + global.EntityClassObject + " id.</param>\n"; xmlDocumentation += "\t/// <returns>" + SqlProvider.obj.TableName + " object.</returns>"; //Method Body StringBuilder methodBody = new StringBuilder(); methodBody.Append("\n\t#region --------------" + MethodName + "--------------"); if (ProjectBuilder.AllowXmlDocumentation) { methodBody.Append(xmlDocumentation); } methodBody.Append("\n\tpublic static " + MethodReturn + " " + MethodName + "(" + Globals.GetAliasDataType(ID.Datatype) + " " + methodParameters + ")"); methodBody.Append("\n\t{"); //------------ methodBody.Append("\n\t\tstring cacheKey = GetChacheKey(" + id + ");"); methodBody.Append("\n\t\t" + entityClass + " " + entityObject + ";"); //methodBody.Append("\n\t\tCache contextCache = HttpContext.Current.Cache;"); //methodBody.Append("\n\t\tCache applicationCache = HttpRuntime.Cache;"); methodBody.Append("\n\t\tobject cachedObject = OurCache.Get(cacheKey);"); methodBody.Append("\n\t\t//Check is object cached into our cache"); methodBody.Append("\n\t\tif (cachedObject == null)"); methodBody.Append("\n\t\t{"); //methodBody.Append("\n\t\t\t//Check is object cached into application cache"); // methodBody.Append("\n\t\t\tif (cachedObject == null)"); //methodBody.Append("\n\t\t\t{"); methodBody.Append("\n\t\t\t" + entityObject + " = " + global.SqlDataProviderClass + ".Instance." + MethodName + "(" + id + ");"); methodBody.Append("\n\t\t\tif (" + entityObject + " == null)"); methodBody.Append("\n\t\t\t\treturn null;"); methodBody.Append("\n\t\t\t//Save object into application cache"); methodBody.Append("\n\t\t\tOurCache.Insert(cacheKey, " + entityObject + ", 3 * OurCache.MinuteFactor);"); /* * methodBody.Append("\n\t\t\t\tapplicationCache[cacheKey] = " + entityObject + ";"); * methodBody.Append("\n\t\t\t\t//Save object into httpContext cache"); * methodBody.Append("\n\t\t\t\tcontextCache[cacheKey] = " + entityObject + ";"); * methodBody.Append("\n\t\t\t}"); * methodBody.Append("\n\t\t\telse"); * methodBody.Append("\n\t\t\t{"); * methodBody.Append("\n\t\t\t\t//get object from application cache"); * methodBody.Append("\n\t\t\t\t" + entityObject + " = (" + entityClass + ")applicationCache[cacheKey];"); * methodBody.Append("\n\t\t\t\t//Save object into httpContext cache"); * methodBody.Append("\n\t\t\t\tcontextCache[cacheKey] = " + entityObject + ";"); * methodBody.Append("\n\t\t\t}");*/ methodBody.Append("\n\t\t}"); methodBody.Append("\n\t\telse"); methodBody.Append("\n\t\t{"); methodBody.Append("\n\t\t\t//get object from httpContext cache"); methodBody.Append("\n\t\t\t" + entityObject + " = (" + entityClass + ")cachedObject;"); methodBody.Append("\n\t\t}"); methodBody.Append("\n\t\t//return the object"); methodBody.Append("\n\t\treturn " + entityObject + ";"); //------------ methodBody.Append("\n\t}"); methodBody.Append("\n\t" + Globals.MetthodsSeparator); methodBody.Append("\n\t#endregion"); return(methodBody.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } } else { return(""); } }
//--------------------------------- /// <summary> /// Generates code for an UPDATE or INSERT Stored Procedure /// </summary> /// <param name="sptypeGenerate">The type of SP to generate, INSERT or UPDATE</param> /// <param name="Fields">A ColumnCollection collection</param> /// <returns>The SP code</returns> private string GenerateUpdatePrcedure(Hashtable allParameters, Hashtable whereParameters) { try { StringBuilder sGeneratedCode = new StringBuilder(); StringBuilder sParamDeclaration = new StringBuilder(); StringBuilder sBody = new StringBuilder(); StringBuilder sINSERTValues = new StringBuilder(); // Setup SP code, begining is the same no matter the type sGeneratedCode.AppendFormat("CREATE PROCEDURE {0}.[{1}_{2}]", new string[] { SqlProvider.obj.DatabaseOwner, Globals.GetProgramatlyName(SqlProvider.obj.TableName), ProcedureAndMethodName }); sGeneratedCode.Append(Environment.NewLine); // Setup body code, different for UPDATE and INSERT sBody.AppendFormat("UPDATE [{0}]", SqlProvider.obj.TableName); sBody.Append(Environment.NewLine); sBody.Append("SET"); sBody.Append(Environment.NewLine); #region Add Parametars foreach (Column colCurrent in SqlProvider.obj.Fields) { if (!allParameters.Contains(colCurrent.Name)) { continue; } sParamDeclaration.AppendFormat(" @{0} {1}", new string[] { Globals.GetProgramatlyName(colCurrent.Name), colCurrent.Datatype }); // Only binary, char, nchar, nvarchar, varbinary and varchar may have their length declared if ( colCurrent.Datatype == "binary" || colCurrent.Datatype == "char" || colCurrent.Datatype == "nchar" || colCurrent.Datatype == "nvarchar" || colCurrent.Datatype == "varbinary" || colCurrent.Datatype == "varchar") { sParamDeclaration.AppendFormat("({0})", colCurrent.Length); } sParamDeclaration.Append(","); sParamDeclaration.Append(Environment.NewLine); // Body construction, different for INSERT and UPDATE if (SqlProvider.obj.ID == null || colCurrent.Name != SqlProvider.obj.ID.Name) { sBody.AppendFormat(" [{0}] = @{1},", new string[] { colCurrent.Name, Globals.GetProgramatlyName(colCurrent.Name) }); sBody.Append(Environment.NewLine); } } #endregion // Now stitch the body parts together into the SP whole sGeneratedCode.Append(sParamDeclaration.Remove(sParamDeclaration.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append("AS"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sBody.Remove(sBody.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); // sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(CreateWhereStatement(whereParameters)); //WriteStoredProcedure(sGeneratedCode.ToString()); return(sGeneratedCode.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } }
// private string CreateLoadData() { StringBuilder loadData = new StringBuilder(); loadData.Append("\n\tprivate void LoadData()"); loadData.Append("\n\t{"); loadData.Append("\n\t\tDataTable dtSource= " + global.TableFactoryClass + "." + StoredProcedureTypes.GetAll.ToString() + "();"); loadData.Append("\n\t\tif(dtSource!=null&&dtSource.Rows.Count >0)"); loadData.Append("\n\t\t{"); loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataSource= dtSource;"); if (ID != null) { loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataKeyField=\"" + Globals.GetProgramatlyName(ID.Name) + "\";"); } loadData.Append("\n\t\t\tif(" + global.ViewAllDataGrid + ".PageSize>=dtSource.Rows.Count)"); loadData.Append("\n\t\t\t{"); loadData.Append("\n\t\t\t\t" + global.ViewAllDataGrid + ".AllowPaging=false;"); loadData.Append("\n\t\t\t}"); loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataBind();"); loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".Visible = true;"); loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".UpdateAfterCallBack = true;"); loadData.Append("\n\t\t\tlblMsg.Visible = false;"); loadData.Append("\n\t\t}"); loadData.Append("\n\t\telse"); loadData.Append("\n\t\t{"); loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".Visible=false;"); loadData.Append("\n\t\t\tlblMsg.Visible = true;"); loadData.Append("\n\t\t}"); loadData.Append("\n\t}"); return(loadData.ToString()); }
private string CreateGetOne4ShowMethod(StoredProcedureTypes type) { if (ID != null) { try { string id = Globals.GetProgramatlyName(ID.Name); id = Globals.ConvetStringToCamelCase(id); // string ProcName = global.TableProgramatlyName + "_" + type.ToString(); string MethodName = "Get" + global.TableProgramatlyName + "Object4Show"; string MethodReturn = global.TableEntityClass; //XML Documentaion string xmlDocumentation = "\t/// <summary>\n"; xmlDocumentation += "\t/// Gets single " + SqlProvider.obj.TableName + " object .\n"; xmlDocumentation += "\t/// <example>[Example]" + global.TableEntityClass + " " + global.EntityClassObject + "=" + ClassName + ".Instance." + MethodName + "(" + id + ");.</example>\n"; xmlDocumentation += "\t/// </summary>\n"; xmlDocumentation += "\t/// <param name=\"" + id + "\">The " + global.EntityClassObject + " id.</param>\n"; xmlDocumentation += "\t/// <returns>" + SqlProvider.obj.TableName + " object4Show.</returns>"; //Method Body StringBuilder methodBody = new StringBuilder(); methodBody.Append(xmlDocumentation); methodBody.Append("\n\tpublic " + MethodReturn + " " + MethodName + "(" + Globals.GetAliasDataType(ID.Datatype) + " " + id + ")"); methodBody.Append("\n\t{"); methodBody.Append("\n\t\t" + global.TableEntityClass + " " + global.EntityClassObject + " = null;"); methodBody.Append("\n\t\tusing( SqlConnection myConnection = GetSqlConnection()) "); methodBody.Append("\n\t\t{"); methodBody.Append("\n\t\t\tSqlCommand myCommand = new SqlCommand(\"" + ProcName + "\", myConnection);"); methodBody.Append("\n\t\t\tmyCommand.CommandType = CommandType.StoredProcedure;"); methodBody.Append("\n\t\t\t// Set the parameters"); methodBody.Append("\n\t\t\tmyCommand.Parameters.Add(\"@" + Globals.GetProgramatlyName(ID.Name) + "\", SqlDbType." + Globals.GetSqlDataType(ID.Datatype).ToString() + "," + ID.Length + ").Value = " + id + ";"); methodBody.Append("\n\t\t\t// Execute the command"); methodBody.Append("\n\t\t\tmyConnection.Open();"); methodBody.Append("\n\t\t\tusing(SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection))"); methodBody.Append("\n\t\t\t{"); methodBody.Append("\n\t\t\t\tif(dr.Read())"); methodBody.Append("\n\t\t\t\t{"); methodBody.Append("\n\t\t\t\t\t" + global.EntityClassObject + " = " + global.PopulateMethodName + "(dr);"); methodBody.Append("\n\t\t\t\t}"); methodBody.Append("\n\t\t\t\tdr.Close();"); methodBody.Append("\n\t\t}"); methodBody.Append("\n\t\t\tmyConnection.Close();"); //------------------------------------- methodBody.Append("\n\t\t\treturn " + global.EntityClassObject + ";"); methodBody.Append("\n\t\t}"); methodBody.Append("\n\t}"); methodBody.Append("\n\t" + Globals.MetthodsSeparator); return(methodBody.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); return(""); } } else { return(""); } }
//--------------------------------- /// <summary> /// Generates code for an UPDATE Stored Procedure /// </summary> /// <param name="sptypeGenerate">The type of SP to generate, INSERT or UPDATE</param> /// <param name="Fields">A ColumnCollection collection</param> /// <returns>The SP code</returns> private void GenerateUpdatePrcedure() { try { StringBuilder sGeneratedCode = new StringBuilder(); StringBuilder sParamDeclaration = new StringBuilder(); StringBuilder sBody = new StringBuilder(); StringBuilder sINSERTValues = new StringBuilder(); string finnal = ""; // Setup SP code, begining is the same no matter the type sGeneratedCode.AppendFormat("CREATE PROCEDURE {0}.[{1}_{2}]", new string[] { SqlProvider.obj.DatabaseOwner, Globals.GetProgramatlyName(Table), StoredProcedureTypes.Update.ToString() }); sGeneratedCode.Append(Environment.NewLine); // Setup body code, different for UPDATE and INSERT sBody.AppendFormat("UPDATE [{0}]", Table); sBody.Append(Environment.NewLine); sBody.Append("SET"); sBody.Append(Environment.NewLine); #region Add Parametars foreach (Column colCurrent in Fields) { sParamDeclaration.AppendFormat(" @{0} {1}", new string[] { Globals.GetProgramatlyName(colCurrent.Name), colCurrent.Datatype }); // Only binary, char, nchar, nvarchar, varbinary and varchar may have their length declared if ( colCurrent.Datatype == "binary" || colCurrent.Datatype == "char" || colCurrent.Datatype == "nchar" || colCurrent.Datatype == "nvarchar" || colCurrent.Datatype == "varbinary" || colCurrent.Datatype == "varchar") { sParamDeclaration.AppendFormat("({0})", colCurrent.Length); } sParamDeclaration.Append(","); sParamDeclaration.Append(Environment.NewLine); // Body construction, different for INSERT and UPDATE if (ID == null || colCurrent.Name != ID.Name) { sBody.AppendFormat(" [{0}] = @{1},", new string[] { colCurrent.Name, Globals.GetProgramatlyName(colCurrent.Name) }); sBody.Append(Environment.NewLine); } } if (ID != null) { finnal = "Where [" + ID.Name + "] =@" + Globals.GetProgramatlyName(ID.Name); } #endregion // Now stitch the body parts together into the SP whole sGeneratedCode.Append(sParamDeclaration.Remove(sParamDeclaration.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append("AS"); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(sBody.Remove(sBody.Length - 3, 3)); sGeneratedCode.Append(Environment.NewLine); sGeneratedCode.Append(finnal); WriteStoredProcedure(sGeneratedCode.ToString()); } catch (Exception ex) { MessageBox.Show("My Generated Code Exception:" + ex.Message); } }
// private string GenerateControls() { StringBuilder controls = new StringBuilder(); controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"Result\" align=\"center\" colspan=\"2\">"); controls.Append("\n\t\t\t\t\t\t<asp:Label id=\"lblResult\" runat=\"server\"></asp:Label>"); controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); string datatype; foreach (Column column in Fields) { if (allParameters != null && !allParameters.Contains(column.Name)) { continue; } if (ID == null || column.Name != ID.Name || !Globals.CheckIsAddedBySql(ID)) { datatype = Globals.GetAliasDataType(column.Datatype); if (datatype == "bool") { controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"Title\">" + column.Name + "</td>"); controls.Append("\n\t\t\t\t\t<td class=\"Control\">"); controls.Append("\n\t\t\t\t\t\t<asp:CheckBox id=\"cb" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" ValidationGroup=\"" + ClassName + "\" ></asp:CheckBox>"); controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); } else if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.NText) { controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"Title\">" + column.Name + "</td>"); controls.Append("\n\t\t\t\t\t<td class=\"Control\">"); //FREETEXTBOX controls.Append("\n\t\t\t\t\t\t<FTB:FREETEXTBOX id=\"ftb" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" TextDirection=\"RightToLeft\" "); controls.Append("\n\t\t\t\t\t\tToolbarLayout=\"Bold,Italic,Underline,Strikethrough,Superscript,Subscript;"); controls.Append("\n\t\t\t\t\t\tJustifyLeft,JustifyRight,JustifyCenter,JustifyFull;"); controls.Append("\n\t\t\t\t\t\tCut,Copy,Paste,Delete,Undo,Redo,Print,Save,ieSpellCheck|"); controls.Append("\n\t\t\t\t\t\tParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontBackColorsMenu,FontForeColorPicker,FontBackColorPicker|StyleMenu,SymbolsMenu,InsertHtmlMenu|InsertRule,InsertDate,InsertTime|WordClean|"); controls.Append("\n\t\t\t\t\t\tCreateLink,Unlink;RemoveFormat,BulletedList,NumberedList,Indent,Outdent;InsertTable,EditTable,InsertTableRowBefore,InsertTableRowAfter,DeleteTableRow,InsertTableColumnBefore,InsertTableColumnAfter,DeleteTableColumn|\""); controls.Append("\n\t\t\t\t\t\tSupportFolder=\"/phyEditorImages/FreeTextBox/\" ButtonSet=\"NotSet\" Width=\"450px\" ButtonWidth=\"21\"></FTB:FREETEXTBOX>"); // //----------- controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); // IshasFreeTextBoxControl = true; } else if (datatype != "byte[]" && datatype != "Object" && datatype != "Guid") { TableConstraint cnstr = SqlProvider.obj.GetParentColumn(column.Name); controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"Title\">" + column.Name + "</td>"); controls.Append("\n\t\t\t\t\t<td class=\"Control\">"); if (cnstr == null) { controls.Append("\n\t\t\t\t\t\t<asp:TextBox id=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" CssClass=\"Control\" MaxLength=\"" + Globals.GetTextBoxMaxLength(column) + "\" ValidationGroup=\"" + ClassName + "\" ></asp:TextBox>"); if (!column.AllowNulls) { controls.Append("\n\t\t\t\t\t\t<asp:RequiredFieldValidator id=\"rfv" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" ValidationGroup=\"" + ClassName + "\">ÃÏÎá åÐÇ ÇáÈíÇä</asp:RequiredFieldValidator>"); } } else { controls.Append("\n\t\t\t\t\t\t<asp:DropDownList id=\"ddl" + Globals.GetProgramatlyName(cnstr.ParentTable) + "\" runat=\"server\" CssClass=\"Control\" ValidationGroup=\"" + ClassName + "\" ></asp:DropDownList>"); } controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); } } } controls.Append("\n\t\t\t\t<tr>"); controls.Append("\n\t\t\t\t\t<td class=\"Result\" align=\"center\" colspan=\"2\">"); controls.Append("\n\t\t\t\t\t\t<asp:Button id=\"btnCreate\" runat=\"server\" Width=\"100px\" Text=\"ÅÖÇÝÉ\" CssClass=\"Submit\" OnClick=\"btnCreate_Click\" ValidationGroup=\"" + ClassName + "\"></asp:Button>"); controls.Append("\n\t\t\t\t\t</td>"); controls.Append("\n\t\t\t\t</tr>"); return(controls.ToString()); }