//
        private string CreateLoadData()
        {
            StringBuilder loadData = new StringBuilder();

            loadData.Append("\n\tprivate void LoadData()");
            loadData.Append("\n\t{");
            loadData.Append("\n\t\tDataTable dtSource= " + global.TableFactoryClass + "." + StoredProcedureTypes.GetAll.ToString() + "();");
            loadData.Append("\n\t\tif(dtSource!=null&&dtSource.Rows.Count >0)");
            loadData.Append("\n\t\t{");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataSource= dtSource;");
            if (ID != null)
            {
                loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataKeyField=\"" + Globals.GetProgramatlyName(ID.Name) + "\";");
            }
            loadData.Append("\n\t\t\tif(" + global.ViewAllDataGrid + ".PageSize>=dtSource.Rows.Count)");
            loadData.Append("\n\t\t\t{");
            loadData.Append("\n\t\t\t\t" + global.ViewAllDataGrid + ".AllowPaging=false;");
            loadData.Append("\n\t\t\t}");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataBind();");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".Visible = true;");
            loadData.Append("\n\t\t}");
            loadData.Append("\n\t\telse");
            loadData.Append("\n\t\t{");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".Visible=false;");
            loadData.Append("\n\t\t\tlblResult.Text = " + LanguageXmlBuilder.AddText("ThereIsNoData", TextType.Text) + ";");
            loadData.Append("\n\t\t}");
            loadData.Append("\n\t}");
            return(loadData.ToString());
        }
        //
        private string CreateItemDataBoundHandler()
        {
            StringBuilder pageIndexHandler = new StringBuilder();

            pageIndexHandler.Append("\n\tprotected void " + global.ViewAllDataGrid + "_ItemDataBound(object source, DataGridItemEventArgs e)");
            pageIndexHandler.Append("\n\t{");
            pageIndexHandler.Append("\n\t\tif (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)");
            pageIndexHandler.Append("\n\t\t{");
            pageIndexHandler.Append("\n\t\t\tImageButton lbtnDelete = (ImageButton)e.Item.FindControl(\"lbtnDelete\");");
            pageIndexHandler.Append("\n\t\t\tlbtnDelete.Attributes.Add(\"onclick\", \"return confirm('\"+" + LanguageXmlBuilder.AddText("DeleteActivation", TextType.Text) + "+\"')\");");
            pageIndexHandler.Append("\n\t\t\tlbtnDelete.AlternateText = " + LanguageXmlBuilder.AddText("Delete", TextType.Text) + ";");

            pageIndexHandler.Append("\n\t\t}");
            pageIndexHandler.Append("\n\t}");
            return(pageIndexHandler.ToString());
        }
Beispiel #3
0
        //----------------------------------
        private string GenerateControls()
        {
            string        dataGridID = "dg" + global.TableProgramatlyName;
            StringBuilder controls   = new StringBuilder();

            controls.Append("\n\t\t\t\t<tr>");
            controls.Append("\n\t\t\t\t\t<td class=\"Result\" align=\"center\" >");
            controls.Append("\n\t\t\t\t\t\t<asp:Label ID=\"lblResult\" runat=\"server\" ForeColor=\"Red\" Text=\"\"></asp:Label>");
            controls.Append("\n\t\t\t\t\t</td>");
            controls.Append("\n\t\t\t\t</tr>");

            #region DataGrid Declaretion And Propreties
            controls.Append("\n\t\t\t\t\t<td class=\"Control\" align=\"center\" >");
            controls.Append("\n\t\t\t\t\t\t<asp:datagrid id=\"" + dataGridID + "\" runat=\"server\" SkinId=\"GridViewSkin\" ");
            controls.Append("\n\t\t\t\t\t\tOnDeleteCommand=\"" + dataGridID + "_DeleteCommand\" OnItemDataBound=\"" + dataGridID + "_ItemDataBound\" OnPageIndexChanged=\"" + dataGridID + "_PageIndexChanged\" >");
            #endregion
            //
            if (Fields.Count > 0)
            {
                controls.Append("\n\t\t\t\t\t\t<Columns>");
                int i = 0;
                foreach (SQLDMO.Column column in Fields)
                {
                    if ((ID == null || column.Name != ID.Name) && i < 4)
                    {
                        if (allParameters != null && !allParameters.Contains(column.Name))
                        {
                            continue;
                        }
                        controls.Append("\n\t\t\t\t\t\t\t<asp:BoundColumn DataField=\"" + column.Name + "\" HeaderText=\"" + column.Name + "\"></asp:BoundColumn>");
                    }
                    ++i;
                }
                if (ID != null)
                {
                    controls.Append("\n\t\t\t\t\t\t\t<asp:TemplateColumn HeaderText=\"\">");
                    controls.Append("\n\t\t\t\t\t\t\t<ItemTemplate>");
                    controls.Append("\n\t\t\t\t\t\t\t\t<a href='<%# \"Edit.aspx?" + Globals.GetProgramatlyName(ID.Name) + "=\"+DataBinder.Eval(Container.DataItem, \"" + ID.Name + "\")+\"&iK=" + global.TableProgramatlyName + "\" %>' class='Link'>");
                    controls.Append("\n\t\t\t\t\t\t\t\t\t<img src=\"/App_Design/Globals/Images/Admin/edit.gif\" border=\"0\" alt=\"<%#" + LanguageXmlBuilder.AddText("Update", TextType.Text) + "%>\" /></a>");
                    controls.Append("\n\t\t\t\t\t\t\t</ItemTemplate>");
                    controls.Append("\n\t\t\t\t\t\t\t</asp:TemplateColumn>");
                    //Delete column.
                    controls.Append("\n\t\t\t\t\t\t\t<asp:TemplateColumn HeaderText=\"\">");
                    controls.Append("\n\t\t\t\t\t\t\t<ItemTemplate>");
                    controls.Append("\n\t\t\t\t\t\t\t\t<asp:ImageButton ID=\"lbtnDelete\" AlternateText=\"\" ImageUrl=\"/App_Design/Globals/Images/Admin/delete.gif\" CommandName=\"Delete\" runat=\"server\"></asp:ImageButton>");
                    controls.Append("\n\t\t\t\t\t\t\t</ItemTemplate>");
                    controls.Append("\n\t\t\t\t\t\t\t</asp:TemplateColumn>");
                }
                controls.Append("\n\t\t\t\t\t\t</Columns>");
                controls.Append("\n\t\t\t\t\t\t</asp:datagrid>");
            }
            controls.Append("\n\t\t\t\t\t</td>");
            controls.Append("\n\t\t\t\t</tr>");
            //--------------------------------

            return(controls.ToString());
        }
        //
        private string CreateDeleteCommandHandler()
        {
            string dataGridID = "dg" + global.TableProgramatlyName;
            string id         = Globals.GetProgramatlyName(ID.Name);

            id = Globals.ConvetStringToCamelCase(id);
            StringBuilder pageIndexHandler = new StringBuilder();

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

            pageIndexHandler.Append("\n\t\t}");
            pageIndexHandler.Append("\n\t}");
            return(pageIndexHandler.ToString());
            //
        }
        //
        private string GeneratePageLoad()
        {
            string pageLoadBody = "\n\t\tlblResult.Text=\"\";";

            pageLoadBody += "\n\t\tif(!IsPostBack)";
            pageLoadBody += "\n\t\t{";
            string gridID = "dg" + global.TableProgramatlyName;

            pageLoadBody += "\n\t\t\t" + gridID + ".Columns[" + gridID + ".Columns.Count - 2].HeaderText = " + LanguageXmlBuilder.AddText("Update", TextType.Text) + ";";
            pageLoadBody += "\n\t\t\t" + gridID + ".Columns[" + gridID + ".Columns.Count - 1].HeaderText = " + LanguageXmlBuilder.AddText("Delete", TextType.Text) + ";";
            pageLoadBody += "\n\t\t\tLoadData();";
            pageLoadBody += "\n\t\t};";
            return(GeneratePageLoadHandler(pageLoadBody));
        }