Ejemplo n.º 1
0
 //-------------------------------------
 #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("");
     }
 }
Ejemplo n.º 2
0
        //
        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());
            //
        }
Ejemplo n.º 3
0
        //----------------------------------------------------------
        #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("");
            }
        }
Ejemplo n.º 4
0
 //-------------------------------------
 #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 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("");
     }
 }
Ejemplo n.º 6
0
        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("");
            }
        }
Ejemplo n.º 7
0
        //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("");
            }
        }
Ejemplo n.º 8
0
        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());
        }
Ejemplo n.º 9
0
        //-------------------------------------
        #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("");
            }
        }
Ejemplo n.º 10
0
        //-------------------------------------
        public string CreateGetAllMethod(SQLDMO.Column conditionalColumn, bool isAvailableMethod)
        {
            try
            {
                string MethodName = StoredProcedureTypes.GetAll.ToString();
                string sqlDataProviderMethodName2  = "GetAll";
                string sqlDataProviderMethodCaller = global.SqlDataProviderClass + ".Instance." + sqlDataProviderMethodName2;
                string methodParameters            = "";
                string sqlMethodParameters         = "";
                string additionalPreviousBodyLines = "";
                //------------------------------
                bool hasPreviousMethodParameter    = false;
                bool hasPreviousSqlMethodParameter = false;
                //------------------------------
                bool isMaultiLanguages = (ProjectBuilder.HasMultiLanguages && SqlProvider.CheckISATableIsMultiLanguage(SqlProvider.obj.TableName));
                if (isMaultiLanguages)
                {
                    if (!isAvailableMethod)
                    {
                        methodParameters          += "Languages langID";
                        hasPreviousMethodParameter = true;
                    }
                    sqlMethodParameters          += "langID";
                    hasPreviousSqlMethodParameter = true;
                }
                //------------------------------
                if (conditionalColumn != null)
                {
                    //Check Previous Parameters
                    if (hasPreviousMethodParameter)
                    {
                        methodParameters += ", ";
                    }
                    if (hasPreviousSqlMethodParameter)
                    {
                        sqlMethodParameters += ", ";
                    }
                    //-----------------------
                    MethodName += "By" + Globals.GetProgramatlyName(conditionalColumn.Name);
                    sqlDataProviderMethodCaller += "By" + Globals.GetProgramatlyName(conditionalColumn.Name);
                    methodParameters            += Globals.GetAliasDataType(conditionalColumn.Datatype) + " " + Globals.ConvetStringToCamelCase(Globals.GetProgramatlyName(conditionalColumn.Name));
                    sqlMethodParameters         += Globals.ConvetStringToCamelCase(Globals.GetProgramatlyName(conditionalColumn.Name));
                    //-----------------------
                    hasPreviousMethodParameter    = true;
                    hasPreviousSqlMethodParameter = true;
                }
                //------------------------------
                bool hasIsAvailable = SqlProvider.CheckIsATableHasIsAvailableColumnName(SqlProvider.obj.TableName);
                if (hasIsAvailable)
                {
                    if (!isAvailableMethod)
                    {
                        //Check Previous Parameters
                        if (hasPreviousMethodParameter)
                        {
                            methodParameters += ", ";
                        }
                        if (hasPreviousSqlMethodParameter)
                        {
                            sqlMethodParameters += ", ";
                        }
                        //-------------------------
                        methodParameters    += "bool " + Globals.ConvetStringToCamelCase(ProjectBuilder.IsAvailableConditionParam);
                        sqlMethodParameters += Globals.ConvetStringToCamelCase(ProjectBuilder.IsAvailableConditionParam);
                        //-----------------------
                        hasPreviousMethodParameter    = true;
                        hasPreviousSqlMethodParameter = true;
                    }
                    else
                    {
                        //Check Previous Parameter
                        if (hasPreviousSqlMethodParameter)
                        {
                            sqlMethodParameters += ", ";
                        }
                        sqlDataProviderMethodCaller = MethodName;
                        //if (userType == UserType.Admin)
                        //{
                        //    MethodName += "ForAdmin";
                        //    sqlMethodParameters += "false";
                        //    additionalPreviousBodyLines = "Languages langID = (Languages) ResourceManager.GetCurrentLanguage();";
                        //}
                        //else
                        //{
                        //    MethodName += "ForUser";
                        //    sqlMethodParameters += "true";
                        //    additionalPreviousBodyLines = "Languages langID = (Languages) ResourceManager.GetCurrentLanguage();";
                        //}
                        ////-----------------------
                        hasPreviousSqlMethodParameter = true;
                    }
                }
                //------------------------------
                //Check Previous Parameters
                if (hasPreviousMethodParameter)
                {
                    methodParameters += ", ";
                }
                if (hasPreviousSqlMethodParameter)
                {
                    sqlMethodParameters += ", ";
                }
                //-------------------------
                methodParameters    += "int pageIndex, int pageSize, out int totalRecords";
                sqlMethodParameters += "pageIndex, pageSize, out totalRecords";
                //XXXXXXXXXXXXXXX
                //XXXXXXXXXXXXXXX
                string MethodReturn = "List<" + global.TableEntityClass + ">";
                //XML Documentaion
                string xmlDocumentation = "\n\t/// <summary>\n";
                xmlDocumentation += "\t/// Gets All " + SqlProvider.obj.TableName + ".\n";
                xmlDocumentation += "\t/// <example>[Example]" + MethodReturn + " " + global.EntityClassList + "=" + ClassName + "." + MethodName + "(" + sqlMethodParameters + ");.</example>\n";

                xmlDocumentation += "\t/// </summary>\n";
                xmlDocumentation += "\t/// <returns>All " + SqlProvider.obj.TableName + ".</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 + "(" + methodParameters + ")");
                methodBody.Append("\n\t{");
                methodBody.Append("\n\t\t" + additionalPreviousBodyLines);
                methodBody.Append("\n\t\treturn " + sqlDataProviderMethodCaller + "(" + sqlMethodParameters + ");");
                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("");
            }
        }
        private string CreateLoadData()
        {
            StringBuilder loadData = new StringBuilder();
            string        id       = Globals.GetProgramatlyName(ID.Name);

            id = Globals.ConvetStringToCamelCase(id);
            loadData.Append("\n\tprivate void LoadData()");
            loadData.Append("\n\t{try{");
            loadData.Append("\n\t\tif(Request.QueryString[\"" + id + "\"]!=null)");
            loadData.Append("\n\t\t{");
            loadData.Append("\n\t\t\t" + Globals.GetAliasDataType(ID.Datatype) + " " + id + " = Convert.To" + Globals.GetDataType(ID.Datatype) + "(Request.QueryString[\"" + id + "\"]);");

            loadData.Append("\n\t\t\t" + global.TableEntityClass + " " + global.EntityClassObject + " =" + global.TableFactoryClass + ".Get" + global.TableProgramatlyName + "Object(" + id + ");");
            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))
                {
                    TableConstraint cnstr = SqlProvider.obj.GetParentColumn(column.Name);
                    datatype = Globals.GetAliasDataType(column.Datatype);
                    string ddl = "";
                    if (datatype == "string")
                    {
                        if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.NText)
                        {
                            loadData.Append("\n\t\t\tfck" + Globals.GetProgramatlyName(column.Name) + ".Value = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ";");
                        }
                        else
                        {
                            if (cnstr == null)
                            {
                                loadData.Append("\n\t\t\ttxt" + Globals.GetProgramatlyName(column.Name) + ".Text = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ";");
                            }
                            else
                            {
                                ddl = "ddl" + Globals.GetProgramatlyName(cnstr.ParentTable);

                                loadData.Append("\n\t\t\tMyDropDownList.LoadDataAndSetSelectedValue(" + ddl + "," + Globals.GetProgramatlyName(cnstr.ParentTable) + "Factory.GetAll(),\"" +
                                                SqlProvider.obj.GetExpectedNameForParent(cnstr.ParentTable) + "\",\"" + Globals.GetProgramatlyName(cnstr.ParentColID) + "\"," + global.EntityClassObject + "." +
                                                Globals.GetProgramatlyName(column.Name) + ".ToString());");
                            }
                        }
                    }
                    //DateTime
                    else if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.DateTime)
                    {
                        loadData.Append("\n\t\t\ttxt" + Globals.GetProgramatlyName(column.Name) + ".Value = Convert.ToString(" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ");");
                    }
                    //DateTime
                    else if (datatype == "bool")
                    {
                        loadData.Append("\n\t\t\tcb" + Globals.GetProgramatlyName(column.Name) + ".Checked = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ";");
                    }
                    else if (datatype != "byte[]" && datatype != "Object" && datatype != "Guid")
                    {
                        if (cnstr == null)
                        {
                            loadData.Append("\n\t\t\ttxt" + Globals.GetProgramatlyName(column.Name) + ".Text = " + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + ".ToString();");
                        }
                        else
                        {
                            ddl = "ddl" + Globals.GetProgramatlyName(cnstr.ParentTable);

                            loadData.Append("\n\t\t\tMyDropDownList.LoadDataAndSetSelectedValue(" + ddl + "," + Globals.GetProgramatlyName(cnstr.ParentTable) + "Factory.GetAll(),\"" +
                                            SqlProvider.obj.GetExpectedNameForParent(cnstr.ParentTable) + "\",\"" + Globals.GetProgramatlyName(cnstr.ParentColID) + "\"," + global.EntityClassObject + "." +
                                            Globals.GetProgramatlyName(column.Name) + ".ToString());");
                        }
                    }
                }
            }

            loadData.Append("\n\t\t}");
            loadData.Append("\n\t\telse");
            loadData.Append("\n\t\tthis.Visible=false;");
            loadData.Append("\n\t}catch{Response.Redirect(\"default.aspx\");}}");
            return(loadData.ToString());
        }
Ejemplo n.º 12
0
        //
        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\t#region --------------" + dataGridID + "_DeleteCommand--------------");
            pageIndexHandler.Append("\n\t//---------------------------------------------------------");
            pageIndexHandler.Append("\n\t//" + dataGridID + "_DeleteCommand");
            pageIndexHandler.Append("\n\t//---------------------------------------------------------");


            pageIndexHandler.Append("\n\tprotected void " + dataGridID + "_DeleteCommand(object source, DataGridCommandEventArgs e)");
            pageIndexHandler.Append("\n\t{");
            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\t" + global.TableEntityClass + " " + global.EntityClassObject + " =" + global.TableFactoryClass + ".Get" + global.TableProgramatlyName + "Object(" + id + ");");
            pageIndexHandler.Append("\n\t\tif(" + global.TableFactoryClass + "." + MethodType.Delete.ToString() + "(" + id + "))");
            pageIndexHandler.Append("\n\t\t{");
            //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX//
            #region XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
            string datatype;
            bool   siteurlObject = false;
            foreach (SQLDMO.Column column in Fields)
            {
                //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() != ProjectBuilder.LangID)
                {
                    TableConstraint cnstr = SqlProvider.obj.GetParentColumn(column.Name);
                    datatype = Globals.GetAliasDataType(column.Datatype);
                    if (datatype == "string")
                    {
                        if (cnstr == null)
                        {
                            if (column.Name.IndexOf("Extension") > 0 && !siteurlObject)
                            {
                                pageIndexHandler.Append("\n\t\t\t" + SiteUrlsBuilder.GetFullDeclaration());
                                siteurlObject = true;
                            }
                            //--------------------------------------------
                            if (column.Name == ProjectBuilder.PhotoExtensionColumnName)
                            {
                                pageIndexHandler.Append("\n\t\t\t//Photo-----------------------------");
                                pageIndexHandler.Append("\n\t\t\t//Delete old original photo");
                                //Add Urls Property
                                SiteUrlsBuilder.AddDirectoryUrl("OriginalPhotos", SiteUrlsBuilder.photoOriginalUrl, Globals.GetProgramatlyName(Table), "");
                                SiteUrlsBuilder.AddDirectoryUrl("MicroPhotoThumbs", SiteUrlsBuilder.photoMicroUrl, Globals.GetProgramatlyName(Table), "");
                                SiteUrlsBuilder.AddDirectoryUrl("MiniPhotoThumbs", SiteUrlsBuilder.photoMiniUrl, Globals.GetProgramatlyName(Table), "");
                                SiteUrlsBuilder.AddDirectoryUrl("NormalPhotoThumbs", SiteUrlsBuilder.photoNormalUrl, Globals.GetProgramatlyName(Table), "");
                                SiteUrlsBuilder.AddDirectoryUrl("BigPhotoThumbs", SiteUrlsBuilder.photoBigUrl, Globals.GetProgramatlyName(Table), "");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls.OriginalPhotos) + " + global.EntityClassObject + ".Photo" + ");");
                                pageIndexHandler.Append("\n\t\t\t//Delete old Thumbnails");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls." + "MicroPhotoThumbs) + " + global.TableFactoryClass + ".Create" + Table + "PhotoName(" + id + " ) + MoversFW.Thumbs.thumbnailExetnsion);");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls." + "MiniPhotoThumbs) + " + global.TableFactoryClass + ".Create" + Table + "PhotoName(" + id + " ) + MoversFW.Thumbs.thumbnailExetnsion);");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls." + "NormalPhotoThumbs) + " + global.TableFactoryClass + ".Create" + Table + "PhotoName(" + id + " ) + MoversFW.Thumbs.thumbnailExetnsion);");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls." + "BigPhotoThumbs) + " + global.TableFactoryClass + ".Create" + Table + "PhotoName(" + id + " ) + MoversFW.Thumbs.thumbnailExetnsion);");
                                pageIndexHandler.Append("\n\t\t\t//------------------------------------------------");
                            }
                            else if (column.Name == "LogoExtension")
                            {
                                pageIndexHandler.Append("\n\t\t\t//Logo-----------------------------");
                                pageIndexHandler.Append("\n\t\t\t//Delete old original Logo");
                                //Add Urls Property
                                SiteUrlsBuilder.AddDirectoryUrl("OriginalLogos", SiteUrlsBuilder.logoOriginalUrl, Globals.GetProgramatlyName(Table), "");
                                SiteUrlsBuilder.AddDirectoryUrl("MicroLogoThumbs", SiteUrlsBuilder.logoMicroUrl, Globals.GetProgramatlyName(Table), "");
                                SiteUrlsBuilder.AddDirectoryUrl("MiniLogoThumbs", SiteUrlsBuilder.logoMiniUrl, Globals.GetProgramatlyName(Table), "");
                                SiteUrlsBuilder.AddDirectoryUrl("NormalLogoThumbs", SiteUrlsBuilder.logoNormalUrl, Globals.GetProgramatlyName(Table), "");
                                SiteUrlsBuilder.AddDirectoryUrl("BigLogoThumbs", SiteUrlsBuilder.logoBigUrl, Globals.GetProgramatlyName(Table), "");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls.OriginalLogos)  + " + global.EntityClassObject + ".Logo" + ");");
                                pageIndexHandler.Append("\n\t\t\t//Delete old Thumbnails");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls.MicroLogoThumbs) + " + global.TableFactoryClass + ".Create" + Table + "LogoName(" + id + " ) + MoversFW.Thumbs.thumbnailExetnsion);");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls.MiniLogoThumbs) + " + global.TableFactoryClass + ".Create" + Table + "LogoName(" + id + " ) + MoversFW.Thumbs.thumbnailExetnsion);");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls.NormalLogoThumbs) + " + global.TableFactoryClass + ".Create" + Table + "LogoName(" + id + " ) + MoversFW.Thumbs.thumbnailExetnsion);");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls.BigLogoThumbs) + " + global.TableFactoryClass + ".Create" + Table + "LogoName(" + id + " ) + MoversFW.Thumbs.thumbnailExetnsion);");
                            }
                            else if (column.Name == "FileExtension")
                            {
                                pageIndexHandler.Append("\n\t\t\t//File-----------------------------");
                                pageIndexHandler.Append("\n\t\t\t//Delete old original file");
                                //Add Urls Property
                                SiteUrlsBuilder.AddDirectoryUrl("OriginalFiles", SiteUrlsBuilder.filesUrl, Globals.GetProgramatlyName(Table), "");
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls.OriginalFiles) + " + global.EntityClassObject + ".File" + ");");
                                pageIndexHandler.Append("\n\t\t\t\t//------------------------------------------------");
                            }
                            else if (column.Name.IndexOf("Extension") > 0)
                            {
                                string[] stringSeparators = new string[] { "Extension" };
                                string[] separatingResult = column.Name.Split(stringSeparators, StringSplitOptions.None);
                                string   propertyName     = separatingResult[0];
                                string   uploaderID       = "fu" + propertyName;
                                pageIndexHandler.Append("\n\t\t\t//File-----------------------------");
                                //Add Urls Property
                                SiteUrlsBuilder.AddDirectoryUrl("Original" + propertyName, SiteUrlsBuilder.otherFilesUrl, Globals.GetProgramatlyName(Table), propertyName + "s");
                                pageIndexHandler.Append("\n\t\t\t//Delete old original " + propertyName);
                                pageIndexHandler.Append("\n\t\t\tFile.Delete(Server.MapPath(urls.Original" + propertyName + ") + " + global.EntityClassObject + "." + propertyName + ");");
                            }
                        }
                    }
                }
            }
            #endregion
            //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX//
            pageIndexHandler.Append("\n\t\t\tlblResult.ForeColor = Color.Blue;");
            pageIndexHandler.Append("\n\t\t\tlblResult.Text = " + ResourcesTesxtsBuilder.AddAdminGlobalText("DeletingOprationDone", TextType.Text) + ";");
            pageIndexHandler.Append("\n\t\t\t//if one item in datagrid");
            pageIndexHandler.Append("\n\t\t\tif (" + dataGridID + ".Items.Count == 1)");
            pageIndexHandler.Append("\n\t\t\t{");
            pageIndexHandler.Append("\n\t\t\t\t--pager.CurrentPage;");
            pageIndexHandler.Append("\n\t\t\t}");
            pageIndexHandler.Append("\n\t\t\tLoadData();");
            pageIndexHandler.Append("\n\t\t}");
            pageIndexHandler.Append("\n\t\telse");
            pageIndexHandler.Append("\n\t\t{");
            pageIndexHandler.Append("\n\t\t\tlblResult.ForeColor = Color.Red;");
            pageIndexHandler.Append("\n\t\t\tlblResult.Text =" + ResourcesTesxtsBuilder.AddAdminGlobalText("DeletingOprationFaild", TextType.Text) + ";");

            pageIndexHandler.Append("\n\t\t}");
            pageIndexHandler.Append("\n\t}");
            pageIndexHandler.Append("\n\t//--------------------------------------------------------");
            pageIndexHandler.Append("\n\t#endregion");
            return(pageIndexHandler.ToString());
            //
        }
        //
        #region ClassMember
        public string CreateInsertUpdateDeleteMethod(StoredProcedureTypes type)
        {
            try
            {
                string id = Globals.GetProgramatlyName(ID.Name);
                id = Globals.ConvetStringToCamelCase(id);
                string MethodName = type.ToString();
                string sqlDataProviderMethodName = type.ToString();
                string MethodReturn     = "bool";
                string MethodParameters = "(" + global.TableEntityClass + " " + global.EntityClassObject + ")";
                //
                if (type == StoredProcedureTypes.Delete)
                {
                    MethodParameters = "(" + Globals.GetAliasDataType(ID.Datatype) + " " + id + ")";
                }
                else
                {
                    MethodParameters = "(" + global.TableEntityClass + " " + global.EntityClassObject + ")";
                }
                //XML Documentaion
                string xmlInsertDocumentation = "\t/// <summary>\n";
                xmlInsertDocumentation += "\t/// Creates " + SqlProvider.obj.TableName + " object by calling " + SqlProvider.obj.TableName + " data provider create method.\n";
                xmlInsertDocumentation += "\t/// <example>[Example]bool result=" + ClassName + "." + 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 operation.</returns>";
                //
                string xmlUpdateDocumentation = "\t/// <summary>\n";
                xmlUpdateDocumentation += "\t/// Updates " + SqlProvider.obj.TableName + " object by calling " + SqlProvider.obj.TableName + " data provider update method.\n";
                xmlUpdateDocumentation += "\t/// <example>[Example]bool result=" + 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>The result of update operation.</returns>";
                //
                string xmlDeleteDocumentation = "\t/// <summary>\n";
                xmlDeleteDocumentation += "\t/// Deletes single " + SqlProvider.obj.TableName + " object .\n";
                xmlDeleteDocumentation += "\t/// <example>[Example]bool result=" + ClassName + "." + 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 operation.</returns>";
                //method body
                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);
                }
                methodBody.Append("\n\tpublic static " + MethodReturn + " " + MethodName + MethodParameters);
                methodBody.Append("\n\t{");
                //
                if (type == StoredProcedureTypes.Delete)
                {
                    methodBody.Append("\n\t\treturn " + global.SqlDataProviderClass + ".Instance." + sqlDataProviderMethodName + "(" + id + ");");
                }
                else
                {
                    methodBody.Append("\n\t\treturn " + global.SqlDataProviderClass + ".Instance." + sqlDataProviderMethodName + "(" + 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("");
            }
        }
        //--------------------------------------
        //
        protected string GenerateClass()
        {
            string id = Globals.GetProgramatlyName(ID.Name);

            id = Globals.ConvetStringToCamelCase(id);
            string headerProperity = "";
            string boxHeader       = "";

            if (Fields.Count >= 2)
            {
                SQLDMO.Column headerColumn = (SQLDMO.Column)Fields.Item(1);

                headerProperity = Globals.GetProgramatlyName(headerColumn.Name);
                boxHeader       = global.EntityClassObject + "." + headerProperity;
            }
            else
            {
                boxHeader = "\"\"";
            }
            StringBuilder pageCode = new StringBuilder();

            pageCode.Append("using System;\n");
            pageCode.Append("using System.Data;\n");
            pageCode.Append("using System.Configuration;\n");
            pageCode.Append("using System.Collections;\n");
            pageCode.Append("using System.Web;\n");
            pageCode.Append("using System.Web.Security;\n");
            pageCode.Append("using System.Web.UI;\n");
            pageCode.Append("using System.Web.UI.WebControls;\n");
            pageCode.Append("using System.Web.UI.WebControls.WebParts;\n");
            pageCode.Append("using System.Web.UI.HtmlControls;\n");
            pageCode.Append("using System.Drawing;\n");
            pageCode.Append("\npublic partial class Details : System.Web.UI.Page");
            pageCode.Append("\n{");
            pageCode.Append("\n\t#region --------------LoadData--------------");
            pageCode.Append("\n\t//---------------------------------------------------------");
            pageCode.Append("\n\t//Page_Load");
            pageCode.Append("\n\t//---------------------------------------------------------");
            pageCode.Append("\n\tprotected void Page_Load(object sender, EventArgs e)");
            pageCode.Append("\n\t{");
            pageCode.Append("\n\t\tif (!IsPostBack)");
            pageCode.Append("\n\t\t{");
            if (ProjectBuilder.HasConfiguration)
            {
                pageCode.Append("\n\t\t\tSiteOptions.CheckModuleWithHandling(Resources.SiteOptions." + SiteOptionsBuilder.GetHasPropertyString(Table) + ", ViewerType.User);");
            }
            pageCode.Append("\n\t\t\t//Set Boxes Headers");
            pageCode.Append("\n\t\t\tSetBoxesHeaders();");
            pageCode.Append("\n\t\t}");
            pageCode.Append("\n\t}");
            pageCode.Append("\n\t//--------------------------------------------------------");
            pageCode.Append("\n\t#endregion");
            pageCode.Append("\n\t");
            pageCode.Append("\n\t#region Set Boxes Headers");
            pageCode.Append("\n\t//--------------------------------------------------------");
            pageCode.Append("\n\t//Set Boxes Headers");
            pageCode.Append("\n\t//--------------------------------------------------------");
            pageCode.Append("\n\tprotected void SetBoxesHeaders()");
            pageCode.Append("\n\t{");
            SiteUrlsBuilder.AddParameter(Globals.GetProgramatlyName(ID.Name));
            pageCode.Append("\n\t\tif(MoversFW.Components.UrlManager.ChechIsValidIntegerParameter(" + SiteUrlsBuilder.GetIdentifire() + Globals.GetProgramatlyName(ID.Name) + "))");
            pageCode.Append("\n\t\t{");
            pageCode.Append("\n\t\t\t" + Globals.GetAliasDataType(ID.Datatype) + " " + id + " = Convert.To" + Globals.GetDataType(ID.Datatype) + "(Request.QueryString[" + SiteUrlsBuilder.GetIdentifire() + Globals.GetProgramatlyName(ID.Name) + "]);");

            pageCode.Append("\n\t\t\t" + global.TableEntityClass + " " + global.EntityClassObject + " =" + global.TableFactoryClass + ".Get" + global.TableProgramatlyName + "Object(" + id + ");");
            pageCode.Append("\n\t\t\tif (" + global.EntityClassObject + " != null)");
            pageCode.Append("\n\t\t\t{");
            pageCode.Append("\n\t\t\t\t" + masterBoxID + ".Header = " + boxHeader + ";");
            pageCode.Append("\n\t\t\t}");

            pageCode.Append("\n\t\t\telse");
            pageCode.Append("\n\t\t\t{");
            pageCode.Append("\n\t\t\t\tResponse.Redirect(\"/default.aspx\");");
            pageCode.Append("\n\t\t\t}");
            pageCode.Append("\n\t\t}");
            pageCode.Append("\n\t\telse");
            pageCode.Append("\n\t\t{");
            pageCode.Append("\n\t\t\tResponse.Redirect(\"/default.aspx\");");
            pageCode.Append("\n\t\t}");

            pageCode.Append("\n\t}");
            pageCode.Append("\n\t//--------------------------------------------------------");
            pageCode.Append("\n\t#endregion");
            pageCode.Append("\n}");
            return(pageCode.ToString());
        }