예제 #1
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
//        /// <summary>
//        /// 서버의 DataTable을 클라이언트의 자바스크립트에서 쓸 수 있도록 변경함.
//        /// </summary>
//        /// <param name="dt"></param>
//        /// <param name="AddScriptTag">&lt;script&gt; 태그 추가</param>
//        /// <remarks>오라클의 경우는 필드 이름이 전부 대문자로 리턴되므로 소문자로 변경하려면 ColumnNameToLower 인수를 true로 할 것.</remarks>
//        /// <returns></returns>
//        private static string GetClientDataSet(object DataSetOrDataTable, string VarName, bool IsArray, bool IsDataTable, bool ColumnNameToLower, bool AddScriptTag)
//        {
//            List<DataSet> ads = new List<DataSet>();
//            List<DataTable> adt = new List<DataTable>();

//            if (IsDataTable)
//            {
//                if (IsArray)
//                {
//                    adt.AddRange((IEnumerable<DataTable>)DataSetOrDataTable);
//                }
//                else
//                {
//                    adt.Add((DataTable)DataSetOrDataTable);
//                }
//            }
//            else
//            {
//                if (IsArray)
//                {
//                    ads.AddRange((IEnumerable<DataSet>)DataSetOrDataTable);
//                }
//                else
//                {
//                    ads.Add((DataSet)DataSetOrDataTable);
//                }
//            }

//            List<string> aStmt = new List<string>();

//            if (IsDataTable)
//            {
//                if (IsArray)
//                {
//                    aStmt.Add("var " + VarName + " = [];");
//                }

//                for (int nTbl = 0; nTbl < adt.Count; nTbl++)
//                {
//                    DataTable dt = adt[nTbl];

//                    string VarNameCur = IsArray ? VarName + "[" + nTbl + "]" : VarName;
//                    aStmt = GetClientDataTableCommon(aStmt, dt, VarNameCur, ColumnNameToLower);
//                }
//            }
//            else
//            {
//                /*
//var ads = [];

//ads[0] = { };
//ads[0].Tables = [];
//ads[0].Tables[0] = new CDataTable();
//ads[0].Tables[1] = new CDataTable();


//ads[1].Tables = [];
//ads[1].Tables[0] = new CDataTable();
//ads[1].Tables[1] = new CDataTable();


//var ds = { };
//ds.Tables = [];
//ds.Tables[0] = new CDataTable();
//ds.Tables[1] = new CDataTable();

//*/
//                if (IsArray)
//                    aStmt.Add("var " + VarName + " = [];");
//                else
//                    aStmt.Add("var " + VarName + " = { Tables: [] };");

//                for (int nDs = 0; nDs < ads.Count; nDs++)
//                {
//                    DataSet ds = ads[nDs];

//                    if (IsArray)
//                        aStmt.Add(VarName + "[" + nDs + "] = { Tables: [] };");

//                    string VarNameCur = IsArray ? VarName + "[" + nDs + "].Tables" : VarName + ".Tables";

//                    for (int nTbl = 0; nTbl < ds.Tables.Count; nTbl++)
//                    {
//                        DataTable dt = ds.Tables[nTbl];

//                        string VarNameCur2 = VarNameCur + "[" + nTbl + "]";
//                        aStmt = GetClientDataTableCommon(aStmt, dt, VarNameCur2, ColumnNameToLower);
//                    }
//                }
//            }


//            string s = CScript.GetScript(aStmt, AddScriptTag);
//            return s;
//        }
        //private static List<string> GetClientDataTableCommon(List<string> aStmt, DataTable dt, string VarName, bool ColumnNameToLower)
        //{
        //    aStmt.Add(VarName + " = new CDataTable();");

        //    string[] aColName = GetColumnNameInArray(dt, ColumnNameToLower);

        //    string ColumnNameList = "";
        //    for (int cl = 0; cl < aColName.Length; cl++)
        //    {
        //        ColumnNameList += ", \"" + aColName[cl] + "\"";
        //    }
        //    ColumnNameList = ColumnNameList.Substring(2);
        //    aStmt.Add(VarName + ".Columns = [ " + ColumnNameList + " ];");

        //    string RowList = GetClientDataRow(dt, aColName);
        //    aStmt.Add(VarName + ".Rows = " + RowList + ";");

        //    return aStmt;
        //}

        //public static string GetClientDataRow(DataTable dt, string[] aColName)
        //{
        //    List<string> aRow = new List<string>();
        //    for (int rw = 0, rw2 = dt.Rows.Count; rw < rw2; rw++)
        //    {
        //        DataRow dr = dt.Rows[rw];

        //        string[] aNameValue = new string[dt.Columns.Count];
        //        for (int cl = 0, cl2 = dt.Columns.Count; cl < cl2; cl++)
        //        {
        //            object oValue = dr[cl];

        //            string Text = GetValueForJson(oValue);

        //            //JSON 형식을 리턴할 때 Name에 큰 따옴표를 붙여야만 에러를 내지 않음.
        //            aNameValue[cl] = "\"" + aColName[cl] + "\":" + Text;
        //        }
        //        string NameValueList = string.Join(", ", aNameValue);
        //        aRow.Add("{ " + NameValueList + " }");
        //    }

        //    string RowList = "[ " + string.Join(",\r\n", aRow.ToArray()) + " ]";
        //    return RowList;
        //}
        //public static string GetClientDataRow(DataTable dt)
        //{
        //    string[] aColName = GetColumnNameInArray(dt);
        //    return GetClientDataRow(dt, aColName);
        //}

        /// <summary>
        /// JSON 형식으로 리턴하기 위함.
        /// null은 null로, 날짜 형식과 문자열은 따옴표를 양쪽에 묶고, 나머지는 따옴표를 묶지 않은 값을 리턴함.
        /// </summary>
        /// <param name="oValue"></param>
        /// <returns></returns>
        public static string GetValueForJson(object oValue)
        {
            string NullString = "null";
            string Delim      = "";

            string Text = CType.ConvertColumnValueToString(oValue, NullString);

            if (Text != NullString)
            {
                SqlColumnTypeSimple TypeSimple = CSql.GetColumnTypeSimple(oValue);
                if (TypeSimple == SqlColumnTypeSimple.DateTime)
                {
                    Delim = "\"";

                    var dtValue = (DateTime)oValue;
                    Text = Delim + dtValue.ToString(CConst.Format_yyyy_MM_dd_HH_mm_ss_fff) + Delim;

                    //new Date는 JSON 형식에 맞지 않으므로 주석.
                    //Text = string.Format("new Date({0}, {1}, {2}, {3}, {4}, {5}, {6})",
                    //    dtValue.Year, dtValue.Month - 1, dtValue.Day,
                    //    dtValue.Hour, dtValue.Minute, dtValue.Second, dtValue.Millisecond);
                }
                else if (TypeSimple == SqlColumnTypeSimple.Boolean)
                {
                    Text = (bool)oValue ? "true" : "false";
                }
                else
                {
                    Delim = (TypeSimple == SqlColumnTypeSimple.String) ? "\"" : "";
                    Text  = Delim + CScript.ReplaceForScriptVariable(Text) + Delim;
                }
            }

            return(Text);
        }
예제 #2
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        private static void AlertAndFocus(string Msg, string CtlClientID, Page p, Control ctl)
        {
            List <string> aStmt = new List <string>();

            string Alert = CScript.GetScriptAlert(Msg);

            aStmt.Add(Alert);

            if (!string.IsNullOrEmpty(CtlClientID))
            {
                string Focus = GetScriptFocus(CtlClientID);
                aStmt.Add(Focus);
            }

            string Stmt = CScript.GetScript(aStmt);

            if (p != null)
            {
                p.ClientScript.RegisterStartupScript(typeof(Page), "AlertAndFocus", Stmt, true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(ctl, ctl.GetType(), "AlertAndFocus", Stmt, true);
            }
        }
예제 #3
0
        public static string GetClientDataRow(DataTable dt, string[] aColName)
        {
            List <string> aRow = new List <string>();

            for (int rw = 0, rw2 = dt.Rows.Count; rw < rw2; rw++)
            {
                DataRow dr = dt.Rows[rw];

                string[] aNameValue = new string[dt.Columns.Count];
                for (int cl = 0, cl2 = dt.Columns.Count; cl < cl2; cl++)
                {
                    object oValue = dr[cl];

                    string Text = CScript.GetValueForJson(oValue);

                    //JSON 형식을 리턴할 때 Name에 큰 따옴표를 붙여야만 에러를 내지 않음.
                    aNameValue[cl] = "\"" + aColName[cl] + "\":" + Text;
                }
                string NameValueList = string.Join(", ", aNameValue);
                aRow.Add("{ " + NameValueList + " }");
            }

            string RowList = "[ " + string.Join(",\r\n", aRow.ToArray()) + " ]";

            return(RowList);
        }
예제 #4
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static string GetClientArray <T>(IEnumerable <T> eValue, string VarName, bool AddScriptTag)
        {
            List <string> aStmt = new List <string>();

            aStmt.Add("var " + VarName + " = [];");

            int i = -1;

            foreach (T Value in eValue)
            {
                string Quot     = "";
                string ValueNew = "";

                if (CLang.In(typeof(T), typeof(string), typeof(char)))
                {
                    Quot     = "\"";
                    ValueNew = CScript.ReplaceForScriptVariable(Value.ToString());
                }
                else if (typeof(T) == typeof(DateTime))
                {
                    ValueNew = CScript.GetJavaScriptDateTime(Convert.ToDateTime(Value));
                }
                else
                {
                    Quot     = "";
                    ValueNew = Value.ToString();
                }

                aStmt.Add(VarName + "[" + (++i).ToString() + "] = " + Quot + ValueNew + Quot + ";");
            }

            return(CScript.GetScript(aStmt, AddScriptTag));
        }
예제 #5
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static string GetScriptDocumentWrite(string Value, bool AddScriptTag)
        {
            string s = "document.write(\"" + CScript.ReplaceForScriptVariable(Value) + "\");";

            s = CScript.GetScript(new string[] { s }, AddScriptTag);

            return(s);
        }
예제 #6
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static string GetScriptAlert(string Msg, bool AddScriptTag)
        {
            string s = "alert(\"" + CScript.ReplaceForScriptVariable(Msg) + "\");";

            s = CScript.GetScript(new string[] { s }, AddScriptTag);

            return(s);
        }
예제 #7
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static void Alert(string Msg, bool EndResponse, HttpContext ctx)
        {
            string Alert = CScript.GetScriptAlert(Msg);
            string s     = CScript.GetScript(new string[] { Alert }, true);

            HttpContext.Current.Response.Write(s);

            if (EndResponse)
            {
                ctx.Response.End();
            }
        }
예제 #8
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static void AlertAndClose(string Msg, bool EndResponse, HttpContext ctx)
        {
            string Alert = CScript.GetScriptAlert(Msg);
            string Close = "window.close();";
            string s     = CScript.GetScript(new string[] { Alert, Close }, true);

            ctx.Response.Write(s);

            if (EndResponse)
            {
                ctx.Response.End();
            }
        }
예제 #9
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static void SubmitOpenerAndCloseWindow(string OpenerFrmName)
        {
            List <string> aStmt = new List <string>();

            aStmt.Add("if (window.opener) {");
            aStmt.Add("	window.opener.document.forms[\"" + OpenerFrmName + "\"].submit();");
            aStmt.Add("}");
            //팝업 띄운 창에서 window.close()를 쓰면 Chrome, Safari의 경우 fail 메세지 표시되고 안 닫히므로 타이머를 사용해 닫음.
            aStmt.Add("setTimeout(function () { window.close(); }, 100);");
            string s = CScript.GetScript(aStmt, true);

            HttpContext.Current.Response.Write(s);
            HttpContext.Current.Response.End();
        }
예제 #10
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static void AlertAndBack(string Msg, bool EndResponse, HttpContext ctx)
        {
            string Alert = CScript.GetScriptAlert(Msg);
            string Back  = "history.back();\r\n";

            string s = CScript.GetScript(new string[] { Alert, Back }, true);

            ctx.Response.Write(s);

            if (EndResponse)
            {
                ctx.Response.End();
            }
        }
예제 #11
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static void RedirectOpenerAndCloseWindow(string Url)
        {
            List <string> aStmt = new List <string>();

            aStmt.Add("if (window.opener)");
            aStmt.Add("{");
            aStmt.Add("	window.opener.location.href = \"" + Url + "\";");
            aStmt.Add("}");
            //팝업 띄운 창에서 window.close()를 쓰면 Chrome, Safari의 경우 fail 메세지 표시되고 안 닫히므로 타이머를 사용해 닫음.
            aStmt.Add("setTimeout(function () { window.close(); }, 100);");
            string s = CScript.GetScript(aStmt, true);

            HttpContext.Current.Response.Write(s);
            HttpContext.Current.Response.End();
        }
예제 #12
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static void AlertAndRedirectTo(string Msg, string Url, bool EndResponse, HttpContext ctx)
        {
            List <string> aStmt = new List <string>();

            aStmt.Add(CScript.GetScriptAlert(Msg));
            aStmt.Add("window.location.href = \"" + Url + "\";");
            string s = CScript.GetScript(aStmt, true);

            ctx.Response.Write(s);

            if (EndResponse)
            {
                ctx.Response.End();
            }
        }
예제 #13
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        /// <summary>
        /// width: "100", height: "100", 와 같은 문자열을 만들기 위함.
        /// </summary>
        /// <param name="KeyValue"></param>
        /// <param name="EncloseDoubleQuote"></param>
        /// <returns></returns>
        public static string GetScriptKeyValueByColon(Dictionary <string, string> KeyValue, bool EncloseDoubleQuote)
        {
            string s = "";
            string q = EncloseDoubleQuote ? "\"" : "";

            foreach (KeyValuePair <string, string> kv in KeyValue)
            {
                string Value = EncloseDoubleQuote ? CScript.ReplaceForScriptVariable(kv.Value) : kv.Value;
                s += ", " + kv.Key + ": " + q + Value + q;
            }
            if (s != "")
            {
                s = s.Substring(1);
            }

            return(s);
        }
예제 #14
0
        private string GetValueByType(ClientControlPropertyTypes PropType, int Index)
        {
            string Value = "";

            if ((PropType == ClientControlPropertyTypes.InputRadio) || (PropType == ClientControlPropertyTypes.InputCheckBox))
            {
                Value = this.maValue[Index];
                if ((Value != "true") && (Value != "false"))
                {
                    throw new Exception("radio, checkbox인 경우, 'true', 'false' 값만 허용됩니다.");
                }
            }
            else
            {
                Value = "\"" + CScript.ReplaceForScriptVariable(this.maValue[Index]) + "\"";
            }

            return(Value);
        }
예제 #15
0
        public static string GetScriptWrite(string Version, int Width, int Height,
                                            FlashAllowScriptAccess AllowScriptAccess, FlashWmode Wmode, FlashSalign Salign, FlashScale Scale,
                                            Color BgColor, string FlashVars, string Movie, string FlashId, string DivIdForContainer)
        {
            string DivId = string.IsNullOrEmpty(DivIdForContainer) ? "div" + FlashId : DivIdForContainer;

            Dictionary <string, string> nv = new Dictionary <string, string>();

            nv.Add("menu", "false");
            nv.Add("allowScriptAccess", AllowScriptAccess.ToString());
            nv.Add("wmode", Wmode.ToString());
            nv.Add("salign", Salign.ToString());
            nv.Add("scale", Scale.ToString());
            nv.Add("bgcolor", CColorConv.GetHexaByColor(BgColor));
            nv.Add("flashvars", FlashVars);
            string Params = CScript.GetScriptKeyValueByColon(nv, true);

            string s = "";

            if (string.IsNullOrEmpty(DivIdForContainer))
            {
                s += "<div id=\"" + DivId + "\">" +
                     "<a href=\"http://www.adobe.com/go/getflashplayer\">" +
                     "<img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" />" +
                     "</a>" +
                     "</div>\r\n";
            }

            List <string> aStmt = new List <string>();

            aStmt.Add("var flashvars = false;");
            aStmt.Add("var params = { " + Params + " };");
            aStmt.Add("var attributes = { id: \"" + FlashId + "\", name: \"" + FlashId + "\" };");
            aStmt.Add("swfobject.embedSWF(\"" + Movie + "\", \"" + DivId + "\", \"" + Width.ToString() + "\", \"" + Height.ToString() + "\", \"" + Version + "\", \"\", flashvars, params, attributes);");

            string s2 = CScript.GetScript(aStmt, true);

            return(s + s2);
        }
예제 #16
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        /// <summary>
        /// TextBox의 TextMode가 MultiLine이면 MaxLength가 먹히지 않아 사용함.
        /// </summary>
        /// <param name="txt"></param>
        public static void LimitToMaxLength(Page p, TextBox txt)
        {
            List <string> aStmt       = new List <string>();
            string        TxtCliendID = txt.ClientID;
            int           MaxLength   = txt.MaxLength;

            aStmt.Add("var " + TxtCliendID + " = document.getElementById(\"" + TxtCliendID + "\");");
            aStmt.Add("if (" + TxtCliendID + ") {");
            aStmt.Add("	" + TxtCliendID + ".onkeyup = function (e) {");
            aStmt.Add("		var e = window.event || e;");
            aStmt.Add("		var src = e.srcElement || e.target;");
            aStmt.Add("		var maxlength = "+ MaxLength.ToString() + ";");
            aStmt.Add("		if (src.value.length > maxlength) {");
            aStmt.Add("			alert(\"허용길이인 \" + maxlength + \"자를 초과했습니다.\");");
            aStmt.Add("			src.value = src.value.substring(0, maxlength);");
            aStmt.Add("		}");
            aStmt.Add("	}");
            aStmt.Add("}");

            string Stmt = CScript.GetScript(aStmt);

            p.ClientScript.RegisterStartupScript(typeof(Page), "LimitToLength" + TxtCliendID, Stmt, true);
        }
예제 #17
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        /// <summary>
        /// ASP.Net에서 Cookie를 설정할 때 Domain 속성을 설정하면 실제로는 작동되지 않아 JScript로 Cookie를 설정함.
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="Value"></param>
        /// <param name="ExpireDays"></param>
        /// <param name="Domain"></param>
        /// <returns></returns>
        public static string SetCookie(string Key, string Value, int ExpireDays, string Domain)
        {
            List <string> aStmt = new List <string>();

            aStmt.Add("var Now = new Date();");
            aStmt.Add("Now.setDate(Now.getDate() + " + ExpireDays.ToString() + ");");

            aStmt.Add("var Cookie = \"" + Key + "=" + Value + ";\";");
            aStmt.Add("Cookie += \"path=/;\";");

            if (ExpireDays > 0)
            {
                aStmt.Add("Cookie += \"expires=\" + Now.toGMTString() + \";\";");
            }

            if (Domain != "")
            {
                aStmt.Add("Cookie += \"domain=" + Domain + ";\";");
            }

            aStmt.Add("document.cookie = Cookie;");

            return(CScript.GetScript(aStmt, false));
        }
예제 #18
0
        public static string GetScript(string Source, string Id,
                                       SInfoSilverlightProperties Properties, SInfoSilverlightEvents Events,
                                       Dictionary <string, string> InitParams)
        {
/*
 * <div id="silverlightControlHost">
 *      <script type="text/javascript">
 *      var source = "/ClientBin/RoundedBox.xap";
 *      var parentElement = silverlightControlHost;
 *      var id = "slPlugin";
 *      var properties = {
 *              width: "100", height: "100",
 *              background: "white", alt: alt,
 *              minRuntimeVersion: "2.0.30800.0"
 *      };
 *      var events = { onError: onSLError, onLoad: onSLLoad };
 *      var initParams = "param1=value1,param2=value2";
 *
 *      Silverlight.createObject(source, parentElement, id, properties, events, initParams, "");
 * </script>
 * </div>
 */
            string DivId = "div" + Id;

            List <string> aStmt = new List <string>();

            aStmt.Add("var source = \"" + Source + "\";");
            aStmt.Add("var parentElement = " + DivId + ";");
            aStmt.Add("var id = \"" + Id + "\";");

            aStmt.Add("var properties = {");
            Dictionary <string, string> dicProperties = new Dictionary <string, string>();

            if (Properties.width != 0)
            {
                dicProperties.Add("width", Properties.width.ToString());
            }
            if (Properties.height != 0)
            {
                dicProperties.Add("height", Properties.height.ToString());
            }
            if (!string.IsNullOrEmpty(Properties.background))
            {
                dicProperties.Add("background", Properties.background);
            }
            if (!string.IsNullOrEmpty(Properties.alt))
            {
                dicProperties.Add("alt", Properties.alt);
            }
            if (!string.IsNullOrEmpty(Properties.minRuntimeVersion))
            {
                dicProperties.Add("minRuntimeVersion", Properties.minRuntimeVersion);
            }
            aStmt.Add(CScript.GetScriptKeyValueByColon(dicProperties, true));
            aStmt.Add("};");

            aStmt.Add("var events = {");
            Dictionary <string, string> dicEvents = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(Events.onError))
            {
                dicEvents.Add("onError", Events.onError);
            }
            if (!string.IsNullOrEmpty(Events.onFullScreenChanged))
            {
                dicEvents.Add("onFullScreenChanged", Events.onFullScreenChanged);
            }
            if (!string.IsNullOrEmpty(Events.onLoaded))
            {
                dicEvents.Add("onLoaded", Events.onLoaded);
            }
            if (!string.IsNullOrEmpty(Events.onResized))
            {
                dicEvents.Add("onResized", Events.onResized);
            }
            if (!string.IsNullOrEmpty(Events.onSourceDownloadComplete))
            {
                dicEvents.Add("onSourceDownloadComplete", Events.onSourceDownloadComplete);
            }
            if (!string.IsNullOrEmpty(Events.onSourceDownloadProgressChanged))
            {
                dicEvents.Add("onSourceDownloadProgressChanged", Events.onSourceDownloadProgressChanged);
            }
            aStmt.Add(CScript.GetScriptKeyValueByColon(dicEvents, true));
            aStmt.Add("};");

            aStmt.Add("var initParams = \"" + GetInitParams(InitParams) + "\";");

            aStmt.Add("Silverlight.createObject(source, parentElement, id, properties, events, initParams, \"\");");
            string Script = CScript.GetScript(aStmt, true);
            string s      = "<div id=\"" + DivId + "\">" + Script + "</div>\r\n";

            return(s);
        }
예제 #19
0
        /// <summary>
        /// 서버의 DataTable을 클라이언트의 자바스크립트에서 쓸 수 있도록 변경함.
        /// </summary>
        /// <remarks>오라클의 경우는 필드 이름이 전부 대문자로 리턴되므로 소문자로 변경하려면 ColumnNameToLower 인수를 true로 할 것.</remarks>
        /// <returns></returns>
        public string ToClientScript()
        {
            List <string> aStmt = new List <string>();

            if (_aDt.Count > 0)
            {
                if (!_Option.DontDeclareVariable)
                {
                    if (_aDt.Count == 1)
                    {
                        aStmt.Add("var " + _Option.VariableName + " = new CDataTable();");
                    }
                    else
                    {
                        aStmt.Add("var " + _Option.VariableName + " = [];");
                    }
                }

                for (int nTbl = 0; nTbl < _aDt.Count; nTbl++)
                {
                    DataTable dt = _aDt[nTbl];

                    string VarNameCur = (_aDt.Count != 1) ? _Option.VariableName + "[" + nTbl + "]" : _Option.VariableName;
                    aStmt = GetClientDataTableCommon(aStmt, dt, VarNameCur, _Option.ColumnNameToLower);
                }
            }

            if (_aDs.Count > 0)
            {
                /*
                 * var ads = [];
                 *
                 * ads[0] = { Tables: [] };
                 * ads[0].Tables[0] = new CDataTable();
                 * ads[0].Tables[1] = new CDataTable();
                 *
                 * ads[1] = { Tables: [] };
                 * ads[1].Tables[0] = new CDataTable();
                 * ads[1].Tables[1] = new CDataTable();
                 *
                 *
                 * var ds = { Tables: [] };
                 * ds.Tables[0] = new CDataTable();
                 * ds.Tables[1] = new CDataTable();
                 *
                 */
                if (!_Option.DontDeclareVariable)
                {
                    if (_aDs.Count == 1)
                    {
                        aStmt.Add("var " + _Option.VariableName + " = { Tables: [] };");
                    }
                    else
                    {
                        aStmt.Add("var " + _Option.VariableName + " = [];");
                    }
                }

                for (int nDs = 0; nDs < _aDs.Count; nDs++)
                {
                    DataSet ds = _aDs[nDs];

                    if (_aDs.Count != 1)
                    {
                        aStmt.Add(_Option.VariableName + "[" + nDs + "] = { Tables: [] };");
                    }

                    string VarNameCur =
                        (_aDs.Count != 1)
                                                ? _Option.VariableName + "[" + nDs + "].Tables"
                                                : _Option.VariableName + ".Tables";

                    for (int nTbl = 0; nTbl < ds.Tables.Count; nTbl++)
                    {
                        DataTable dt = ds.Tables[nTbl];

                        string VarNameCur2 = VarNameCur + "[" + nTbl + "]";
                        aStmt = GetClientDataTableCommon(aStmt, dt, VarNameCur2, _Option.ColumnNameToLower);
                    }
                }
            }


            string s = CScript.GetScript(aStmt, _Option.AddScriptTag);

            return(s);
        }
예제 #20
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
 public static string GetScript(IEnumerable <string> aStmt)
 {
     return(CScript.GetScript(aStmt, false));
 }
예제 #21
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        /// <summary>
        /// You must use a ScriptManager control on a page to enable the following features of ASP.NET AJAX:
        ///•Client-script functionality of the Microsoft AJAX Library, and any custom script that you want to send to the browser. For more information, see ASP.NET AJAX and JavaScript.
        ///•Partial-page rendering, which enables regions on the page to be independently refreshed without a postback. The ASP.NET AJAX UpdatePanel, UpdateProgress, and Timer controls require a ScriptManager control to support partial-page rendering.
        ///•JavaScript proxy classes for Web services, which enable you to use client script to access Web services by exposing Web services as strongly typed objects.
        ///•JavaScript classes to access ASP.NET authentication and profile application services.
        /// http://forums.asp.net/t/1169763.aspx/1
        /// </summary>
        public static void Alert(string Msg, Control ctl)
        {
            string Alert = CScript.GetScriptAlertJQuery(Msg);

            ScriptManager.RegisterStartupScript(ctl, ctl.GetType(), "AlertOnStartup", Alert, true);
        }
예제 #22
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static string GetArraySetting(string ArrayName, int ArrayIndex, string Value, bool AddQuote)
        {
            string Quot = (AddQuote ? "\"" : "");

            return(string.Concat(ArrayName, "[", ArrayIndex, "] = ", Quot, CScript.ReplaceForScriptVariable(Value.ToString()), Quot, ";"));
        }
예제 #23
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
 public static string GetScript(string Stmt, bool AddScriptTag)
 {
     return(CScript.GetScript(new string[] { Stmt }, AddScriptTag));
 }
예제 #24
0
파일: CScript.cs 프로젝트: doctorgu/MadeIn9
        public static void Alert(string Msg, Page p)
        {
            string Alert = CScript.GetScriptAlertJQuery(Msg);

            p.ClientScript.RegisterStartupScript(typeof(Page), "AlertOnStartup", Alert, true);
        }