Exemple #1
0
        private string SelectHtml(string connStr, string tableName, string tableDescN)
        {
            if ((!string.IsNullOrEmpty(this.devConnStr) &&
                 (this.devConnStr.Split(new char[] { ';' })[0].Split(new char[] { '=' })[1] != "")) &&
                ((this.devConnStr.Split(new char[] { ';' })[1].Split(new char[] { '=' })[1] != "") &&
                 !string.IsNullOrEmpty(tableName)))
            {
                if (this.fieldList == null)
                {
                    this.fieldList = new List <EditFieldParam>();
                    this.SetFieldList();
                }
                else if (this.fieldList.Count == 0)
                {
                    this.SetFieldList();
                }
            }
            string whereValue     = string.Empty;
            string whereFieldName = string.Empty;

            if ((HttpContext.Current != null) &&
                (HttpContext.Current.Request.Url.Query.Replace("?", "").Split(new char[] { '=' }).Length > 1))
            {
                whereValue =
                    HttpUtility.UrlDecode(
                        MyControl_FilterHelper.GetString(
                            HttpContext.Current.Request.Url.Query.Replace("?", "").Split(new char[] { '=' })[1]));
                whereFieldName = HttpContext.Current.Request.Url.Query.Replace("?", "").Split(new char[] { '=' })[0];
            }
            return(this.GetHtml(tableName, tableDescN,
                                AdminData.GetModelDataTable(connStr, tableName, this.FileName, this.ProcName,
                                                            whereFieldName, whereValue, this.fieldList)));
        }
Exemple #2
0
 protected override void Render(HtmlTextWriter writer)
 {
     if (string.IsNullOrEmpty(this.ConnStrName) || string.IsNullOrEmpty(this.TableName))
     {
         writer.Write("");
     }
     else
     {
         try
         {
             string str = string.Empty;
             if ((HttpContext.Current != null) &&
                 (HttpContext.Current.Request.Url.Query.Replace("?", "").Split(new char[] { '=' }).Length > 1))
             {
                 str =
                     MyControl_FilterHelper.GetString(
                         HttpContext.Current.Request.Url.Query.Replace("?", "").Split(new char[] { '=' })[1]);
             }
             if (MyControl_CacheHelper.Exists(this.TableName + str))
             {
                 writer.Write(MyControl_CacheHelper.Get(this.TableName + str));
             }
             else
             {
                 string str2 = this.SelectHtml(this.ConnStrName,
                                               this.TableName.ToLower().Replace("with(nolock)", "").Trim(),
                                               this.TableDescN);
                 if (!string.IsNullOrEmpty(str))
                 {
                     MyControl_CacheHelper.Set(this.TableName + str, str2, 1);
                 }
                 writer.Write(str2);
             }
         }
         catch (Exception exception)
         {
             writer.Write(exception);
         }
     }
 }
Exemple #3
0
        private string GetHtml(string tableName, string tableDescN, DataTable data)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(
                "<style type=\"text/css\">body, table, td, th, span, p, div, a, form, input, button, select, option, textarea { font-family : simsun; font-size : 12px }");
            builder.Append("a:link {color: #0000ea; text-decoration:none}");
            builder.Append("a:visited {color: #006666; text-decoration: none}");
            builder.Append("a:active {color:#ff0000; text-decoration: underline}");
            builder.Append("a:hover {color: #ff0000; text-decoration: underline}");
            builder.Append(
                "a.btn-i1{display:block;width:120px;text-align:center;color:#E6E956;background-color:#CCEEEE; text-decoration:none; border-left:#99A52F 1px solid; border-top:#99A52F 1px solid; border-right:#61691E 1px solid; border-bottom:#3F4414 1px solid;padding:2px 0 0 0;}");
            builder.Append("a.btn-i1:link {color: #000000; text-decoration:none}");
            builder.Append("a.btn-i1:visited {color: #006666; text-decoration: none}");
            builder.Append("a.btn-i1:active {");
            builder.Append("color:#ff0000; text-decoration: underline}");
            builder.Append("a.btn-i1:hover {color: #ff0000; text-decoration: underline}");
            builder.Append(".bottomLine { border-bottom:1px solid #000000 }");
            builder.Append(".rightLine { border-right:1px solid #000000 }");
            builder.Append(".ftGreen { color : green }");
            builder.Append(".bgColor { background-color:#33CCCC }");
            builder.Append(".bgColor1 { background-color:#CCEEEE }");
            builder.Append(".bgColor2 { background-color:#66CCFF }");
            builder.Append(".bgDark { background-color:#000000 }");
            builder.Append(".bgGray { background-color:Gray }");
            builder.Append(".bgLightGray { background-color : #DDDDDD }");
            builder.Append(".bgLightBlue { background-color : lightblue }");
            builder.Append(".bgLightGreen { background-color : lightgreen }");
            builder.Append(".bgWhite { background-color:#FFFFFF }");
            builder.Append(".buttonWidth { width: 100px }");
            builder.Append(".inputWidth { width: 200px }");
            builder.Append(
                ".SortFieldLable{text-decoration:underline;background-color:#66CCFF;color:#3366ff;cursor:hand;}");
            builder.Append(".pagebar{line-height:20px;height:20px;}");
            builder.Append(
                ".pagebar a,.pagebar .now-page{padding:1px 3px 2px 3px;margin:0 2px;text-align:center;font-weight:bold;font-family:Verdana;border:1px solid #ccc;text-decoration:none;COLOR: #006699;}");
            builder.Append(
                ".pagebar a:hover{border:1px solid #c00;text-decoration:none;BACKGROUND-COLOR: #f1ffc0;COLOR: #c00;}");
            builder.Append("a.wa {COLOR: #7c7b6b;BACKGROUND-COLOR: #f1ff00;}");
            builder.Append("a.wah {COLOR: #7c7b6b;}</style>");
            builder.Append("<script type=\"text/javascript\">");
            builder.Append("function Edit(edit) {");
            builder.Append("document.getElementById('txtEdit').value=edit;");
            builder.Append("document.forms[0].action = location.href;");
            builder.Append("document.forms[0].method = \"post\";");
            builder.Append("document.forms[0].submit();");
            builder.Append("}");
            builder.Append("</script>");
            builder.Append("<table width=\"98%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
            builder.Append("<tr>");
            builder.Append("<td>");
            builder.Append("<table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"1\" class=\"bgDark\">");
            builder.Append("<tr class=\"bgLightGray\">");
            builder.Append("<td colspan=\"3\" align=\"left\">");
            if (data != null)
            {
                builder.Append("<b><font color=\"#009900\">【" + tableDescN + "编辑】</font></b>");
            }
            else
            {
                builder.Append("<b><font color=\"#009900\">【" + tableDescN + "新增】</font></b>");
            }
            builder.Append("</td>");
            builder.Append("</tr>");
            if (this.fieldList != null)
            {
                foreach (EditFieldParam param in this.fieldList)
                {
                    if ((HttpContext.Current != null) &&
                        param.FieldName.Equals(
                            HttpContext.Current.Request.Url.Query.Replace("?", "").Split(new char[] { '=' })[0],
                            StringComparison.OrdinalIgnoreCase))
                    {
                        param.IsEdit = false;
                    }
                    if ((param.IsEdit || (HttpContext.Current == null)) ||
                        !string.IsNullOrEmpty(
                            HttpContext.Current.Request.Url.Query.Replace("?", "").Split(new char[] { '=' })[0]))
                    {
                        string defaultValue = string.Empty;
                        if ((data != null) && (data.Rows.Count == 1))
                        {
                            defaultValue = MyControl_FilterHelper.GetString(data.Rows[0][param.FieldName]);
                        }
                        else if (!string.IsNullOrEmpty(param.DefaultValue) && (param.FieldType != FieldType.DateTime))
                        {
                            defaultValue = param.DefaultValue;
                        }
                        if (string.IsNullOrEmpty(param.RowClass))
                        {
                            builder.Append("<tr>");
                        }
                        else
                        {
                            builder.Append("<tr class=\"" + param.RowClass + "\">");
                        }
                        builder.Append("<td class=\"bgColor2\" align=\"right\" width=\"15%\"><span id=\"L_" +
                                       param.FieldName + "\"> ");
                        builder.Append(param.FieldDescN + ":");
                        builder.Append("</span></td>");
                        builder.Append("<td width=\"10%\" class=\"bgWhite\">");
                        string str2 = string.Empty;
                        if (!param.IsEdit)
                        {
                            str2 = "disabled=\"disabled\"";
                        }
                        if ((param.SltList != null) && (param.SltList.Count > 0))
                        {
                            builder.Append("<select id=\"" + param.FieldName + "\" " + str2 + " name=\"" +
                                           param.FieldName + "\">");
                            builder.Append("<option value=\"\">--请选择--</option>");
                            foreach (StatusList list in param.SltList)
                            {
                                builder.Append("<option value=\"" + list.Value + "\">" + list.Text + "</option>");
                            }
                            builder.Append("</select>");
                            builder.Append("<script type=\"text/javascript\">if('" + defaultValue +
                                           "' != ''){document.getElementById('" + param.FieldName + "').value='" +
                                           defaultValue + "';}else{document.getElementById('" + param.FieldName +
                                           "').selectedIndex=0;}</script>");
                        }
                        else if (param.FieldType == FieldType.DateTime)
                        {
                            builder.Append("<input type=\"text\" " + str2 + " id=\"" + param.FieldName +
                                           "\" style=\"height: 15px; width: 160px;\" name=\"" + param.FieldName +
                                           "\" value=\"" + defaultValue +
                                           "\" onclick=\"WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss',skin:'whyGreen'})\" class=\"inputcss\" />");
                        }
                        else if (((param.FieldType == FieldType.Int) || (param.FieldType == FieldType.Long)) ||
                                 ((param.FieldType == FieldType.Float) || (param.FieldType == FieldType.Decimal)))
                        {
                            builder.Append("<input type=\"text\" " + str2 + " value=\"" + defaultValue + "\" id=\"" +
                                           param.FieldName + "\" style=\"height: 15px; width: 160px;\" name=\"" +
                                           param.FieldName + "\" />");
                        }
                        else if (param.IsTextarea)
                        {
                            builder.Append("<textarea  " + str2 + " id=\"" + param.FieldName + "\" name=\"" +
                                           param.FieldName +
                                           "\" style=\"width:160px; height:60px;\" cols=\"20\" rows=\"100\">" +
                                           defaultValue + "</textarea>");
                        }
                        else
                        {
                            if (((param.FieldType == FieldType.Int) || (param.FieldType == FieldType.Long)) ||
                                ((param.FieldType == FieldType.Float) || (param.FieldType == FieldType.Decimal)))
                            {
                                param.FieldLen = 50;
                            }
                            builder.Append(
                                string.Concat(new object[]
                            {
                                "<input type=\"text\" ", str2, " value=\"", defaultValue, "\" id=\"",
                                param.FieldName, "\" maxlength=\"", param.FieldLen,
                                "\" style=\"height: 15px; width: 160px;\" name=\"", param.FieldName, "\" />"
                            }));
                        }
                        builder.Append("</td>");
                        builder.Append("<td class=\"bgWhite\">");
                        builder.Append("<font color='#424242'><span id=\"M_" + param.FieldName + "\"> " +
                                       param.ValueMemo + "</span></font>");
                        builder.Append("</td>");
                        builder.Append("</tr>");
                    }
                }
            }
            builder.Append("<tr>");
            builder.Append("<td class=\"bgColor2\" align=\"right\">");
            builder.Append("相关操作:");
            builder.Append("</td>");
            builder.Append("<td class=\"bgWhite\" colspan=\"2\">");
            if ((data == null) && this.AddBtnVisible)
            {
                builder.Append(
                    "&nbsp;<input id=\"BtnEdit\" type=\"button\" value=\" 新 增 \" onclick=\"Edit('add');\" /><input type=\"hidden\" value=\"\" id=\"txtEdit\" name=\"txtEdit\" />");
            }
            if ((data != null) && this.EditBtnVisible)
            {
                builder.Append(
                    "&nbsp;<input id=\"BtnEdit\" type=\"button\" value=\" 修 改 \" onclick=\"Edit('edit');\" /><input type=\"hidden\" value=\"\" id=\"txtEdit\" name=\"txtEdit\" />");
            }
            builder.Append(
                "<input type=\"button\" style=\"margin-left:150px;\" value=\" 返  回 \" onclick=\"javascript:location.href='" +
                this.FileName + ".aspx';\" />");
            builder.Append("</td>");
            builder.Append("</tr>");
            builder.Append("</table>");
            builder.Append("</td>");
            builder.Append("</tr>");
            builder.Append("</table>");
            return(builder.ToString());
        }