void addItemElement(int pItemID, int pBuyingPrice, int pSellingPrice)
 {
     priceInfo[pItemID] = new PriceInfo()
     {
         buyingPrice = pBuyingPrice,
         sellingPrice = pSellingPrice,
     };
 }
Beispiel #2
0
        public override PriceInfo ExtractPriceInfo(string content)
        {
            bool instock = false;
            float price = 0f;

            if (!Regex.IsMatch(content, "<div id=\"ctl00_ctl00_cphGeneral_cphMain_lblUnavailable\" class=\"cost5\">Товара сейчас нет в наличии</div>"))
            {
                // product exists, get price
                Match m = Regex.Match(content, "<div id=\"ctl00_ctl00_cphGeneral_cphMain_lblCost\" class=\"cost\">(.+?)<span class='rub'>");
                if (!m.Success) throw new Exception("Bad content");
                string sprice = m.Groups[1].Value.Replace(" ", String.Empty);
                price = float.Parse(sprice);
                instock = true;
            }

            PriceInfo pi = new PriceInfo()
            {
                Price = price,
                InStock = instock
            };
            return pi;
        }
Beispiel #3
0
        /// <summary>
        /// Возвращает информацию по туру для корзины по ключу цены
        /// </summary>
        /// <param name="mainDc">Контекст основной БД</param>
        /// <param name="searchDc">Контекст поисковой БД</param>
        /// <param name="priceKey">Ключ цены (таблица tp_prices)</param>
        /// <returns></returns>
        public static PriceInfo GetPriceInfoByTPKey(this MtMainDbDataContext mainDc, MtSearchDbDataContext searchDc, int priceKey)
        {
            var priceStartDate = mainDc.GetTPPriceByKey(priceKey).TP_DateBegin;

            var commandBuilder = new StringBuilder();

            commandBuilder.AppendLine("select to_key, ts_key, ts_svkey, ts_code, ts_subcode1, ts_subcode2, ts_oppartnerkey, ts_oppacketkey, ts_day, ts_days, ts_men, ts_attribute ");
            commandBuilder.AppendLine("from tp_tours ");
            commandBuilder.AppendLine("join tp_services on ts_tokey = to_Key ");
            commandBuilder.AppendLine("join tp_servicelists on tl_tskey = ts_key ");
            commandBuilder.AppendLine("join tp_lists on ti_key = tl_tikey ");
            commandBuilder.AppendLine(String.Format("where tl_tikey in (select tp_tikey from tp_prices where tp_key = {0})", priceKey));
            commandBuilder.AppendLine("order by ts_day, ts_key");

            var priceInfo = new PriceInfo();

            using (var command = mainDc.Connection.CreateCommand())
            {
                command.CommandText    = commandBuilder.ToString();
                command.CommandTimeout = 100;

                mainDc.Connection.Open();
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (priceInfo.Tour == null)
                        {
                            priceInfo.Tour = (from tour in searchDc.GetAllTPTours()
                                              where tour.TO_Key == reader.GetInt32("to_key")
                                              select tour).Single();
                        }

                        var sf = new ServiceInfo
                        {
                            Key          = reader.GetInt32("ts_key"),
                            ServiceClass = (ServiceClass)reader.GetInt32("ts_svkey"),
                            Code         = reader.GetInt32("ts_code"),
                            SubCode1     = reader.GetInt32OrNull("ts_subcode1"),
                            SubCode2     = reader.GetInt32OrNull("ts_subcode2"),
                            PartnerKey   = reader.GetInt32("ts_oppartnerkey"),
                            PacketKey    = reader.GetInt32("ts_oppacketkey"),
                            StartDate    = priceStartDate.AddDays(reader.GetInt16("ts_day") - 1),
                            Days         = reader.GetInt16("ts_days"),
                            NMen         = reader.GetInt16("ts_men"),
                            Attribute    = reader.GetInt32("ts_attribute"),
                            Day          = reader.GetInt16("ts_day")
                        };

                        if (sf.ServiceClass != ServiceClass.Flight)
                        {
                            priceInfo.Services.Add(sf);
                        }
                        else
                        {
                            int?ctKeyFrom, ctKeyTo;
                            searchDc.GetCharterCityDirection(sf.Code, out ctKeyFrom, out ctKeyTo);

                            if (!ctKeyFrom.HasValue || !ctKeyTo.HasValue)
                            {
                                throw new KeyNotFoundException(String.Format("Перелет с ключом {0} не найден", sf.Code));
                            }

                            var    findFlight   = (sf.Attribute & (int)ServiceAttribute.CodeEdit) != (int)ServiceAttribute.CodeEdit;
                            var    flightGroups = Globals.Settings.CharterClassesDictionary;
                            string hashOut;
                            var    altCharters =
                                findFlight
                                ? searchDc.GetAltCharters(mainDc, ctKeyFrom.Value, ctKeyTo.Value, sf.StartDate, sf.PacketKey, flightGroups, out hashOut)
                                : searchDc.GetAltCharters(mainDc, sf.Code, sf.StartDate, sf.PacketKey, flightGroups, out hashOut);

                            foreach (var key in flightGroups.Keys)
                            {
                                var key1 = key;
                                priceInfo.Flights.AddRange(altCharters[key].Select(info => new FlightInfo()
                                {
                                    Key             = sf.Key,
                                    Attribute       = sf.Attribute,
                                    Code            = info.CharterKey,
                                    SubCode1        = info.ClassKey,
                                    PartnerKey      = info.PartnerKey,
                                    FlightTimeStart = info.FlightDateTimeFrom,
                                    FlightTimeEnd   = info.FlightDateTimeTo,
                                    Days            = sf.Days,
                                    Day             = sf.Day,
                                    ServiceClass    = sf.ServiceClass,
                                    SubCode2        = sf.SubCode2,
                                    PacketKey       = sf.PacketKey,
                                    StartDate       = sf.StartDate,
                                    NMen            = sf.NMen,
                                    FlightGroupKey  = key1
                                }));
                            }
                        }
                    }
                }
                mainDc.Connection.Close();
            }

            var priceEndDate = priceStartDate;
            var tempDate     = DateTime.MinValue;

            foreach (var sf in priceInfo.Services)
            {
                string hashOut;
                // делаем расчет стоимости услуги
                //todo: переделать получение цены по разным валютам
                sf.Cost = mainDc.GetServiceCost((int)sf.ServiceClass, sf.Code,
                                                sf.SubCode1.HasValue ? sf.SubCode1.Value : 0, sf.SubCode2.HasValue ? sf.SubCode2.Value : 0,
                                                sf.PartnerKey, sf.PacketKey, sf.StartDate, sf.Days, "E", sf.NMen, out hashOut);

                // получаем конечную дату тура
                if (sf.ServiceClass == ServiceClass.Hotel || sf.ServiceClass == ServiceClass.AddHotelService)
                {
                    tempDate = priceStartDate.AddDays(sf.Day + Math.Max((int)sf.Days, 1) - 1);
                }
                else
                {
                    tempDate = priceStartDate.AddDays(sf.Day + Math.Max((int)sf.Days, 1) - 2);
                }

                if (priceEndDate < tempDate)
                {
                    priceEndDate = tempDate;
                }
            }

            foreach (var fi in priceInfo.Flights)
            {
                string hashOut;
                // делаем расчет стоимости услуги
                //todo: переделать получение цены по разным валютам
                fi.Cost = mainDc.GetServiceCost((int)fi.ServiceClass, fi.Code,
                                                fi.SubCode1.HasValue ? fi.SubCode1.Value : 0, fi.SubCode2.HasValue ? fi.SubCode2.Value : 0,
                                                fi.PartnerKey, fi.PacketKey, fi.StartDate, priceInfo.Flights.Max(f => f.Day), "E", fi.NMen, out hashOut);

                // получаем направление перелета
                // первый перелет - прямой перелет
                // последний перелет - обратный
                // все остальные - промежуточные
                if (fi.Key == priceInfo.Flights.Min(f => f.Key))
                {
                    fi.Direction = FlightDirection.DirectFlight;
                }
                else if (fi.Key == priceInfo.Flights.Max(f => f.Key))
                {
                    fi.Direction = FlightDirection.BackFlight;
                }
                else
                {
                    fi.Direction = FlightDirection.Intermediate;
                }

                // получаем конечную дату тура
                tempDate = priceStartDate.AddDays(fi.Day - 1);
                if (priceEndDate < tempDate)
                {
                    priceEndDate = tempDate;
                }
            }
            priceInfo.TourDateBegin = priceStartDate;
            priceInfo.TourDateEnd   = tempDate;

            var tst = priceInfo.GetTourHotelsAndPansions;

            return(priceInfo);
        }
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            int currFeeYear = 0, currFeeMonth = 0;

            if (dtData.Rows.Count == 0)
            {
                new MsgBoxForm("提示", "没有要打印的单据!").ShowDialog();
                return;
            }
            else
            {
                currFeeYear  = Helper.Obj2Int(dtData.Rows[0]["年份"]);
                currFeeMonth = Helper.Obj2Int(dtData.Rows[0]["月份"]);
            }
            string v_业主编号 = "";

            if (this.业主姓名ComboBox.SelectedValue != null && this.业主姓名ComboBox.SelectedValue.ToString() != "System.Data.DataRowView")
            {
                v_业主编号 = this.业主姓名ComboBox.SelectedValue.ToString();
            }
            string    v_应收金额 = this.应收金额TextBox.Text;
            string    v_实收金额 = this.实收金额TextBox.Text;
            OwnerInfo ownerInfo = ownerInfoDic.ContainsKey(v_业主编号) ? ownerInfoDic[v_业主编号] : null;
            float     f_应收金额 = 0, f_实收金额 = 0, f_预存金额 = 0;

            float.TryParse(v_应收金额, out f_应收金额);
            float.TryParse(v_实收金额, out f_实收金额);
            f_预存金额 = f_实收金额 - f_应收金额;
            if (f_实收金额 < f_应收金额)
            {
                new MsgBoxForm("提示", "实收金额不能小于应收金额!").ShowDialog();
                return;
            }
            PriceInfo priceInfo = PriceHelper.GetPriceInfo();

            e.Graphics.DrawString(string.Format("{0}{1}年{2}月物业管理费明细单", this.MyCommunity, currFeeYear, currFeeMonth), new Font("宋体", 16), Brushes.Black, 180, 20);
            e.Graphics.DrawLine(new Pen(Color.Black, (float)1.00), 50, 45, 770, 45);
            e.Graphics.DrawString("业主姓名:" + this.交款人员TextBox.Text, new Font("宋体", 10), Brushes.Black, 55, 50);
            e.Graphics.DrawString("业主编号:" + v_业主编号, new Font("宋体", 10), Brushes.Black, 550, 50);
            e.Graphics.DrawLine(new Pen(Color.Black), 50, 70, 770, 70);
            e.Graphics.DrawString("电表序列", new Font("宋体", 10), Brushes.Black, 55, 78);
            e.Graphics.DrawString("电单价", new Font("宋体", 10), Brushes.Black, 125, 78);
            e.Graphics.DrawString("上月数", new Font("宋体", 10), Brushes.Black, 180, 78);
            e.Graphics.DrawString("本月数", new Font("宋体", 10), Brushes.Black, 235, 78);
            e.Graphics.DrawString("用量", new Font("宋体", 10), Brushes.Black, 290, 78);
            e.Graphics.DrawString("电费", new Font("宋体", 10), Brushes.Black, 340, 78);
            e.Graphics.DrawString("公共照明", new Font("宋体", 10), Brushes.Black, 400, 78);
            e.Graphics.DrawString("电损", new Font("宋体", 10), Brushes.Black, 470, 78);
            e.Graphics.DrawString("物业费", new Font("宋体", 10), Brushes.Black, 520, 78);
            e.Graphics.DrawString("合计", new Font("宋体", 10), Brushes.Black, 575, 78);
            int MyPosY = 98;
            int MyID   = 1;

            foreach (DataRow MyRow in this.dtData.Rows)
            {
                string v_物业费 = string.Empty;
                double d_物业费 = 0;
                if (ownerInfo != null && MyID == 1)
                {
                    d_物业费 = ownerInfo.d_物业费用;
                    v_物业费 = d_物业费.ToString("N2");
                }
                double d_电费 = Helper.Obj2Double(MyRow["金额"]);
                double d_合计 = d_电费 + d_物业费;
                e.Graphics.DrawString(MyID.ToString(), new Font("宋体", 10), Brushes.Black, 55, MyPosY);
                e.Graphics.DrawString(priceInfo.d_标准电费价格.ToString("N3"), new Font("宋体", 10), Brushes.Black, 125, MyPosY);
                e.Graphics.DrawString(Helper.Obj2String(MyRow["上月数"]), new Font("宋体", 10), Brushes.Black, 180, MyPosY);
                e.Graphics.DrawString(Helper.Obj2String(MyRow["本月数"]), new Font("宋体", 10), Brushes.Black, 235, MyPosY);
                e.Graphics.DrawString(Helper.Obj2String(MyRow["用量"]), new Font("宋体", 10), Brushes.Black, 290, MyPosY);
                e.Graphics.DrawString(d_电费.ToString("N2"), new Font("宋体", 10), Brushes.Black, 340, MyPosY);
                e.Graphics.DrawString(priceInfo.d_公共照明价格.ToString("N3"), new Font("宋体", 10), Brushes.Black, 400, MyPosY);
                e.Graphics.DrawString(priceInfo.d_电力损耗价格.ToString("N3"), new Font("宋体", 10), Brushes.Black, 470, MyPosY);
                e.Graphics.DrawString(v_物业费, new Font("宋体", 10), Brushes.Black, 520, MyPosY);
                e.Graphics.DrawString(d_合计.ToString("N2"), new Font("宋体", 10), Brushes.Black, 575, MyPosY);
                MyPosY += 20;
                MyID   += 1;
            }
            e.Graphics.DrawLine(new Pen(Color.Black), 50, MyPosY, 770, MyPosY);
            e.Graphics.DrawLine(new Pen(Color.Black), 120, 70, 120, MyPosY);
            e.Graphics.DrawLine(new Pen(Color.Black), 175, 70, 175, MyPosY);
            e.Graphics.DrawLine(new Pen(Color.Black), 230, 70, 230, MyPosY);
            e.Graphics.DrawLine(new Pen(Color.Black), 285, 70, 285, MyPosY + 50);
            e.Graphics.DrawLine(new Pen(Color.Black), 335, 70, 335, MyPosY);
            e.Graphics.DrawLine(new Pen(Color.Black), 395, 70, 395, MyPosY);
            e.Graphics.DrawLine(new Pen(Color.Black), 465, 70, 465, MyPosY);
            e.Graphics.DrawLine(new Pen(Color.Black), 515, 70, 515, MyPosY);
            e.Graphics.DrawLine(new Pen(Color.Black), 570, 70, 570, MyPosY + 50);
            e.Graphics.DrawLine(new Pen(Color.Black), 425, MyPosY, 425, MyPosY + 50);
            e.Graphics.DrawString("应收费用:" + f_应收金额.ToString("N2") + "元", new Font("宋体", 10), Brushes.Black, 55, MyPosY + 10);
            e.Graphics.DrawString("实收费用:" + f_实收金额.ToString("N2") + "元", new Font("宋体", 10), Brushes.Black, 290, MyPosY + 10);
            e.Graphics.DrawString("预收费用:" + f_预存金额.ToString("N2") + "元", new Font("宋体", 10), Brushes.Black, 430, MyPosY + 10);
            e.Graphics.DrawString("缴费时间:" + DateTime.Now.ToString("yyyy年M月d日"), new Font("宋体", 10), Brushes.Black, 575, MyPosY + 10);
            e.Graphics.DrawString("备注:" + this.补充说明TextBox.Text, new Font("宋体", 10), Brushes.Black, 55, MyPosY + 30);
            //下边框
            e.Graphics.DrawLine(new Pen(Color.Black, (float)1.00), 50, MyPosY + 50, 770, MyPosY + 50);
            //左边框
            e.Graphics.DrawLine(new Pen(Color.Black, (float)1.00), 50, 45, 50, MyPosY + 50);
            //右边框
            e.Graphics.DrawLine(new Pen(Color.Black, (float)1.00), 770, 45, 770, MyPosY + 50);
            if (communityInfoDic.ContainsKey(this.MyCommunity))
            {
                string v_服务电话 = communityInfoDic[this.MyCommunity];
                if (!string.IsNullOrEmpty(v_服务电话))
                {
                    e.Graphics.DrawString(string.Format("报修、查询费用请拨物业服务电话: {0}", v_服务电话), new Font("宋体", 10), Brushes.Black, 430, MyPosY + 55);
                }
            }
        }
Beispiel #5
0
 private void UpdateRealTimePrice(ObjectType objType, PriceInfo info)
 {
     CacheHelper.Set(string.Format("{0}_{1}", (int)objType, info.code), JsonConvert.SerializeObject(info));
 }
Beispiel #6
0
 private void UpdateDayPrice(ObjectType objType, PriceInfo info)
 {
     CacheHelper.Set(string.Format("{0}_{1}_{2}_current", (int)objType, info.code, TechCycle.day.ToString().ToLower()), JsonConvert.SerializeObject(info));
 }
Beispiel #7
0
        /// <summary>
        /// 返回日周月三线的数据
        /// </summary>
        /// <param name="p1">code</param>
        /// <param name="p2">类别</param>
        /// <returns></returns>
        public IHttpActionResult GetKDataAllCycle(string p1, string p2)
        {
            if (string.IsNullOrEmpty(p1) || string.IsNullOrEmpty(p2))
            {
                return(BadRequest("参数不合规"));
            }

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

            string[] cycles = new string[3] {
                "day", "week", "month"
            };
            foreach (var cycle in cycles)
            {
                string current = getCurrentDataFromCache(p1, cycle, p2);
                string history = getLastDataFromCache(p1, cycle, p2);// CacheHelper.Get<string>(string.Format("{0}_{1}_{2}", p3, p1, p2.ToLower()));
                //日线不处理
                //周线,当前价格+current计算得当前周
                //月线,当前价格+current计算得当前月
                switch (cycle.ToLower())
                {
                case "day":
                    //return Ok(string.Format("{{current:{0},history:{1}}}", current, history));
                    break;

                case "week":
                case "month":
                    var dayPriceStr = getCurrentDataFromCache(p1, "day", p2);
                    if (!string.IsNullOrEmpty(dayPriceStr))
                    {
                        PriceInfo currentPrice = JsonConvert.DeserializeObject <PriceInfo>(dayPriceStr);

                        PriceInfo currentCycle = null;
                        if (!string.IsNullOrEmpty(current))
                        {
                            currentCycle = JsonConvert.DeserializeObject <PriceInfo>(current);

                            currentCycle.price    = currentPrice.price;
                            currentCycle.high     = currentPrice.high >= currentCycle.high ? currentPrice.high : currentCycle.high;
                            currentCycle.low      = currentPrice.low <= currentCycle.low ? currentPrice.low : currentCycle.low;
                            currentCycle.volume   = currentCycle.volume + currentPrice.volume;
                            currentCycle.turnover = currentCycle.turnover + currentPrice.volume;
                            if (currentCycle.yestclose.HasValue)
                            {
                                currentCycle.percent = Math.Round(((currentPrice.price - currentCycle.yestclose ?? 0) * 100) / currentCycle.yestclose.Value, 2);
                            }
                            else
                            {
                                currentCycle.percent = 0;
                            }
                        }
                        else
                        {
                            currentCycle = currentPrice;
                        }
                        current = JsonConvert.SerializeObject(currentCycle);
                    }
                    break;
                }
                if (string.IsNullOrEmpty(current))
                {
                    current = "null";
                }
                if (string.IsNullOrEmpty(history))
                {
                    history = "[]";
                }
                result.Add(string.Format("\"{0}\":{{\"current\":{1},\"history\":{2}}}", cycle, current, history));
            }
            return(new StringToJsonResult("{" + String.Join(",", result) + "}", this.Request));
        }
Beispiel #8
0
        /// <summary>
        /// 获取K线数据
        /// </summary>
        /// <param name="p1">code,编码</param>
        /// <param name="p2">周期,day,week,month</param>
        /// <param name="p3">数据类型,1,个股,2,行业,3,大盘</param>
        /// <returns>{current:[],history:[]}</returns>
        public IHttpActionResult GetKData(string p1, string p2, string p3)
        {
            if (string.IsNullOrEmpty(p1) || string.IsNullOrEmpty(p2))
            {
                return(BadRequest("参数不合规"));
            }

            data.TechCycle cycle;
            if (!Enum.TryParse(p2, true, out cycle))
            {
                return(BadRequest("参数不合规"));
            }

            string current = getCurrentDataFromCache(p1, p2, p3);
            string history = getLastDataFromCache(p1, p2, p3);// CacheHelper.Get<string>(string.Format("{0}_{1}_{2}", p3, p1, p2.ToLower()));

            //日线不处理
            //周线,当前价格+current计算得当前周
            //月线,当前价格+current计算得当前月
            switch (p2.ToLower())
            {
            case "day":
                //return Ok(string.Format("{{current:{0},history:{1}}}", current, history));
                break;

            case "week":
            case "month":
                var dayPriceStr = getCurrentDataFromCache(p1, "day", p3);
                if (!string.IsNullOrEmpty(dayPriceStr))
                {
                    PriceInfo currentPrice = JsonConvert.DeserializeObject <PriceInfo>(dayPriceStr);

                    PriceInfo currentCycle = null;
                    if (!string.IsNullOrEmpty(current))
                    {
                        currentCycle = JsonConvert.DeserializeObject <PriceInfo>(current);

                        currentCycle.price    = currentPrice.price;
                        currentCycle.high     = currentPrice.high >= currentCycle.high ? currentPrice.high : currentCycle.high;
                        currentCycle.low      = currentPrice.low <= currentCycle.low ? currentPrice.low : currentCycle.low;
                        currentCycle.volume   = currentCycle.volume + currentPrice.volume;
                        currentCycle.turnover = currentCycle.turnover + currentPrice.volume;
                        if (currentCycle.yestclose.HasValue)
                        {
                            currentCycle.percent = Math.Round(((currentPrice.price - currentCycle.yestclose ?? 0) * 100) / currentCycle.yestclose.Value, 2);
                        }
                        else
                        {
                            currentCycle.percent = 0;
                        }
                    }
                    else
                    {
                        currentCycle = currentPrice;
                    }
                    current = JsonConvert.SerializeObject(currentCycle);
                }
                break;
            }
            if (string.IsNullOrEmpty(current))
            {
                current = "null";
            }
            if (string.IsNullOrEmpty(history))
            {
                history = "[]";
            }
            return(new StringToJsonResult(string.Format("{{\"current\":{0},\"history\":{1}}}", current, history), this.Request));
        }
        public static PriceInfo Generate()
        {
            var priceInfo = new PriceInfo()
            {
                granularity     = "daily",
                maxAnomalyRatio = 0.25,
                sensitivity     = 95,
                series          = new List <Series>()
                {
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 01), value = 32858923
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 02), value = 29615278
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 03), value = 22839355
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 04), value = 25948736
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 05), value = 34139159
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 06), value = 33843985
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 07), value = 33637661
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 08), value = 32627350
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 09), value = 29881076
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 10), value = 22681575
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 11), value = 24629393
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 12), value = 34010679
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 13), value = 33893888
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 14), value = 33760076
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 15), value = 33093515
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 16), value = 29945555
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 17), value = 22676212
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 18), value = 25262514
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 19), value = 33631649
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 20), value = 34468310
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 21), value = 34212281
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 22), value = 38144434
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 23), value = 34662949
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 24), value = 24623684
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 25), value = 26530491
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 26), value = 35445003
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 27), value = 34250789
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 28), value = 33423012
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 29), value = 30744783
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 30), value = 25825128
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 03, 31), value = 21244209
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 01), value = 22576956
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 02), value = 31957221
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 03), value = 33841228
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 04), value = 33554483
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 05), value = 32383350
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 06), value = 29494850
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 07), value = 22815534
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 08), value = 25557267
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 09), value = 34858252
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 10), value = 34750597
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 11), value = 34717956
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 12), value = 34132534
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 13), value = 30762236
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 14), value = 22504059
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 15), value = 26149060
                    },
                    new Series()
                    {
                        timestamp = new DateTime(2018, 04, 16), value = 35250105
                    },
                }
            };

            return(priceInfo);
        }
        private void 水电气费BindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            string v_小区名称 = this.小区名称ToolStripComboBox.Text.Trim();
            string v_楼栋名称 = this.楼栋名称ToolStripComboBox.Text.Trim();
            string v_计费年份 = this.计费年份ToolStripComboBox.Text.Trim();
            string v_计费月份 = this.计费月份ToolStripComboBox.Text.Trim();
            string v_费用类型 = "物业费用";

            if (string.IsNullOrEmpty(v_计费年份) || string.IsNullOrEmpty(v_计费月份) || string.IsNullOrEmpty(v_小区名称) || string.IsNullOrEmpty(v_楼栋名称))
            {
                new MsgBoxForm("提示", "没有选择正确的计费年份,计费月份,小区名称,楼栋名称等信息!").ShowDialog();
                return;
            }

            try
            {
                PriceInfo priceInfo = PriceHelper.GetPriceInfo();
                foreach (DataGridViewRow gridViewRow in this.水电气费DataGridView.Rows)
                {
                    string v_业主编号 = Helper.GetCellValue(gridViewRow, "业主编号");
                    if (string.IsNullOrEmpty(v_业主编号))
                    {
                        continue;
                    }
                    string v_业主姓名 = Helper.GetCellValue(gridViewRow, "业主姓名");
                    string v_表编号 = Helper.GetCellValue(gridViewRow, "表编号");
                    string v_上月数 = Helper.GetCellValue(gridViewRow, "上月数");
                    string v_本月数 = Helper.GetCellValue(gridViewRow, "本月数");
                    string v_计费单价 = Helper.GetCellValue(gridViewRow, "计费单价");
                    string v_表用量 = string.Empty, v_补充说明 = string.Empty;
                    float  f_表底数 = 0, f_表止数 = 0, f_计费单价 = 0, f_应交金额;
                    float.TryParse(v_上月数, out f_表底数);
                    float.TryParse(v_本月数, out f_表止数);
                    float.TryParse(v_计费单价, out f_计费单价);

                    if (f_表底数 > f_表止数)
                    {
                        new MsgBoxForm("提示", "本月数不能小于上月数,请重新输入!").ShowDialog();
                        return;
                    }
                    if (f_计费单价 < 0)
                    {
                        new MsgBoxForm("提示", "计费单价不能小于0,请重新输入!").ShowDialog();
                        return;
                    }
                    v_表用量  = (f_表止数 - f_表底数).ToString("N2");
                    f_应交金额 = (f_表止数 - f_表底数) * f_计费单价;
                    v_补充说明 = string.Format("含公共照明:{0} 电力损耗:{1}", ((f_表止数 - f_表底数) * priceInfo.d_公共照明价格).ToString("N3"), ((f_表止数 - f_表底数) * priceInfo.d_电力损耗价格).ToString("N3"));
                    string query = "UPDATE 水电气费 SET 上月数=" + v_上月数 + ",本月数=" + v_本月数 + ",表用量=" + v_表用量 + ",计费单价=" + v_计费单价 + ",应交金额=" + f_应交金额 + ",补充说明='" + v_补充说明 + "' WHERE 计费年份=" + v_计费年份 +
                                   " AND 计费月份=" + v_计费月份 + " AND 费用类型='" + v_费用类型 + "' AND 楼栋名称='" + v_楼栋名称 + "' AND 业主编号='" + v_业主编号 + "' AND 业主姓名='" + v_业主姓名 + "' AND 表编号='" + v_表编号 + "'";
                    DataHelper.UpdateOrDeleteRecord(query);
                }
                DataHelper.CommitUpdate();
                SynGasRegisterInfo(v_计费年份, v_计费月份, v_楼栋名称, "正在登记");
                new MsgBoxForm("提示", "保存成功!").ShowDialog();
            }
            catch (Exception ex)
            {
                new MsgBoxForm("提示", "保存失败,请检查所填数据类型!").ShowDialog();
                LogHelper.LogError(ex);
            }
        }
Beispiel #11
0
 public void Constructor_WithEmptyString_ReturnsNull()
 {
     _priceInfo = JsonConvert.DeserializeObject <PriceInfo>(string.Empty);
     Assert.IsNull(_priceInfo);
 }
        public string ModifyPriceInfo(string loginIdentifer, string priceJson)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;
            CommonUtil.WaitMainLibInit();
            JavaScriptObject jso = (JavaScriptObject)JavaScriptConvert.DeserializeObject(priceJson);

            if (jso == null)
            {
                obj2["Message"] = "参数priceJson格式不正确";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if ((!jso.ContainsKey("ID") || (jso["ID"] == null)) || (jso["ID"].ToString().Trim() == ""))
            {
                obj2["Message"] = "价格ID不能为空";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            PriceInfo pi = null;

            try
            {
                pi = this.JsonToPriceInfo(jso);
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            ResMsg msg = PriceModule.ModifyPriceInfo(pi);

            string[]    strArray  = new string[] { "一阶名称", "二阶名称", "三阶名称", "四阶名称" };
            string[]    strArray2 = new string[4];
            string[]    strArray3 = new string[4];
            XmlDocument document  = new XmlDocument();
            string      filename  = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"App_Config\Price.config";

            document.Load(filename);
            XmlNode node  = document.GetElementsByTagName("水价").Item(0);
            XmlNode node2 = document.GetElementsByTagName("电价").Item(0);
            int     num   = int.Parse(document.SelectSingleNode("价格设置/水价/阶梯数量").InnerText);
            int     num2  = int.Parse(document.SelectSingleNode("价格设置/电价/阶梯数量").InnerText);

            for (int i = 0; (i < num) && (i < strArray.Length); i++)
            {
                XmlNode node5 = node.SelectSingleNode(strArray[i]);
                strArray2[i] = node5.InnerText;
            }
            for (int j = 0; (j < num2) && (j < strArray.Length); j++)
            {
                XmlNode node6 = node2.SelectSingleNode(strArray[j]);
                strArray3[j] = node6.InnerText;
            }
            obj2["Result"]  = msg.Result;
            obj2["Message"] = msg.Message;
            try
            {
                SysLog log = new SysLog();
                log.LogUserId   = loginUser.UserId;
                log.LogUserName = loginUser.LoginName;
                log.LogAddress  = ToolsWeb.GetIP(context.Request);
                log.LogTime     = DateTime.Now;
                log.LogType     = "修改价格信息";
                log.LogContent  = msg + "|" + ModelHandler <PriceInfo> .ToString(pi);

                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
Beispiel #13
0
        internal static decimal CalculateChange(decimal balance, PriceInfo info)
        {
            decimal oldPrice = info.price + (info.price * (info.change / 100m));

            return(Math.Abs((balance * info.price) - (oldPrice * balance)));
        }
 public void Update(ArticleInfo articleInfo, PriceInfo priceInfo)
 {
     this.ArticleInfo = articleInfo;
     this.PriceInfo   = priceInfo;
     this.UpdateInfo  = this.UpdateInfo.MarkAsSuccessful();
 }
Beispiel #15
0
        private void ItemShop(CommandArgs args)
        {
            var parameters        = args.Parameters;
            var player            = args.Player;
            var playerGroupConfig = Config.Instance.GetGroupConfig(player.Group.Name);
            var subcommand        = parameters.Count > 0 ? parameters[0] : "";

            if (subcommand.Equals("1", StringComparison.OrdinalIgnoreCase))
            {
                player.AwaitingTempPoint = 1;
                player.SendInfoMessage("Hit a block to set the first point.");
            }
            else if (subcommand.Equals("2", StringComparison.OrdinalIgnoreCase))
            {
                player.AwaitingTempPoint = 2;
                player.SendInfoMessage("Hit a block to set the second point.");
            }
            else if (subcommand.Equals("buy", StringComparison.OrdinalIgnoreCase))
            {
                if (parameters.Count != 2 && parameters.Count != 3)
                {
                    player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop buy <item-index> [amount]");
                    return;
                }

                var session = GetOrCreateSession(player);
                if (session.CurrentlyViewedShop == null)
                {
                    player.SendErrorMessage("You aren't currently viewing a shop.");
                    return;
                }
                var shop = session.CurrentlyViewedShop;

                var inputItemIndex = parameters[1];
                if (!int.TryParse(inputItemIndex, out var itemIndex) || itemIndex < 1 || itemIndex > Chest.maxItems)
                {
                    player.SendErrorMessage($"Invalid item index '{inputItemIndex}'.");
                    return;
                }

                var shopItem = shop.Items.FirstOrDefault(i => i.Index == itemIndex - 1 && i.StackSize > 0);
                if (shopItem == null)
                {
                    player.SendErrorMessage($"Invalid item index '{inputItemIndex}'.");
                    return;
                }

                var inputAmount = parameters.Count == 3 ? parameters[2] : "1";
                if (!int.TryParse(inputAmount, out var amount) || amount < 1 || amount > shopItem.StackSize)
                {
                    player.SendErrorMessage($"Invalid amount '{inputAmount}'.");
                    return;
                }

                var item   = new Item();
                var itemId = shopItem.ItemId;
                item.SetDefaults(itemId);

                //var unitPrice = shop.UnitPrices.Get(itemId, item.value / 5);
                var unitPriceInfo = shop.UnitPrices[itemId];

                if (!unitPriceInfo.IsValid)
                {
                    player.SendErrorMessage("Unfortunately, this item is priced incorrectly. Please contact the shop owner.");
                    return;
                }

                var currencyConverter = unitPriceInfo.Currency.GetCurrencyConverter();

                //var purchaseCost = (amount * shop.UnitPrices.Get(itemId, item.value / 5));
                var purchaseCost       = amount * unitPriceInfo.Value;
                var salesTax           = Math.Round(purchaseCost * (decimal)playerGroupConfig.SalesTaxRate);
                var purchaseCostString = currencyConverter.ToString(purchaseCost);
                var salesTaxString     = currencyConverter.ToString(salesTax);

                var itemText = $"[i/s{amount},p{shopItem.PrefixId}:{shopItem.ItemId}]";
                player.SendInfoMessage(
                    $"Purchasing {itemText} will cost [c/{Color.OrangeRed.Hex3()}:{purchaseCostString}], " +
                    $"with a sales tax of [c/{Color.OrangeRed.Hex3()}:{salesTaxString}].");
                player.SendInfoMessage("Do you wish to proceed? Use /yes or /no.");
                player.AddResponse("yes", args2 =>
                {
                    player.AwaitingResponse.Remove("no");

                    var account = BankingPlugin.Instance.GetBankAccount(player.Name, unitPriceInfo.Currency.InternalName);
                    if (account == null || account.Balance < purchaseCost + salesTax)
                    {
                        player.SendErrorMessage($"You do not have enough of a balance to purchase {itemText}.");
                        shop.TryShowStock(player, MessageRefreshDelay);
                        return;
                    }
                    if (shopItem.StackSize < amount || shopItem.ItemId != itemId || shop.IsBeingChanged)
                    {
                        player.SendErrorMessage("While waiting, the shop changed.");
                        //shop.TryShowStock(player, MessageRefreshDelay * 2);//if the shop is changing, lets not spam anyones display while it is
                        return;
                    }

                    if (purchaseCost > 0)
                    {
                        var account2 = BankingPlugin.Instance.GetBankAccount(shop.OwnerName, unitPriceInfo.Currency.InternalName);
                        account.TryTransferTo(account2, purchaseCost);
                    }
                    if (salesTax > 0)
                    {
                        account.TryTransferTo(BankingPlugin.Instance.GetWorldAccount(), salesTax);
                    }

                    shopItem.StackSize -= amount;
                    database.Update(shop);

                    var totalCost       = purchaseCost + salesTax;
                    var totalCostString = currencyConverter.ToString(totalCost);

                    player.GiveItem(
                        itemId, "", Player.defaultWidth, Player.defaultHeight, amount, shopItem.PrefixId);
                    player.SendSuccessMessage($"Purchased {itemText} for " +
                                              $"[c/{Color.OrangeRed.Hex3()}:{totalCostString}].");

                    var player2 = TShock.Players.Where(p => p?.Active == true)
                                  .FirstOrDefault(p => p.User?.Name == shop.OwnerName);
                    player2?.SendInfoMessage($"{player.Name} purchased {itemText} for " +
                                             $"[c/{Color.OrangeRed.Hex3()}:{totalCostString}].");

                    shop.TryShowStock(player, MessageRefreshDelay);
                });
                player.AddResponse("no", args2 =>
                {
                    player.AwaitingResponse.Remove("yes");
                    player.SendInfoMessage("Canceled purchase.");

                    shop.TryShowStock(player, MessageRefreshDelay);
                });
            }
            else if (subcommand.Equals("close", StringComparison.OrdinalIgnoreCase))
            {
                var session = GetOrCreateSession(player);
                if (session.CurrentShop == null)
                {
                    player.SendErrorMessage("You aren't currently in a shop.");
                    return;
                }

                var shop = session.CurrentShop;
                if (shop.OwnerName != player.User?.Name && !player.HasPermission("housing.itemshop.admin"))
                {
                    player.SendErrorMessage(
                        $"You can't close {shop.OwnerName}'s shop [c/{Color.LimeGreen.Hex3()}:{shop}].");
                    return;
                }

                shop.IsOpen = false;
                database.Update(shop);
                player.SendSuccessMessage(
                    $"Closed {(shop.OwnerName == player.User?.Name ? "your shop" : shop.OwnerName + "'s shop")} " +
                    $"[c/{Color.LimeGreen.Hex3()}:{shop}].");
            }
            else if (subcommand.Equals("info", StringComparison.OrdinalIgnoreCase))
            {
                var session = GetOrCreateSession(player);
                if (session.CurrentShop == null)
                {
                    player.SendErrorMessage("You aren't currently in a shop.");
                    return;
                }

                var shop = session.CurrentShop;
                player.SendInfoMessage($"Owner: {shop.OwnerName}, Name: {shop.Name}");
                var prices = shop.UnitPrices.Where(kvp => kvp.Value.IsValid && kvp.Value.Value > 0)
                             .Select(kvp => $"[i:{kvp.Key}]: {Color.OrangeRed.ColorText(kvp.Value.Price)}");

                player.SendInfoMessage(
                    $"Prices: {string.Join(", ", prices)}. All other items are default sell prices.");
                if (shop.OwnerName == player.User?.Name)
                {
                    //var ownerConfig = shop.GetGroupConfig();

                    var house   = session.CurrentHouse;
                    var taxRate = playerGroupConfig.StoreTaxRate - playerGroupConfig.TaxRate;
                    var taxCost = (decimal)Math.Round(house.Area * taxRate);
                    player.SendInfoMessage($"Extra tax on house: {Color.OrangeRed.ColorText(taxCost.ToMoneyString())}");
                }
            }
            else if (subcommand.Equals("open", StringComparison.OrdinalIgnoreCase))
            {
                var session = GetOrCreateSession(player);
                if (session.CurrentShop == null)
                {
                    player.SendErrorMessage("You aren't currently in a shop.");
                    return;
                }

                var shop = session.CurrentShop;
                if (shop.OwnerName != player.User?.Name && !player.HasPermission("housing.itemshop.admin"))
                {
                    player.SendErrorMessage(
                        $"You can't open {shop.OwnerName}'s shop {Color.LimeGreen.ColorText(shop)}.");
                    return;
                }

                shop.IsOpen = true;
                database.Update(shop);
                player.SendSuccessMessage(
                    $"Opened {(shop.OwnerName == player.User?.Name ? "your shop" : shop.OwnerName + "'s shop")} " +
                    $"{Color.LimeGreen.ColorText(shop)}.");
            }
            else if (subcommand.Equals("remove", StringComparison.OrdinalIgnoreCase))
            {
                var session = GetOrCreateSession(player);
                if (session.CurrentShop == null)
                {
                    player.SendErrorMessage("You aren't currently in a shop.");
                    return;
                }

                var shop = session.CurrentShop;
                if (shop.OwnerName != player.User?.Name && !player.HasPermission("housing.itemshop.admin"))
                {
                    player.SendErrorMessage(
                        $"You can't remove {shop.OwnerName}'s shop {Color.LimeGreen.ColorText(shop)}.");
                    return;
                }

                // Revert the chest to a normal chest.
                var chestId = Chest.FindEmptyChest(shop.ChestX, shop.ChestY);
                if (chestId >= 0)
                {
                    var chest = new Chest();
                    for (var i = 0; i < Chest.maxItems; ++i)
                    {
                        var shopItem = shop.Items.FirstOrDefault(si => si.Index == i);
                        var item     = new Item();
                        item.SetDefaults(shopItem?.ItemId ?? 0);
                        item.stack    = shopItem?.StackSize ?? 0;
                        item.prefix   = shopItem?.PrefixId ?? 0;
                        chest.item[i] = item;
                    }
                    Main.chest[chestId] = chest;
                }

                database.Remove(shop);
                player.SendSuccessMessage(
                    $"Removed {(shop.OwnerName == player.User?.Name ? "your shop" : shop.OwnerName + "'s shop")} " +
                    $"{Color.LimeGreen.ColorText(shop)}.");
            }
            else if (subcommand.Equals("set", StringComparison.OrdinalIgnoreCase))
            {
                if (parameters.Count != 2)
                {
                    player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop set <shop-name>");
                    return;
                }

                if (player.TempPoints.Any(p => p == Point.Zero))
                {
                    player.SendErrorMessage("Not all points have been set.");
                    return;
                }

                var session = GetOrCreateSession(player);
                if (session.CurrentHouse == null || session.CurrentHouse.OwnerName != player.User?.Name)
                {
                    player.SendErrorMessage("You aren't currently in a house that you own.");
                    return;
                }

                //var playerGroupConfig = Config.Instance.GetGroupConfig(player.Group.Name);
                var point1        = player.TempPoints[0];
                var point2        = player.TempPoints[1];
                var inputShopName = parameters[1];
                var x             = Math.Min(point1.X, point2.X);
                var y             = Math.Min(point1.Y, point2.Y);
                var x2            = Math.Max(point1.X, point2.X);
                var y2            = Math.Max(point1.Y, point2.Y);
                var area          = (x2 - x + 1) * (y2 - y + 1);
                if (area < playerGroupConfig.MinShopSize)
                {
                    player.SendErrorMessage($"Your shop is too small. Minimum area is {playerGroupConfig.MinShopSize}.");
                    return;
                }
                if (area > playerGroupConfig.MaxShopSize)
                {
                    player.SendErrorMessage($"Your shop is too large.Maximum area is {playerGroupConfig.MaxShopSize}.");
                    return;
                }

                var rectangle = new Rectangle(x, y, x2 - x + 1, y2 - y + 1);
                if (!session.CurrentHouse.Rectangle.Contains(rectangle))
                {
                    player.SendErrorMessage("Your shop must lie entirely within your house.");
                    return;
                }

                session.NextShopHouse = session.CurrentHouse;
                session.NextShopName  = inputShopName;
                session.NextShopX     = x;
                session.NextShopY     = y;
                session.NextShopX2    = x2;
                session.NextShopY2    = y2;
                player.SendInfoMessage("Place a chest to serve as the item shop chest.");
            }
            else if (subcommand.Equals("setmsg", StringComparison.OrdinalIgnoreCase))
            {
                if (parameters.Count < 2)
                {
                    player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop setmsg <message>");
                    return;
                }

                var session = GetOrCreateSession(player);
                if (session.CurrentShop == null)
                {
                    player.SendErrorMessage("You aren't currently in a shop.");
                    return;
                }

                var shop = session.CurrentShop;
                if (shop.OwnerName != player.User?.Name && !player.HasPermission("housing.itemshop.admin"))
                {
                    player.SendErrorMessage(
                        $"You can't set the message for {shop.OwnerName}'s {Color.LimeGreen.ColorText(shop)} shop.");
                    return;
                }

                var message = string.Join(" ", parameters.Skip(1));
                shop.Message = message;
                database.Update(shop);
                player.SendSuccessMessage(
                    $"Updated {(shop.OwnerName == player.User?.Name ? "your" : shop.OwnerName + "'s")} " +
                    $"{Color.LimeGreen.ColorText(shop)} shop message.");
            }
            else if (subcommand.Equals("setprice", StringComparison.OrdinalIgnoreCase))
            {
                if (parameters.Count != 3)
                {
                    player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop setprice <item-name> <price>");
                    return;
                }

                var session = GetOrCreateSession(player);
                if (session.CurrentShop == null)
                {
                    player.SendErrorMessage("You aren't currently in a shop.");
                    return;
                }

                var shop = session.CurrentShop;
                if (shop.OwnerName != player.User?.Name && !player.HasPermission("housing.itemshop.admin"))
                {
                    player.SendErrorMessage(
                        $"You can't modify {shop.OwnerName}'s {Color.LimeGreen.ColorText(shop)} shop.");
                    return;
                }

                var inputItemName = parameters[1];
                var items         = TShock.Utils.GetItemByIdOrName(inputItemName);
                if (items.Count > 1)
                {
                    player.SendErrorMessage($"Multiple items matched '{inputItemName}':");
                    TShock.Utils.SendMultipleMatchError(player, items);
                    return;
                }
                if (items.Count == 0)
                {
                    player.SendErrorMessage($"Invalid item '{inputItemName}'.");
                    return;
                }

                var inputPrice = parameters[2];
                var priceInfo  = new PriceInfo(inputPrice);
                var disable    = false;

                if (inputPrice == "0" || inputPrice == "none")
                {
                    disable = true;
                }

                //if(!BankingPlugin.Instance.Bank.CurrencyManager.TryFindCurrencyFromString(inputPrice, out var priceCurrency))
                if (!priceInfo.IsValid && !disable)
                {
                    player.SendErrorMessage($"Invalid price. '{inputPrice}' is not a valid currency format.");
                    return;
                }

                if (priceInfo.Value <= 0m && !disable)
                {
                    player.SendErrorMessage($"Invalid price '{inputPrice}'. Price cannot be less than 1.");
                    return;
                }

                //we use CurrencyConverter.ToString() here to ensure the unit price uses the largest currency values possible.
                //shop.UnitPrices[items[0].type] = priceCurrency.GetCurrencyConverter().ToString(price);
                shop.UnitPrices[items[0].type] = priceInfo;
                database.Update(shop);

                if (disable)
                {
                    player.SendSuccessMessage(
                        $"Removed {inputItemName} from the {Color.LimeGreen.ColorText(shop)} item listing.");
                }
                else
                {
                    player.SendSuccessMessage(
                        $"Updated {(shop.OwnerName == player.User?.Name ? "your" : shop.OwnerName + "'s")} " +
                        $"{Color.LimeGreen.ColorText(shop)} shop prices.");
                }
            }
            else
            {
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop 1/2");
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop buy <item-index> [amount]");
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop close");
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop info");
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop open");
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop remove");
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop set <shop-name>");
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop setmsg <message>");
                player.SendErrorMessage($"Syntax: {Commands.Specifier}itemshop setprice <item-name> <price> ( 0 or none disables listing. )");
            }
        }