---------------------------------------------------------------------------- string dateString, format; DateTimeOffset result; IFormatProvider provider = CultureInfo.InvariantCulture; // Parse date-only value with invariant culture and assume time is UTC. dateString = "06/15/2008"; format = "d"; if (DateTimeOffset.TryParseExact(dateString, format, provider, DateTimeStyles.AssumeUniversal, out result)) Console.WriteLine("'{0}' converts to {1}.", dateString, result.ToString()); else Console.WriteLine("'{0}' is not in the correct format.", dateString); // Parse date-only value with leading white space. // Should return False because only trailing whitespace is // specified in method call. dateString = " 06/15/2008"; if (DateTimeOffset.TryParseExact(dateString, format, provider, DateTimeStyles.AllowTrailingWhite, out result)) Console.WriteLine("'{0}' converts to {1}.", dateString, result.ToString()); else Console.WriteLine("'{0}' is not in the correct format.", dateString); // Parse date and time value, and allow all white space. dateString = " 06/15/ 2008 15:15 -05:00"; format = "MM/dd/yyyy H:mm zzz"; if (DateTimeOffset.TryParseExact(dateString, format, provider, DateTimeStyles.AllowWhiteSpaces, out result)) Console.WriteLine("'{0}' converts to {1}.", dateString, result.ToString()); else Console.WriteLine("'{0}' is not in the correct format.", dateString); // Parse date and time and convert to UTC. dateString = " 06/15/2008 15:15:30 -05:00"; format = "MM/dd/yyyy H:mm:ss zzz"; if (DateTimeOffset.TryParseExact(dateString, format, provider, DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.AdjustToUniversal, out result)) Console.WriteLine("'{0}' converts to {1}.", dateString, result.ToString()); else Console.WriteLine("'{0}' is not in the correct format.", dateString); // The example displays the following output: // '06/15/2008' converts to 6/15/2008 12:00:00 AM +00:00. // ' 06/15/2008' is not in the correct format. // ' 06/15/ 2008 15:15 -05:00' converts to 6/15/2008 3:15:00 PM -05:00. // ' 06/15/2008 15:15:30 -05:00' converts to 6/15/2008 8:15:30 PM +00:00. -------------------------------------------------------------------------------- using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; // add using System.Text; using System.Globalization; using ZLib.Core; using ZLib.Web; public partial class Main_Main : System.Web.UI.Page { private const string mcsProgramID = "Main"; private const string mcsProgramName = "京奇電腦"; private DateTime mdPageTime_Last; private DateTime mdPageTime_This; protected void Page_Load(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); bool bLogin; string s1; string sKey, sValue; string sFile; mdPageTime_This = DateTime.Now; lblPageTime.Text = mdPageTime_This.ToString("yyyy.MM.dd HH:mm:ss"); this.Title = mcsProgramID + "-" + mcsProgramName; if (IsPostBack) { IFormatProvider provider = CultureInfo.InvariantCulture; if (!DateTime.TryParseExact(lblPageTime.Text, "yyyy.MM.dd HH:mm:ss", provider, DateTimeStyles.None, out mdPageTime_Last)) throw new Exception("Last Page DateTime error"); } else { // Init // todo: change GetMapPath to Get_MapPath // sFile = ZWeb.GetMapPath("~/ sKey = "Common"; //if (ZFile.ReadAllText( //sValue = ZFile.re //if (Page.RegisterClientScriptBlock( //hello sb.Length = 0; //sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(mcsProgramName); sb.AppendLine(""); sb.AppendLine("開放時間: 08:30 ~ 24:00"); this.SPANLeftInfo.InnerHtml = sb.ToString(); bLogin = false; sb.Length = 0; // 都新開視窗, 保留主視窗不變當作menu, 並且需切換focus到指定視窗 sb.AppendLine(ZHTML.Get_A_OnClick_WindowOpenURL("我的資料", "../SCS/SCS1070.aspx", "SCS1070", "style='color:black;'")); if (bLogin) { sb.Append(" | "); sb.Append("我的設定"); sb.Append(" | "); sb.Append("登出"); } else { //sb.Append("| "); //sb.Append("匿名網友"); //sb.Append(" | 登入"); sb.Append(" | "); sb.AppendLine(ZHTML.Get_A_OnClick_WindowOpenURL("登入", "../SCS/SCS1010.aspx", "SCS1010", "style='color:black;'")); //sb.AppendLine(ZHTML.Get_A("登入", "../SCS/SCS1010.aspx", "SCS1010", "style='color:black;'")); } //sb.Append(" | "); //sb.Append(ZHTML.Get_A_WindowOpen("../SCS/SCS1010.aspx", "SCS1010", "", "test", "color:black;")); //sb.Length = 0; //sb.AppendLine(""); //sb.AppendLine(""); //this.DIVLeftInfo.InnerHtml = SByte. this.DIVRightInfo.InnerHtml = sb.ToString(); //sb.Append(ZHTML.BuildDIVPane("Head", "Body")); sb.Length = 0; sb.Append("版本:"); s1 = gCommon.Project.ReleaseVersion; sb.AppendLine(ZHTML.Get_A_OnClick_WindowOpenURL(s1, "About.aspx", "About")); this.DIVSystemInfo.InnerHtml = sb.ToString(); // 內容 sb.Length = 0; sb.AppendLine(); sb.AppendLine("歡迎光臨。"); sb.AppendLine(); sb.AppendLine("您尚未登入本系統,IP來自: " + ZWeb.REMOTE_ADDR); sb.AppendLine(); sb.AppendLine("本站僅提供專案客戶使用。"); sb.AppendLine(); sb.Replace(ZDefine.NewLine, "
"); this.DIVHelloMsg.InnerHtml = sb.ToString(); gProject.SetPageStyle(this, this.body); MenuItem menu1; menuMain.Items.Clear(); //s1 = "javascript:" + ZJavaScript.GetStatement_WindowOpenURL_NoReturn("../Main/MAIN1020.aspx", "MAIN1020"); s1 = "javascript:" + ZJavaScript.GetStatement_WindowOpenURL_NoReturn("../Main/ContactInfo.aspx", "ContactInfo"); menu1 = new MenuItem("聯絡資料", "", "", s1); menuMain.Items.Add(menu1); s1 = "javascript:" + ZJavaScript.GetStatement_WindowOpenURL_NoReturn("MainEmployee.aspx", "MainEmployee"); menu1 = new MenuItem("內部網站", "", "", s1); menuMain.Items.Add(menu1); // call java on postback test //MenuItem menu2; //menuMain.Items.Clear(); //menu2 = new MenuItem("Call java on postback", "MAIN1020"); //menuMain.Items.Add(menu2); } } //protected void menuMain_MenuItemClick(object sender, MenuEventArgs e) //{ // string sValue; // string sJAVA; // string sFile; // sValue = e.Item.Value; // //sValue = e.CommandArgument.ToString().ToLower(); // if (sValue == "MAIN1020") // { // //sFile = ZWeb.Path_RequestFilePath; // //sFile = ZWeb.Path_RequestPath; // //sFile = ZWeb.Path_RequestPathInfo; // //sFile = ZWeb.Path_RequestRawUrl; // //ZJavaScript.WindowOpenURL_OnPostBack("../Main/MAIN1020.aspx", sValue, "gWIN_MAIN1020"); // } //} }