示例#1
0
        public static string GetValueForLang(string en_us_value, string zh_cn_value, string zh_tw_value)
        {
            string ret = string.Empty;

            switch (MutiLanguage.GetCultureType())
            {
            case MutiLanguage.Languages.en_us:
                ret = en_us_value;
                break;

            case MutiLanguage.Languages.zh_cn:
                ret = zh_cn_value;
                break;

            case MutiLanguage.Languages.zh_tw:
                ret = zh_tw_value;
                break;

            default:
                break;
            }
            if (string.IsNullOrEmpty(ret))
            {
                ret = en_us_value;
            }
            return(ret);
        }
示例#2
0
        public static string FormatDateTimeToString(DateTime xDateTime, DateFormat xDateFormat, bool isMutiLang)
        {
            if (xDateTime == null || Convert.ToDateTime(xDateTime) == DateTime.MinValue)
            {
                return("");
            }
            MutiLanguage.Languages lang = MutiLanguage.GetCultureType();
            lang = isMutiLang ? lang : MutiLanguage.Languages.en_us;
            string langstr = isMutiLang ? MutiLanguage.EnumToString(lang) : MutiLanguage.EnumToString(MutiLanguage.Languages.en_us);

            //System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Date));
            //System.Resources.ResourceSet rs = rm.GetResourceSet(new System.Globalization.CultureInfo(langstr), true, true);
            //return xDateTime.ToString(rs.GetString(xDateFormat.ToString()), System.Globalization.DateTimeFormatInfo.InvariantInfo);
            return(xDateTime.ToString(Date.ResourceManager.GetString(xDateFormat.ToString(), new System.Globalization.CultureInfo(langstr)), System.Globalization.DateTimeFormatInfo.InvariantInfo));
        }
示例#3
0
        public static DateTime ConvertDate(string xDateString, DateFormat xDateFormat, bool isMutiLang)
        {
            if (string.IsNullOrEmpty(xDateString))
            {
                return(DateTime.MinValue);
            }
            switch (xDateFormat)
            {
            case DateFormat.ddMMyyyys:
                string[] dateInfo = xDateString.Split('/');
                string   dd       = string.Empty;
                string   MM       = string.Empty;
                string   yyyy     = string.Empty;
                if (dateInfo.Length == 3)
                {
                    dd = dateInfo[0].Trim();
                    if (dd.Length != 2)
                    {
                        if (dd.Length > 2)
                        {
                            dd = dd.Substring(0, 2);
                        }
                        else if (dd.Length == 1 && dd != "0")
                        {
                            dd = "0" + dd;
                        }
                        else
                        {
                            dd = "01";
                        }
                    }
                    else if (dd == "00")
                    {
                        dd = "01";
                    }
                    MM = dateInfo[1].Trim();
                    if (MM.Length != 2)
                    {
                        if (MM.Length > 2)
                        {
                            MM = MM.Substring(0, 2);
                        }
                        else if (MM.Length == 1)
                        {
                            MM = "0" + MM;
                        }
                        else
                        {
                            MM = "01";
                        }
                    }
                    else if (MM == "00")
                    {
                        MM = "01";
                    }
                    yyyy = dateInfo[2].Trim();
                    if (yyyy.Length == 2)
                    {
                        yyyy += "20";
                    }
                    else if (yyyy.Length != 4)
                    {
                        if (yyyy.Length > 4)
                        {
                            yyyy = yyyy.Substring(0, 4);
                        }
                        else
                        {
                            yyyy = DateTime.Now.ToString("yyyy");
                        }
                    }
                    else if (yyyy == "0000")
                    {
                        yyyy = DateTime.Now.ToString("yyyy");
                    }
                }
                else
                {
                    return(DateTime.MinValue);
                }
                xDateString = string.Format("{0}/{1}/{2}", dd, MM, yyyy);
                break;

            case DateFormat.ddMMyyyyn:
                break;

            case DateFormat.ddMMyyyysp:
                break;

            case DateFormat.ddMMyyyyd:
                break;

            case DateFormat.ddMMMyyyys:
                break;

            case DateFormat.ddMMMyyyyn:
                break;

            case DateFormat.ddMMMyyyysp:
                break;

            case DateFormat.ddMMMyyyyd:
                break;

            case DateFormat.MMMddyyyyspcm:
                break;

            case DateFormat.ddMMMyyyyspwt:
                break;

            case DateFormat.ddMMMyyyyHHmm:
                break;

            case DateFormat.yyyyMMMdd:
                break;

            case DateFormat.yyyyMMdd:
                break;

            case DateFormat.yyMMddHHmm:
                break;

            case DateFormat.MMMdd:
                break;

            case DateFormat.ddMMMyyyyddd:
                break;

            case DateFormat.ddMMMyyyyml:
                break;

            default:
                break;
            }
            MutiLanguage.Languages lang = MutiLanguage.GetCultureType();
            lang = isMutiLang ? lang : MutiLanguage.Languages.en_us;
            string langstr = isMutiLang ? MutiLanguage.EnumToString(lang) : MutiLanguage.EnumToString(MutiLanguage.Languages.en_us);

            System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Date));
            System.Resources.ResourceSet     rs = rm.GetResourceSet(new System.Globalization.CultureInfo(langstr), true, true);
            return(DateTime.ParseExact(xDateString, rs.GetString(xDateFormat.ToString()), System.Globalization.DateTimeFormatInfo.InvariantInfo));
        }