Esempio n. 1
0
        /// <summary>
        /// save location
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="pref"></param>
        /// <returns></returns>
        public MLocation LocationSave(Ctx ctx, Dictionary <string, object> pref)
        {
            var       c_Location_Id = Convert.ToInt32(pref["clocationId"]);
            MLocation _location     = new MLocation(ctx, c_Location_Id, null);

            _location.SetAddress1(Convert.ToString(pref["addvalue1"]));
            _location.SetAddress2(Convert.ToString(pref["addvalue2"]));
            _location.SetAddress3(Convert.ToString(pref["addvalue3"]));
            _location.SetAddress4(Convert.ToString(pref["addvalue4"]));
            _location.SetCity(Convert.ToString(pref["cityValue"]));
            _location.SetPostal(Convert.ToString(pref["zipValue"]));
            //  Country/Region
            _location.SetC_Country_ID(Convert.ToInt32(pref["countryId"]));

            if (_location.GetCountry().IsHasRegion())
            {
                _location.SetC_Region_ID(Convert.ToInt32(pref["stateId"]));
            }
            else
            {
                _location.SetC_Region_ID(0);
            }
            _location.SetRegionName(Convert.ToString(pref["stateValue"]));
            _location.SetC_City_ID(Convert.ToInt32(pref["cityId"]));

            _location.Save();
            return(_location);
        }
Esempio n. 2
0
        /// <summary>
        /// save location
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="pref"></param>
        /// <returns></returns>
        public MLocation LocationSave(Ctx ctx, Dictionary <string, object> pref)
        {
            MLocation _location = null;

            var c_Location_Id = Convert.ToInt32(pref["clocationId"]);

            string sql   = "SELECT COUNT(*) FROM C_Location WHERE C_Location_ID=" + c_Location_Id;
            object count = DB.ExecuteScalar(sql);

            if (count == null || count == DBNull.Value || Util.GetValueOfInt(count) == 0)
            {
                c_Location_Id = 0;
            }

            _location = new MLocation(ctx, c_Location_Id, null);
            _location.SetAddress1(Convert.ToString(pref["addvalue1"]));
            _location.SetAddress2(Convert.ToString(pref["addvalue2"]));
            _location.SetAddress3(Convert.ToString(pref["addvalue3"]));
            _location.SetAddress4(Convert.ToString(pref["addvalue4"]));
            _location.SetCity(Convert.ToString(pref["cityValue"]));
            _location.SetPostal(Convert.ToString(pref["zipValue"]));
            //  Country/Region
            _location.SetC_Country_ID(Convert.ToInt32(pref["countryId"]));

            if (_location.GetCountry().IsHasRegion())
            {
                _location.SetC_Region_ID(Convert.ToInt32(pref["stateId"]));
            }
            else
            {
                _location.SetC_Region_ID(0);
            }
            _location.SetRegionName(Convert.ToString(pref["stateValue"]));
            _location.SetC_City_ID(Convert.ToInt32(pref["cityId"]));

            _location.Save();
            return(_location);
        }
Esempio n. 3
0
        public LocationElement(Ctx ctx, int C_Location_ID, Font font, Color color) : base(10, 1)                //	max
        {
            SetGap(0, 0);
            MLocation ml = MLocation.Get(ctx, C_Location_ID, null);

            //	log.fine("C_Location_ID=" + C_Location_ID);
            if (ml != null)
            {
                int index = 0;
                if (ml.IsAddressLinesReverse())
                {
                    SetData(index++, 0, ml.GetCountry(true), font, color);
                    //String[] lines = java.util.regex.Pattern.compile("$", java.util.regex.Pattern.MULTILINE).split(ml.GetCityRegionPostal());
                    String[] lines = System.Text.RegularExpressions.Regex.Split(ml.GetCityRegionPostal(), "$", System.Text.RegularExpressions.RegexOptions.Multiline);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        if (string.IsNullOrEmpty(lines[i]))
                        {
                            continue;
                        }
                        SetData(index++, 0, lines[i], font, color);
                    }
                    if (ml.GetAddress4() != null && ml.GetAddress4().Length > 0)
                    {
                        SetData(index++, 0, ml.GetAddress4(), font, color);
                    }
                    if (ml.GetAddress3() != null && ml.GetAddress3().Length > 0)
                    {
                        SetData(index++, 0, ml.GetAddress3(), font, color);
                    }
                    if (ml.GetAddress2() != null && ml.GetAddress2().Length > 0)
                    {
                        SetData(index++, 0, ml.GetAddress2(), font, color);
                    }
                    if (ml.GetAddress1() != null && ml.GetAddress1().Length > 0)
                    {
                        SetData(index++, 0, ml.GetAddress1(), font, color);
                    }
                }
                else
                {
                    if (ml.GetAddress1() != null && ml.GetAddress1().Length > 0)
                    {
                        SetData(index++, 0, ml.GetAddress1(), font, color);
                    }
                    if (ml.GetAddress2() != null && ml.GetAddress2().Length > 0)
                    {
                        SetData(index++, 0, ml.GetAddress2(), font, color);
                    }
                    if (ml.GetAddress3() != null && ml.GetAddress3().Length > 0)
                    {
                        SetData(index++, 0, ml.GetAddress3(), font, color);
                    }
                    if (ml.GetAddress4() != null && ml.GetAddress4().Length > 0)
                    {
                        SetData(index++, 0, ml.GetAddress4(), font, color);
                    }
                    //String[] lines = java.util.regex.Pattern.compile("$", java.util.regex.Pattern.MULTILINE).split(ml.GetCityRegionPostal());
                    String[] lines = System.Text.RegularExpressions.Regex.Split(ml.GetCityRegionPostal(), "$", System.Text.RegularExpressions.RegexOptions.Multiline);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        if (string.IsNullOrEmpty(lines[i]))
                        {
                            continue;
                        }
                        SetData(index++, 0, lines[i], font, color);
                    }
                    SetData(index++, 0, ml.GetCountry(true), font, color);
                }
            }
        }       //	LocationElement