Beispiel #1
0
        //
        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());
        }
Beispiel #2
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("");
            }
        }
Beispiel #3
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("");
            }
        }
Beispiel #4
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());
        }
        //
        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());
        }
Beispiel #6
0
        //
        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());
        }
        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());
        }
Beispiel #8
0
        //

        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());
        }
        //
        private string Create_CreateButtonHandler()
        {
            StringBuilder _UpdateButtonHandler = new StringBuilder();
            string        id = Globals.GetProgramatlyName(ID.Name);

            _UpdateButtonHandler.Append("\n\tprotected void btnUpdate_Click(object sender, System.EventArgs e)");
            _UpdateButtonHandler.Append("\n\t{");
            _UpdateButtonHandler.Append("\n\t\tif (!Page.IsValid)");
            _UpdateButtonHandler.Append("\n\t\t{");
            _UpdateButtonHandler.Append("\n\t\t\treturn;");
            _UpdateButtonHandler.Append("\n\t\t}");
            //_UpdateButtonHandler.Append("\n\t\t"+global.TableEntityClass+" "+global.EntityClassObject+" = new "+global.TableEntityClass+"();");
            //_UpdateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(ID.Name) + " = Convert.To" + Globals.GetDataType(ID.Datatype) + "(Request.QueryString[\"" + Globals.GetProgramatlyName(ID.Name) + "\"]);");
            //Diver
            _UpdateButtonHandler.Append("\n\t\t\t" + Globals.GetAliasDataType(ID.Datatype) + " " + id + " = Convert.To" + Globals.GetDataType(ID.Datatype) + "(Request.QueryString[\"" + id + "\"]);");
            _UpdateButtonHandler.Append("\n\t\t\t" + global.TableEntityClass + " " + global.EntityClassObject + " =" + global.TableFactoryClass + ".Get" + global.TableProgramatlyName + "Object(" + id + ");");
            //Diver

            string datatype;

            foreach (SQLDMO.Column column in Fields)
            {
                if (ID == null || column.Name != ID.Name)          //||!Globals.CheckIsAddedBySql(ID))
                {
                    TableConstraint cnstr = SqlProvider.obj.GetParentColumn(column.Name);
                    datatype = Globals.GetAliasDataType(column.Datatype);

                    if (datatype == "string")
                    {
                        if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.NText)
                        {
                            _UpdateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = fck" + Globals.GetProgramatlyName(column.Name) + ".Value;");
                        }
                        else
                        {
                            if (cnstr == null)
                            {
                                _UpdateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = txt" + Globals.GetProgramatlyName(column.Name) + ".Text;");
                            }
                            else
                            {
                                _UpdateButtonHandler.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)
                    {
                        _UpdateButtonHandler.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")
                    {
                        _UpdateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = cb" + Globals.GetProgramatlyName(column.Name) + ".Checked;");
                    }
                    else if (datatype == "Guid")
                    {
                        _UpdateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = Guid.NewGuid();");
                    }
                    else if (datatype != "byte[]" && datatype != "Object")
                    {
                        if (cnstr == null)
                        {
                            _UpdateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = Convert.To" + Globals.GetDataType(column.Datatype) + "(txt" + Globals.GetProgramatlyName(column.Name) + ".Text);");
                        }
                        else
                        {
                            _UpdateButtonHandler.Append("\n\t\t" + global.EntityClassObject + "." + Globals.GetProgramatlyName(column.Name) + " = Convert.To" + Globals.GetDataType(column.Datatype) + "(ddl" + Globals.GetProgramatlyName(cnstr.ParentTable) + ".SelectedValue);");
                        }
                    }
                }
            }
            _UpdateButtonHandler.Append("\n\t\tbool result = " + global.TableFactoryClass + "." + MethodType.Update.ToString() + "(" + global.EntityClassObject + ");");
            _UpdateButtonHandler.Append("\n\t\tif(result)");
            _UpdateButtonHandler.Append("\n\t\t{");
            //_UpdateButtonHandler.Append("\n\t\t\tlblResult.ForeColor=Color.Blue ;");
            //_UpdateButtonHandler.Append("\n\t\t\tlblResult.Text=\"Êã ÇáÊÚÏíá ÈäÌÇÍ\";");
            _UpdateButtonHandler.Append("\n\t\t\tResponse.Redirect(\"default.aspx\");");

            _UpdateButtonHandler.Append("\n\t\t}");
            _UpdateButtonHandler.Append("\n\t\telse");
            _UpdateButtonHandler.Append("\n\t\t{");
            _UpdateButtonHandler.Append("\n\t\t\tlblResult.ForeColor=Color.Red ;");
            _UpdateButtonHandler.Append("\n\t\t\tlblResult.Text=\"ÝÔáÊ ÚãáíÉ ÇáÊÚÏíá\";");
            _UpdateButtonHandler.Append("\n\t\t}");
            _UpdateButtonHandler.Append("\n\t}");
            return(_UpdateButtonHandler.ToString());
        }
        //
        protected 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 (SQLDMO.Column column in Fields)
            {
                if (allParameters != null && !allParameters.Contains(column.Name))
                {
                    continue;
                }
                //if (ID == null || column.Name != ID.Name)//||!Globals.CheckIsAddedBySql(ID))
                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 == "bool")
                    {
                        controls.Append("\n\t\t\t\t<tr>");
                        controls.Append("\n\t\t\t\t\t<td class=\"Text\"><%=LanguageAdminResource.GetString(\"" + Globals.GetProgramatlyName(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=\"Text\"><%=LanguageAdminResource.GetString(\"" + Globals.GetProgramatlyName(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")
                    {
                        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                        if (cnstr == null)
                        {
                            if (column.Name.IndexOf(ProjectBuilder.ExtensionInColumnName) > -1)
                            {
                                if (column.Name == ProjectBuilder.PhotoExtensionColumnName)
                                {
                                    controls.Append("\n\t\t\t\t<tr>");
                                    controls.Append("\n\t\t\t\t\t<td class=\"Text\"><%=LanguageAdminResource.GetString(\"" + Globals.GetProgramatlyName(column.Name) + "\")%></td>");
                                    controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                                    controls.Append("\n\t\t\t\t\t\t<asp:FileUpload ID=\"" + photoUploadreID + "\" runat=\"server\" CssClass=\"Controls\"  />");
                                }
                                else if (column.Name == "LogoExtension")
                                {
                                    controls.Append("\n\t\t\t\t<tr>");
                                    controls.Append("\n\t\t\t\t\t<td class=\"Text\"><%=LanguageAdminResource.GetString(\"" + Globals.GetProgramatlyName(column.Name) + "\")%></td>");
                                    controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                                    controls.Append("\n\t\t\t\t\t\t<asp:FileUpload ID=\"" + logoUploadreID + "\" runat=\"server\" CssClass=\"Controls\"  />");
                                }
                                else if (column.Name == "FileExtension")
                                {
                                    controls.Append("\n\t\t\t\t<tr runat=\"server\" id=\"trFile\">");
                                    controls.Append("\n\t\t\t\t\t<td class=\"Text\"><%=LanguageAdminResource.GetString(\"" + Globals.GetProgramatlyName(column.Name) + "\")%></td>");
                                    controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                                    controls.Append("\n\t\t\t\t\t\t<asp:FileUpload ID=\"" + fileUploadreID + "\" runat=\"server\" CssClass=\"Controls\"  />");
                                }
                                else if (column.Name.IndexOf("Extension") > -1)
                                {
                                    string[] stringSeparators = new string[] { "Extension" };
                                    string[] separatingResult = column.Name.Split(stringSeparators, StringSplitOptions.None);
                                    string   propretyName     = separatingResult[0];
                                    string   uploaderID       = "fu" + propretyName;
                                    controls.Append("\n\t\t\t\t<tr runat=\"server\" id=\"tr" + propretyName + ">");
                                    controls.Append("\n\t\t\t\t\t<td class=\"Text\"><%=LanguageAdminResource.GetString(\"" + Globals.GetProgramatlyName(column.Name) + "\")%></td>");
                                    controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                                    controls.Append("\n\t\t\t\t\t\t<asp:FileUpload ID=\"" + uploaderID + "\" runat=\"server\" CssClass=\"Controls\"  />");
                                }

                                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<tr>");
                                controls.Append("\n\t\t\t\t\t<td class=\"Text\"><%=LanguageAdminResource.GetString(\"" + Globals.GetProgramatlyName(column.Name) + "\")%></td>");
                                controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                                if (column.Name.ToLower().IndexOf("password") > -1)
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:TextBox id=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" TextMode=\"Password\" CssClass=\"Control\" ValidationGroup=\"" + ClassName + "\"></asp:TextBox>");
                                }
                                else if (column.Length > 128)
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:TextBox id=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" TextMode=\"MultiLine\" CssClass=\"Control\" ValidationGroup=\"" + ClassName + "\"></asp:TextBox>");
                                }
                                else
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:TextBox id=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" CssClass=\"Control\" 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<tr>");
                            controls.Append("\n\t\t\t\t\t<td class=\"Text\"><%=LanguageAdminResource.GetString(\"" + Globals.GetProgramatlyName(column.Name) + "\")%></td>");
                            controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                            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=\"btnUpdate\" runat=\"server\" Width=\"100px\" Text=\"\" CssClass=\"Button\" OnClick=\"btnUpdate_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());
        }
        protected string GenerateControls()
        {
            string        propertyName;
            string        trPropertyName;
            string        datatype;
            StringBuilder controls         = new StringBuilder();
            bool          hasPasswordField = false;

            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>");
            foreach (SQLDMO.Column column in Fields)
            {
                propertyName   = Globals.GetProgramatlyName(column.Name);
                trPropertyName = "tr" + propertyName;
                //if (ID == null || column.Name != ID.Name)//||!Globals.CheckIsAddedBySql(ID))
                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 == "bool")
                    {
                        if (ProjectBuilder.HasConfiguration)
                        {
                            controls.Append("\n\t\t\t\t<tr id=\"" + trPropertyName + "\" runat=\"server\" >");
                        }
                        else
                        {
                            controls.Append("\n\t\t\t\t<tr>");
                        }
                        controls.Append("\n\t\t\t\t\t<td class=\"Text\">" + ResourcesTesxtsBuilder.AddUserText(propertyName, TextType.HtmlClassic));
                        if (!column.AllowNulls)
                        {
                            controls.Append("<span class=\"RequiredField\"><asp:Label runat=\"server\" Text=\"*\" /></span>");
                        }
                        controls.Append("</td>");
                        controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                        if (propertyName.ToLower().IndexOf("isavailable") > -1)
                        {
                            controls.Append("\n\t\t\t\t\t\t<asp:CheckBox id=\"cb" + propertyName + "\" Checked=\"true\" CssClass=\"Controls\" runat=\"server\" ValidationGroup=\"" + Table + "\"></asp:CheckBox>");
                        }
                        else
                        {
                            controls.Append("\n\t\t\t\t\t\t<asp:CheckBox id=\"cb" + propertyName + "\" CssClass=\"Controls\" runat=\"server\" ValidationGroup=\"" + Table + "\"></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)
                    {
                        if (column.Name.ToLower().IndexOf("details") > -1)
                        {
                            if (ProjectBuilder.HasConfiguration)
                            {
                                controls.Append("\n\t\t\t\t<tr id=\"" + trPropertyName + "\" runat=\"server\" >");
                            }
                            else
                            {
                                controls.Append("\n\t\t\t\t<tr>");
                            }
                            controls.Append("\n\t\t\t\t\t<td class=\"Text\">" + ResourcesTesxtsBuilder.AddUserText(propertyName, TextType.HtmlClassic));
                            if (!column.AllowNulls)
                            {
                                controls.Append("<span class=\"RequiredField\"><asp:Label runat=\"server\" Text=\"*\" /></span>");
                            }
                            controls.Append("</td>");
                            controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                            //FREETEXTBOX
                            if (ProjectBuilder.IsFreeTextBoxEditor)
                            {
                                controls.Append("\n\t\t\t\t\t\t<FTB:FREETEXTBOX id=\"txt" + propertyName + "\"   runat=\"server\"  TextDirection=\"" + ResourcesTesxtsBuilder.AddAdminGlobalText("EditorDirection", TextType.ServerControl) + "\" ");
                                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>");
                            }
                            else
                            {
                                controls.Append("\n\t\t\t\t\t\t<fckeditorv2:fckeditor id=\"txt" + propertyName + "\" runat=\"server\"></fckeditorv2:fckeditor>");
                            }
                            //-----------
                            controls.Append("\n\t\t\t\t\t</td>");
                            controls.Append("\n\t\t\t\t</tr>");

                            IshasFreeTextBoxControl = true;
                        }
                        else
                        {
                            if (ProjectBuilder.HasConfiguration)
                            {
                                controls.Append("\n\t\t\t\t<tr id=\"" + trPropertyName + "\" runat=\"server\" >");
                            }
                            else
                            {
                                controls.Append("\n\t\t\t\t<tr>");
                            }
                            controls.Append("\n\t\t\t\t\t<td class=\"Text\">" + ResourcesTesxtsBuilder.AddUserText(propertyName, TextType.HtmlClassic));
                            if (!column.AllowNulls)
                            {
                                controls.Append("<span class=\"RequiredField\"><asp:Label runat=\"server\" Text=\"*\" /></span>");
                            }
                            controls.Append("</td>");
                            controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                            controls.Append("\n\t\t\t\t\t\t<asp:TextBox id=\"txt" + propertyName + "\" runat=\"server\" TextMode=\"MultiLine\" CssClass=\"Controls\" ValidationGroup=\"" + Table + "\"></asp:TextBox>");
                            //controls.Append("\n\t\t\t\t\t\t<input type=\"text\"  class=\"Controls\"  name=\"txt" + propertyName + "LengthControler\" id=\"txt" + propertyName + "LengthControler\" style=\"width: 40px;\"  disabled>");
                            //-----------
                            controls.Append("\n\t\t\t\t\t</td>");
                            controls.Append("\n\t\t\t\t</tr>");
                        }
                    }
                    else if (datatype != "byte[]" && datatype != "Object" && datatype != "Guid")
                    {
                        if (ProjectBuilder.HasConfiguration)
                        {
                            controls.Append("\n\t\t\t\t<tr id=\"" + trPropertyName + "\" runat=\"server\" >");
                        }
                        else
                        {
                            controls.Append("\n\t\t\t\t<tr>");
                        }
                        controls.Append("\n\t\t\t\t\t<td class=\"Text\">" + ResourcesTesxtsBuilder.AddUserText(propertyName, TextType.HtmlClassic));
                        if (!column.AllowNulls)
                        {
                            controls.Append("<span class=\"RequiredField\"><asp:Label runat=\"server\" Text=\"*\" /></span>");
                        }
                        controls.Append("</td>");
                        controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXDownLoadExistFile
                        if (cnstr == null)
                        {
                            if (column.Name.IndexOf(ProjectBuilder.ExtensionInColumnName) > -1)
                            {
                                if (column.Name == ProjectBuilder.PhotoExtensionColumnName)
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:FileUpload ID=\"" + photoUploadreID + "\" runat=\"server\" CssClass=\"Controls\"  />");
                                    if (!column.AllowNulls)
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RequiredFieldValidator Display=\"Dynamic\" id=\"rfv" + propertyName + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"" + photoUploadreID + "\" ValidationGroup=\"" + Table + "\" Text=\"*\"></asp:RequiredFieldValidator>");
                                    }
                                }
                                else if (column.Name == "LogoExtension")
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:FileUpload ID=\"" + logoUploadreID + "\" runat=\"server\" CssClass=\"Controls\"  />");
                                    if (!column.AllowNulls)
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RequiredFieldValidator Display=\"Dynamic\" id=\"rfv" + propertyName + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"" + logoUploadreID + "\" ValidationGroup=\"" + Table + "\" Text=\"*\"></asp:RequiredFieldValidator>");
                                    }
                                }
                                else if (column.Name == "FileExtension")
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:FileUpload ID=\"" + fileUploadreID + "\" runat=\"server\" CssClass=\"Controls\"  />");

                                    if (!column.AllowNulls)
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RequiredFieldValidator Display=\"Dynamic\" id=\"rfv" + propertyName + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"" + fileUploadreID + "\" ValidationGroup=\"" + Table + "\" Text=\"*\"></asp:RequiredFieldValidator>");
                                    }
                                }
                                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;

                                    controls.Append("\n\t\t\t\t\t\t<asp:FileUpload ID=\"" + uploaderID + "\" runat=\"server\" CssClass=\"Controls\"  />");

                                    if (!column.AllowNulls)
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RequiredFieldValidator Display=\"Dynamic\" id=\"rfv" + propertyName + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"" + uploaderID + "\" ValidationGroup=\"" + Table + "\" Text=\"*\"></asp:RequiredFieldValidator>");
                                    }
                                }
                            }
                            //Check Priority
                            else if (column.Name.ToLower() == ProjectBuilder.PriorityColumnName.ToLower())
                            {
                                controls.Append("\n\t\t\t\t\t\t<asp:DropDownList id=\"" + ProjectBuilder.PriorityDropDownList + "\" runat=\"server\" CssClass=\"Controls\" ValidationGroup=\"" + Table + "\"></asp:DropDownList>");
                            }
                            else
                            {
                                if (column.Name.ToLower().IndexOf("password") > -1)
                                {
                                    hasPasswordField = true;
                                    controls.Append("\n\t\t\t\t\t\t<asp:TextBox MaxLength=\"" + Globals.GetTextBoxMaxLength(column) + "\"  id=\"txt" + propertyName + "\" runat=\"server\" TextMode=\"Password\" CssClass=\"Controls\" ValidationGroup=\"" + Table + "\"></asp:TextBox>");
                                    if (datatype == "int" || datatype == "long" || datatype == "short")
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RegularExpressionValidator Display=\"Dynamic\" ID=\"rev" + propertyName + "\" runat=\"server\" ControlToValidate=\"txt" + propertyName + "\" ErrorMessage=\"\" ValidationGroup=\"" + Table + "\" ValidationExpression=\"\\d*\"></asp:RegularExpressionValidator>");
                                    }
                                    else if (column.Name.ToLower().IndexOf("email") > -1)
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RegularExpressionValidator Display=\"Dynamic\" ID=\"rev" + propertyName + "\" runat=\"server\" ControlToValidate=\"txt" + propertyName + "\" ErrorMessage=\"\" ValidationGroup=\"" + Table + "\" ValidationExpression=\"\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\"></asp:RegularExpressionValidator>");
                                    }
                                }
                                else if (column.Length > 128)
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:TextBox MaxLength=\"" + Globals.GetTextBoxMaxLength(column) + "\" id=\"txt" + propertyName + "\" runat=\"server\" TextMode=\"MultiLine\" CssClass=\"Controls\" ValidationGroup=\"" + Table + "\"  maxlengthS=\"" + Globals.GetTextBoxMaxLength(column) + "\" onkeyup=\"return ismaxlength(this,document.forms[0].txt" + propertyName + "LengthControler)\"  onfocus=\"return ismaxlength(this,document.forms[0].txt" + propertyName + "LengthControler)\"></asp:TextBox>");
                                    controls.Append("\n\t\t\t\t\t\t<input type=\"text\"  class=\"Controls\"  name=\"txt" + propertyName + "LengthControler\" id=\"txt" + propertyName + "LengthControler\" style=\"width: 40px;\"  disabled>");
                                    if (datatype == "int" || datatype == "long" || datatype == "short")
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RegularExpressionValidator Display=\"Dynamic\" ID=\"rev" + propertyName + "\" runat=\"server\" ControlToValidate=\"txt" + propertyName + "\" ErrorMessage=\"\" ValidationGroup=\"" + Table + "\" ValidationExpression=\"\\d*\"></asp:RegularExpressionValidator>");
                                    }
                                    else if (column.Name.ToLower().IndexOf("email") > -1)
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RegularExpressionValidator Display=\"Dynamic\" ID=\"rev" + propertyName + "\" runat=\"server\" ControlToValidate=\"txt" + propertyName + "\" ErrorMessage=\"\" ValidationGroup=\"" + Table + "\" ValidationExpression=\"\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\"></asp:RegularExpressionValidator>");
                                    }
                                }
                                else
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:TextBox MaxLength=\"" + Globals.GetTextBoxMaxLength(column) + "\" id=\"txt" + propertyName + "\" runat=\"server\" CssClass=\"Controls\" ValidationGroup=\"" + Table + "\"></asp:TextBox>");

                                    if (datatype == "int" || datatype == "long" || datatype == "short")
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RegularExpressionValidator Display=\"Dynamic\" ID=\"rev" + propertyName + "\" runat=\"server\" ControlToValidate=\"txt" + propertyName + "\" ErrorMessage=\"\" Text=\"" + ResourcesTesxtsBuilder.AddAdminGlobalText("InvalidNumericalData", TextType.ServerControl) + "\" ValidationGroup=\"" + Table + "\" ValidationExpression=\"\\d*\"></asp:RegularExpressionValidator>");
                                    }
                                    else if (column.Name.ToLower().IndexOf("email") > -1)
                                    {
                                        controls.Append("\n\t\t\t\t\t\t<asp:RegularExpressionValidator Display=\"Dynamic\" ID=\"rev" + propertyName + "\" runat=\"server\" ControlToValidate=\"txt" + propertyName + "\" ErrorMessage=\"\" Text=\"" + ResourcesTesxtsBuilder.AddAdminGlobalText("InvalidEmail", TextType.ServerControl) + "\" ValidationGroup=\"" + Table + "\" ValidationExpression=\"\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\"></asp:RegularExpressionValidator>");
                                    }
                                }

                                if (!column.AllowNulls)
                                {
                                    controls.Append("\n\t\t\t\t\t\t<asp:RequiredFieldValidator Display=\"Dynamic\" id=\"rfv" + propertyName + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"txt" + propertyName + "\" ValidationGroup=\"" + Table + "\" Text=\"*\"></asp:RequiredFieldValidator>");
                                }
                            }
                        }
                        else
                        {
                            controls.Append("\n\t\t\t\t\t\t<asp:DropDownList id=\"ddl" + Globals.GetProgramatlyName(cnstr.ParentTable) + "\" runat=\"server\" CssClass=\"Controls\" ValidationGroup=\"" + Table + "\"></asp:DropDownList>");
                            if (!column.AllowNulls)
                            {
                                controls.Append("\n\t\t\t\t\t\t<asp:RequiredFieldValidator Display=\"Dynamic\" id=\"rfv" + propertyName + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"ddl" + Globals.GetProgramatlyName(cnstr.ParentTable) + "\" InitialValue=\"-1\" ValidationGroup=\"" + Table + "\" Text=\"*\"></asp:RequiredFieldValidator>");
                            }
                        }
                        controls.Append("\n\t\t\t\t\t</td>");
                        controls.Append("\n\t\t\t\t</tr>");
                        //--------------------------------------------
                        //Confirm Password
                        //--------------------------------------------
                        if (hasPasswordField)
                        {
                            string propertyConfirm = propertyName + "Confirm";
                            controls.Append("\n\t\t\t\t\t<td class=\"Text\">" + ResourcesTesxtsBuilder.AddUserText(propertyConfirm, TextType.HtmlClassic));
                            if (!column.AllowNulls)
                            {
                                controls.Append("<span class=\"RequiredField\"><asp:Label runat=\"server\" Text=\"*\" /></span>");
                            }
                            controls.Append("</td>");
                            controls.Append("\n\t\t\t\t\t<td class=\"Control\">");
                            controls.Append("\n\t\t\t\t\t\t<asp:TextBox MaxLength=\"" + Globals.GetTextBoxMaxLength(column) + "\"  id=\"txt" + propertyConfirm + "\" runat=\"server\" TextMode=\"Password\" CssClass=\"Controls\" ValidationGroup=\"" + Table + "\"></asp:TextBox>");
                            if (!column.AllowNulls)
                            {
                                controls.Append("\n\t\t\t\t\t\t<asp:RequiredFieldValidator Display=\"Dynamic\" id=\"rfv" + propertyConfirm + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"txt" + propertyName + "\" ValidationGroup=\"" + Table + "\" Text=\"*\"></asp:RequiredFieldValidator>");
                            }
                            controls.Append("\n\t\t\t\t\t\t <asp:CompareValidator ID=\"cv" + propertyConfirm + "\" runat=\"server\" ControlToCompare=\"txt" + propertyName + "\" ControlToValidate=\"txt" + propertyConfirm + "\" ErrorMessage=\"" + ResourcesTesxtsBuilder.AddUserText("InvalidConfirmPassord", TextType.ServerControl) + "\" Text=\"" + ResourcesTesxtsBuilder.AddUserText("InvalidConfirmPassord", TextType.ServerControl) + "\" ValidationGroup=\"" + Table + "\"></asp:CompareValidator>");
                            controls.Append("\n\t\t\t\t\t</td>");
                            controls.Append("\n\t\t\t\t</tr>");
                            hasPasswordField = false;
                        }
                    }
                }
            }
            controls.Append("\n\t\t\t\t<tr>");
            controls.Append("\n\t\t\t\t\t<td class=\"Result\" align=\"center\" colspan=\"2\">");
            //New
            controls.Append("\n\t\t\t\t\t\t<asp:HyperLink ID=\"hlCancel\" ImageUrl=\"/App_Design/Admin/Icons/Buttons/Cancel.jpg\"  runat=\"server\" Text=\"" + ResourcesTesxtsBuilder.AddAdminGlobalText("Cancel", TextType.ServerControl) + "\" NavigateUrl=\"default.aspx\"></asp:HyperLink>");
            controls.Append("\n\t\t\t\t\t\t<asp:ImageButton ID=\"ibtnCreateThenNew\"    ImageUrl=\"/App_Design/Admin/Icons/Buttons/CreateNew.png\"    runat=\"server\" AlternateText=\"" + ResourcesTesxtsBuilder.AddAdminGlobalText("CreateThenNew", TextType.ServerControl) + "\" onclick=\"ibtnCreateThenNew_Click\" ValidationGroup=\"" + Table + "\" />");
            controls.Append("\n\t\t\t\t\t\t<asp:ImageButton ID=\"ibtnCreateThenFinish\" ImageUrl=\"/App_Design/Admin/Icons/Buttons/CreateFinish.png\" runat=\"server\" AlternateText=\"<" + ResourcesTesxtsBuilder.AddAdminGlobalText("CreateThenFinish", TextType.ServerControl) + "\" onclick=\"ibtnCreateThenFinish_Click\" ValidationGroup=\"" + Table + "\" />");
            //OLD
            //controls.Append("\n\t\t\t\t\t\t<asp:Button id=\"btnCreate\" runat=\"server\" Width=\"100px\" Text=\"\" CssClass=\"Button\" OnClick=\"btnCreate_Click\" ValidationGroup=\"" + Table + "\"></asp:Button>");
            controls.Append("\n\t\t\t\t\t</td>");
            controls.Append("\n\t\t\t\t</tr>");

            //

            return(controls.ToString());
        }
Beispiel #12
0
        //
        protected string GenerateControls()
        {
            StringBuilder controls = new StringBuilder();
            string        datatype;

            foreach (SQLDMO.Column column in Fields)
            {
                //if (ID == null || column.Name != ID.Name)//||!Globals.CheckIsAddedBySql(ID))
                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 == "bool")
                    {
                        controls.Append("\n\t\t\t\t<tr id=\"tr" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\">");
                        controls.Append("\n\t\t\t\t\t<td class=\"text\">");
                        controls.Append("\n\t\t\t\t\t\t<span class=\"text\">");
                        controls.Append("\n\t\t\t\t\t\t\t" + ResourcesTesxtsBuilder.AddUserText(Globals.GetProgramatlyName(column.Name), TextType.HtmlClassic));
                        controls.Append("\n\t\t\t\t\t\t</span>");
                        controls.Append("\n\t\t\t\t\t\t<span class=\"value\">");
                        controls.Append("\n\t\t\t\t\t\t\t<asp:Label id=\"lbl" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" ></asp:Label>");
                        controls.Append("\n\t\t\t\t\t\t</span>");
                        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)
                    {
                        if (column.Name.ToLower().IndexOf("details") > -1 || column.Name.ToLower().IndexOf("description") > -1)
                        {
                            hasDetails   = true;
                            detailsLabel = "lbl" + Globals.GetProgramatlyName(column.Name);
                        }
                        else
                        {
                            controls.Append("\n\t\t\t\t<tr id=\"tr" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\">");
                            controls.Append("\n\t\t\t\t\t<td class=\"text\">");
                            controls.Append("\n\t\t\t\t\t\t<span class=\"text\">");
                            controls.Append("\n\t\t\t\t\t\t\t" + ResourcesTesxtsBuilder.AddUserText(Globals.GetProgramatlyName(column.Name), TextType.HtmlClassic));
                            controls.Append("\n\t\t\t\t\t\t</span>");
                            controls.Append("\n\t\t\t\t\t\t<br />");
                            controls.Append("\n\t\t\t\t\t\t<span class=\"value\">");
                            controls.Append("\n\t\t\t\t\t\t\t<asp:Label id=\"lbl" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" ></asp:Label>");
                            controls.Append("\n\t\t\t\t\t\t</span>");
                            controls.Append("\n\t\t\t\t\t</td>");
                            controls.Append("\n\t\t\t\t</tr>");
                        }
                    }
                    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;
                            }
                            else if (column.Name == "LogoExtension")
                            {
                                hasLogo = true;
                            }
                            else if (column.Name == "FileExtension")
                            {
                                controls.Append("\n\t\t\t\t<tr id=\"tr" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\">");
                                controls.Append("\n\t\t\t\t\t<td class=\"text\">");
                                controls.Append("\n\t\t\t\t\t\t<span class=\"text\">");
                                controls.Append("\n\t\t\t\t\t\t\t" + ResourcesTesxtsBuilder.AddUserText(Globals.GetProgramatlyName(column.Name), TextType.HtmlClassic));
                                controls.Append("\n\t\t\t\t\t\t</span>");
                                controls.Append("\n\t\t\t\t\t\t<span class=\"value\">");
                                controls.Append("\n\t\t\t\t\t\t\t<asp:HyperLink ID=\"" + fileName + "\" runat=\"server\" />");
                                controls.Append("\n\t\t\t\t\t\t</span>");
                                controls.Append("\n\t\t\t\t\t</td>");
                                controls.Append("\n\t\t\t\t</tr>");
                            }
                            else if (column.Name.IndexOf("Extension") > -1)
                            {
                                string[] stringSeparators = new string[] { "Extension" };
                                string[] separatingResult = column.Name.Split(stringSeparators, StringSplitOptions.None);
                                string   propertyName     = separatingResult[0];
                                controls.Append("\n\t\t\t\t<tr id=\"tr" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\">");
                                controls.Append("\n\t\t\t\t\t<td class=\"text\">");
                                controls.Append("\n\t\t\t\t\t\t<span class=\"text\">");
                                controls.Append("\n\t\t\t\t\t\t\t" + ResourcesTesxtsBuilder.AddUserText(Globals.GetProgramatlyName(column.Name), TextType.HtmlClassic));
                                controls.Append("\n\t\t\t\t\t\t</span>");
                                controls.Append("\n\t\t\t\t\t\t<span class=\"value\">");
                                controls.Append("\n\t\t\t\t\t\t\t<asp:HyperLink ID=\"hl" + propertyName + "\" runat=\"server\"   />");
                                controls.Append("\n\t\t\t\t\t\t</span>");
                                controls.Append("\n\t\t\t\t\t</td>");
                                controls.Append("\n\t\t\t\t</tr>");
                            }
                        }
                        else
                        {
                            controls.Append("\n\t\t\t\t<tr id=\"tr" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\">");
                            controls.Append("\n\t\t\t\t\t<td class=\"text\">");
                            controls.Append("\n\t\t\t\t\t\t<span class=\"text\">");
                            controls.Append("\n\t\t\t\t\t\t\t" + ResourcesTesxtsBuilder.AddUserText(Globals.GetProgramatlyName(column.Name), TextType.HtmlClassic));
                            controls.Append("\n\t\t\t\t\t\t</span>");
                            controls.Append("\n\t\t\t\t\t\t<span class=\"value\">");
                            controls.Append("\n\t\t\t\t\t\t\t<asp:Label id=\"lbl" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" ></asp:Label>");
                            controls.Append("\n\t\t\t\t\t\t</span>");
                            controls.Append("\n\t\t\t\t\t</td>");
                            controls.Append("\n\t\t\t\t</tr>");
                        }
                    }
                }
            }

            //controls.Append("\n\t\t\t\t\t</td>");
            //controls.Append("\n\t\t\t\t</tr>");
            //
            return(controls.ToString());
        }
Beispiel #13
0
        //
        protected 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;
            int    coulmnNo = 0;

            foreach (SQLDMO.Column column in Fields)
            {
                coulmnNo = coulmnNo + 1;
                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);
                    //dateTime
                    if (Globals.GetSqlDataType(column.Datatype) == SqlDbType.DateTime)
                    {
                        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\"><script language=\"javascript\" type=\"text/javascript\" src=\"/sitescripts/datetimepicker.js\"></script>");
                        controls.Append("\n\t\t\t\t\t\t<input id=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" class=\"Control\" style=\"width:250px\" type=\"text\" readonly=\"readonly\" /><a href=\"javascript:NewCal('ctl00$BasicContent$txt" + Globals.GetProgramatlyName(column.Name) + "\','ddmmyyyy')\"><img src=\"/images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"ÇÎÊÑ ÇáÊÇÑíÎ\"></a>");

                        if (!column.AllowNulls)
                        {
                            controls.Append("\n\t\t\t\t\t\t<anthem:RequiredFieldValidator id=\"rfv" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" ValidationGroup=\"" + ClassName + "\">*</anthem:RequiredFieldValidator>");
                        }

                        controls.Append("\n\t\t\t\t\t</td>");
                        controls.Append("\n\t\t\t\t</tr>");
                    }
                    //dateTime
                    else 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
                        #region OlD FREE
                        //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\t<fckeditorv2:fckeditor id=\"fck" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\"></fckeditorv2:fckeditor>");
                        #endregion
                        //-----------
                        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")
                    {
                        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)
                        {
                            #region old
                            //controls.Append("\n\t\t\t\t\t\t<asp:TextBox id=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" CssClass=\"Control\" 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>");
                            #endregion
                            if (Globals.GetTextBoxMaxLength(column) > 499)
                            {
                                controls.Append("\n\t\t\t\t\t\t<anthem:TextBox TextMode=\"MultiLine\"   id=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\"  CssClass=\"Control\" maxlengthS=\"" + Globals.GetTextBoxMaxLength(column) + "\" MaxLength=\"" + Globals.GetTextBoxMaxLength(column) + "\" ValidationGroup=\"" + ClassName + "\" onkeyup=\"return ismaxlength(this,document.forms[0].thelength" + coulmnNo + ")\" onfocus=\"return ismaxlength(this,document.forms[0].thelength" + coulmnNo + ")\" height=150 width=350 ></anthem:TextBox>");
                                controls.Append("\n\t\t\t\t\t\t<input type=\"text\" class=\"Control\" name=\"thelength" + coulmnNo + "\" id=\"thelength" + coulmnNo + "\" style=\"height: 20px; width: 40px;\" disabled> <script src=\"/SiteScripts/textarea.js\"></script>");
                            }
                            else
                            {
                                controls.Append("\n\t\t\t\t\t\t<anthem:TextBox id=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\"  CssClass=\"Control\" MaxLength=\"" + Globals.GetTextBoxMaxLength(column) + "\" ValidationGroup=\"" + ClassName + "\" ></anthem:TextBox>");
                            }
                            if (!column.AllowNulls)
                            {
                                controls.Append("\n\t\t\t\t\t\t<anthem:RequiredFieldValidator id=\"rfv" + Globals.GetProgramatlyName(column.Name) + "\" runat=\"server\" ErrorMessage=\"*\" ControlToValidate=\"txt" + Globals.GetProgramatlyName(column.Name) + "\" ValidationGroup=\"" + ClassName + "\">*</anthem: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=\"btnUpdate\" runat=\"server\" Width=\"100px\" Text=\"ÊÚÏíá\" CssClass=\"Submit\" OnClick=\"btnUpdate_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());
        }