private void btnAdd_Click(object sender, RoutedEventArgs e) { SellInfo sellInfo = new SellInfo(); if (!string.IsNullOrWhiteSpace(txtBand.Text) && !string.IsNullOrWhiteSpace(txtName.Text)) { sellInfo.CDName = txtName.Text; sellInfo.BandName = txtBand.Text; try { string str1 = dpDate.SelectedDate.Value.ToShortDateString(); string str2 = dpDate.SelectedDate.Value.ToShortDateString().Substring(str1.Length - 4); sellInfo.Cd_Date = int.Parse(str2); str1 = dpDateFound.SelectedDate.Value.ToShortDateString(); str2 = dpDateFound.SelectedDate.Value.ToShortDateString().Substring(str1.Length - 4); sellInfo.BandDate = int.Parse(str2); // MessageBox.Show(cbFormat.SelectedItem.ToString()); sellInfo.FormatName = cbFormat.SelectedItem.ToString(); _infoClient.AddDiscBand(sellInfo); Console.WriteLine("Ok"); } catch (Exception ex) { MessageBox.Show(ex.Message); } //MainWindow mainWindow = new MainWindow(); } }
static void DoBuyForEmpty(SellInfo sellInfo, decimal nowPrice) { if (lastBuyForEmptyDate > DateTime.Now.AddSeconds(-20)) { // 如果20秒内购购买一单, 则不能再次购买 return; } if (!string.IsNullOrEmpty(sellInfo.BuyClientOid)) { return; } var percent = 1 + ((sellInfo.SellPrice / nowPrice) - 1) / 3; var buySize = sellInfo.SellQuantity * percent; var buyPrice = nowPrice * (decimal)1.01; // 更高的价格购入, 是为了能够购入 var okInstrument = InstrumentsUtils.GetOkInstruments(sellInfo.Quote, sellInfo.Symbol); if (okInstrument == null) { logger.Error($"出售时候发现 不存在的交易对 {sellInfo.Quote},{sellInfo.Symbol}"); return; } buyPrice = decimal.Round(buyPrice, okInstrument.GetTickSizeNumber()); buySize = decimal.Round(buySize, okInstrument.GetSizeIncrementNumber()); var client_oid = "buy" + DateTime.Now.Ticks; try { logger.Error($""); logger.Error($"{JsonConvert.SerializeObject(sellInfo)}"); logger.Error($""); logger.Error($"1: 准备购买(空) {sellInfo.Quote}-{sellInfo.Symbol}, client_oid:{client_oid}, nowPrice:{nowPrice.ToString()}, buyPrice:{buyPrice.ToString()}, buySize:{buySize}"); var sellResult = OkApi.Buy(client_oid, sellInfo.Symbol + "-" + sellInfo.Quote, buyPrice.ToString(), buySize.ToString()); logger.Error($"2: 下单完成 {JsonConvert.SerializeObject(sellResult)}"); sellInfo.BuyClientOid = client_oid; sellInfo.BuyPrice = buyPrice; sellInfo.BuyQuantity = buySize; sellInfo.BuyResult = sellResult.result; sellInfo.BuyOrderId = sellResult.order_id; new SellInfoDao().UpdateSellInfoWhenBuy(sellInfo); logger.Error($"3: 添加记录完成"); logger.Error($""); lastBuyForEmptyDate = DateTime.Now; } catch (Exception e) { logger.Error("购买异常(空) 严重 --> " + e.Message, e); Thread.Sleep(1000 * 60 * 10); } }
public GSellGump_OfferedItem(GSellGump owner, SellInfo si) : base(32, 67, 196, 0) { this.m_OfferMenu = owner.OfferMenu; IFont font = (IFont)Engine.GetUniFont(3); IHue hue = Hues.Load(648); this.m_xAmount = si.ToSell; this.m_Amount = new GLabel(si.ToSell.ToString(), font, hue, 0, 0); this.m_Description = (GLabel) new GWrappedLabel(string.Format("{0} at {1} gp", (object)si.Name, (object)si.Price), font, hue, 41, 0, 105); this.m_More = new GSellGump_AmountButton(owner, si, 5, 55, 155); this.m_Less = new GSellGump_AmountButton(owner, si, -5, 56, 173); this.m_Height = this.m_Amount.Image.yMax - this.m_Amount.Image.yMin + 1; int num = this.m_Description.Image.yMax - this.m_Description.Image.yMin + 1; if (num > this.m_Height) { this.m_Height = num; } int height1 = this.m_More.Height; if (height1 > this.m_Height) { this.m_Height = height1; } int height2 = this.m_Less.Height; if (height2 > this.m_Height) { this.m_Height = height2; } this.m_Amount.X -= this.m_Amount.Image.xMin; this.m_Amount.Y = (this.m_Height - (this.m_Amount.Image.yMax - this.m_Amount.Image.yMin + 1)) / 2; this.m_Description.X -= this.m_Description.Image.xMin; this.m_Description.Y = (this.m_Height - (this.m_Description.Image.yMax - this.m_Description.Image.yMin + 1)) / 2; if (this.m_Amount.Y > this.m_Description.Y) { this.m_Amount.Y = this.m_Description.Y; } this.m_Amount.Y -= this.m_Amount.Image.yMin; this.m_Description.Y -= this.m_Description.Image.yMin; this.m_More.Y = (this.m_Height - this.m_More.Height) / 2; this.m_Less.Y = (this.m_Height - this.m_Less.Height) / 2; this.m_Children.Add((Gump)this.m_Amount); this.m_Children.Add((Gump)this.m_Description); this.m_Children.Add((Gump)this.m_More); this.m_Children.Add((Gump)this.m_Less); this.Clipper = this.m_OfferMenu.ContentClipper; if (!Engine.ServerFeatures.AOS) { return; } this.Tooltip = (ITooltip) new ItemTooltip(si.Item); }
public string chongzhi(SellInfo sellInfo) { yhxx yhxx = baseDAL.Get <yhxx>().FirstOrDefault(c => c.ywbh == sellInfo.ywbh); yhxx.gqcs += 1; if (yhxx.gqzl == null) { yhxx.gqzl = sellInfo.gql; } else { yhxx.gqzl += sellInfo.gql; } yhxx.gqrq = DateTime.Now; //向营业数据表插入信息 yysj newYysj = new yysj(); newYysj.ywbh = sellInfo.ywbh; newYysj.skcs = baseDAL.Get <yysj>().Where(c => c.ywbh == sellInfo.ywbh).Count() + 1; newYysj.skrq = (DateTime)yhxx.gqrq; newYysj.skje = (decimal)sellInfo.qjMoney; newYysj.skql = sellInfo.gql; newYysj.czy = (string)Session["user_id"]; newYysj.bb = 1; newYysj.hh = 1; newYysj.sjkb = 1; newYysj.time = DateTime.Now; newYysj.gzzbh = 1; newYysj.lstbz = 1; newYysj.bqbz = 0; newYysj.zfbz = 0; string fpbh = "IC0010701 "; fpbh += baseDAL.Get <yysj>().Count().ToString(); newYysj.fpbh = fpbh; baseDAL.AddItem <yysj>(newYysj); //放入session以备打印 Session["ywbhP"] = sellInfo.ywbh; Session["fpbhP"] = fpbh; Session["gqlP"] = sellInfo.gql; Session["qjMoneyP"] = sellInfo.qjMoney; Session["moneyTotalP"] = sellInfo.moneyTotal; Session["returnMoneyP"] = sellInfo.returnMoney; if (baseDAL.SaveAllChanges()) { return("充值成功!"); } else { return("充值失败!"); } }
public void SetSell(Shop shop) { info = new SellInfo(); //TODO: envoi des dialogues info.type = RandomGet(shop.typeAvailable); switch (info.type) { case LootType.artefact: info.dialog = RandomGet(shop.artefactDialog); info.artefact = RandomGet(shop.artefactList); info.price = info.artefact.price; info.dialog.inTxt += "\nIl vous le vend pour " + info.price.ToString() + " or."; //TODO:UI break; case LootType.beer: info.dialog = RandomGet(shop.beerDialog); info.amount = Random.Range(shop.beerFork.min, shop.beerFork.max); info.price = info.amount * shop.beerValue; info.dialog.inTxt += "\nIl vous en vend " + info.amount.ToString() + " pour " + info.price.ToString() + " or."; //TODO:UI break; case LootType.stuff: info.dialog = RandomGet(shop.stuffDialog); info.amount = Random.Range(shop.stuffFork.min, shop.stuffFork.max); info.price = info.amount * shop.stuffValue; info.dialog.inTxt += "\nIl vous en vend " + info.amount.ToString() + " pour " + info.price.ToString() + " or."; //TODO:UI break; case LootType.character: info.dialog = RandomGet(shop.memberDialog); info.amount = Random.Range(shop.memberFork.min, shop.memberFork.max); CharacterData data = info.dialog.data; info.dialog.inTxt += "\nC'est une équipe composée de " + info.amount.ToString() + " " + data.race + "s."; info.price = 0; for (int i = 0; i < info.amount; i++) { info.price += data.price; info.team.Add(data); } info.dialog.inTxt += "\nIls se propose de ce joindre à vous pour " + info.price.ToString() + " or."; //TODO:UI break; default: Debug.LogError("Type pas connu!"); break; } }
public void EnterRoom(RoomType type) { dial = new List <string>(); if (entering) { dial.Add(actualArea.Entering); entering = false; } if (Random.value < loreproba) { dial.AddRange(loreList[0].text); loreList.RemoveAt(0); } //Choix de la salle switch (roomType) { case RoomType.Shop: actualRoom = RandomGet(actualArea.shops); Shop shopRoom = actualRoom as Shop; ShopManager.Instance.SetSell(shopRoom); sellInfo = ShopManager.Instance.GetSell(); dial.Add(sellInfo.dialog.inTxt); TextBox.Instance.AddText(dial, false, rightTxt: parameters.buyButton, leftTxt: parameters.leaveButton); break; case RoomType.Loot: actualRoom = RandomGet(actualArea.loots); dial.AddRange(actualRoom.textIn); TextBox.Instance.AddText(dial, false, rightTxt: parameters.enterButton, leftTxt: parameters.leaveButton); break; case RoomType.Empty: actualRoom = RandomGet(actualArea.empties); dial.AddRange(actualRoom.textIn); TextBox.Instance.AddText(dial, false, rightTxt: parameters.exploitBUtton, leftTxt: parameters.leaveButton); break; case RoomType.Fight: actualRoom = RandomGet(actualArea.fights); dial.AddRange(actualRoom.textIn); nbEnnemies = Random.Range((actualRoom as Fight).ennemyAmount.min, (actualRoom as Fight).ennemyAmount.max); dial.Add("Il y a en face de toi " + nbEnnemies.ToString() + " " + (actualRoom as Fight).ennemy.race + "s!"); TextBox.Instance.AddText(dial, false, rightTxt: parameters.fightEnterButton, leftTxt: parameters.fightFleeButton); break; default: Debug.LogError("Type de salle pas pris en charge! " + roomType.ToString()); break; } TextBox.Instance.UpdateDialog(); }
private SellInfo ConvertSellInfo(string orderNo, int userId, DbTransaction trans = null) { SellInfo result = null; QuotationInfo info = FindByOrderNo(orderNo, trans); if (info != null) { result = new SellInfo(); result.Amount = info.Amount; result.AttachGUID = info.AttachGUID; result.Conatct_ID = info.Conatct_ID; result.Contact = info.Contact; result.ContactMobile = info.ContactMobile; result.ContactPhone = info.ContactPhone; result.Customer_ID = info.Customer_ID; result.DiscountAmount = info.DiscountAmount; result.DiscountNote = info.DiscountNote; result.Note = info.Note; result.Operator = info.Operator; result.OrderDate = info.OrderDate; //result.OrderStatus = info.OrderStatus; //报价单的状态和销售单不同,不能复制过去 result.Quantity = info.Quantity; result.ReceivedMoney = info.ReceivedMoney; result.Creator = info.Editor; result.Operator = info.Operator; result.CreateTime = DateTime.Now; result.Editor = info.Editor; result.EditTime = DateTime.Now; result.Company_ID = info.Company_ID; result.Dept_ID = info.Dept_ID; result.OrderDate = DateTime.Now; result.OrderNo = BLLFactory <Sell> .Instance.GetOrderNo(userId); //生成订单编号 result.Note = info.HandNo; //备注为报价单 //更新报价单状态 info.OrderStatus = "已生成订单"; baseDal.Update(info, info.ID, trans); } return(result); }
/// <summary> /// 把报价单转换为销售订单 /// </summary> /// <param name="quotationNo">报价单编号</param> /// <returns></returns> public bool ConvertToOrder(string orderNo, int userId) { bool result = false; DbTransaction trans = baseDal.CreateTransaction(); if (trans != null) { SellInfo sellInfo = ConvertSellInfo(orderNo, userId, trans); List <OrderDetailInfo> detailList = new List <OrderDetailInfo>(); if (sellInfo != null) { detailList = ConvertOrderDetal(sellInfo, orderNo, trans); } bool success = BLLFactory <Sell> .Instance.Insert(sellInfo, trans); if (success) { foreach (OrderDetailInfo info in detailList) { BLLFactory <OrderDetail> .Instance.Insert(info, trans); } } try { trans.Commit(); result = true; } catch { trans.Rollback(); throw;//重新抛出异常 } } return(result); }
public PlaceOrderResult PlaceOrder(SellInfo Info) { var repo = new Order(); var result = new Order().TX_Order(1, Info.ToXml()) ?? new XElement("default"); var orderID = result.LongValueOf("order_id"); var success = !repo.IsError && result.BooleanValueOf("is_successfull") == true && orderID.HasValue; if (success) { return(new PlaceOrderResult(true, new Ticket().GetByOrderID(orderID.Value))); } if (result.BooleanValueOf("tickets_already_bought") == true) { return(new PlaceOrderResult(false, errors: Resources.ErrorDuplicateTicket)); } if (result.BooleanValueOf("tickets_already_reserved") == true) { return(new PlaceOrderResult(false, errors: Resources.ErrorSeatReserved)); } if (result.BooleanValueOf("voucher_invalid") == true) { var nonExistent = result.Children("non_existent_vouchers", "non_existent_voucher") .Select(x => x.ValueOf("code")) .ToList(); var used = result.Children("used_vouchers", "used_voucher") .Select(x => x.ValueOf("code")) .ToList(); return(new PlaceOrderResult(false, null, nonExistent.Any() ? string.Format(Resources.ErrorVoucherNotExists, nonExistent.JoinStrings(", ")) : "", used.Any() ? string.Format(Resources.ErrorVoucherUsed, used.JoinStrings(", ")) : "")); } return(new PlaceOrderResult(false, null, string.IsNullOrWhiteSpace(repo.ErrorMessage) ? Resources.ErrorGeneral : repo.ErrorMessage)); }
private List <OrderDetailInfo> ConvertOrderDetal(SellInfo sellInfo, string orderNo, DbTransaction trans = null) { List <OrderDetailInfo> list = new List <OrderDetailInfo>(); List <QuotationDetailInfo> quotationList = BLLFactory <QuotationDetail> .Instance.FindByOrderNo(orderNo, trans); foreach (QuotationDetailInfo quotationInfo in quotationList) { OrderDetailInfo info = new OrderDetailInfo(); info.BarCode = quotationInfo.BarCode; info.Color = quotationInfo.Color; info.Conatct_ID = quotationInfo.Conatct_ID; info.Customer_ID = quotationInfo.Customer_ID; info.Editor = quotationInfo.Editor; info.EditTime = DateTime.Now; info.ExpireDate = quotationInfo.ExpireDate; info.MaterialCode = quotationInfo.MaterialCode; info.Model = quotationInfo.Model; info.Note = quotationInfo.Note; info.OrderNo = sellInfo.OrderNo;// info.PinyinCode = quotationInfo.PinyinCode; info.Product_ID = quotationInfo.Product_ID; info.ProductName = quotationInfo.ProductName; info.ProductNo = quotationInfo.ProductNo; info.ProductSize = quotationInfo.ProductSize; info.ProductType = quotationInfo.ProductType; info.Quantity = quotationInfo.Quantity; info.SalePrice = quotationInfo.SalePrice; info.Specification = quotationInfo.Specification; info.SubAmout = quotationInfo.SubAmout; info.Unit = quotationInfo.Unit; list.Add(info); } return(list); }
public CheckCampaignsResult ApplicableCampaigns(SellInfo Info) { return(TryToReturn(() => { #region Prepare xml string xml; var serializer = new XmlSerializer(typeof(SellInfo)); var strm = new MemoryStream(); serializer.Serialize(strm, Info); strm.Seek(0, SeekOrigin.Begin); using (var reader = new StreamReader(strm)) { xml = reader.ReadToEnd(); } var doc = XDocument.Parse(xml); #endregion var db = ConnectionFactory.GetDBCMDataContext(); var result = db.List_ApplicableCampaigns(doc.Root).Select(R => new Campaign { ID = R.CampaignID, Name = R.Name, Description = R.Description, ApplicableActions = R.ApplicableActions }).ToList(); Info.Tickets.ForEach(t => t.PriceAlteration = 0); result.ForEach(c => { ParseAppliedActions(c.ApplicableActions, ref c); c.Tickets.ForEach(t2 => { var ticket = Info.Tickets.FirstOrDefault(t => t.ScheduleID == t2.ScheduleID && t.SeatID == t2.SeatID); if (ticket != null) { ticket.PriceAlteration += t2.PriceAlteration; } }); c.UserCards.ForEach(uc => { var userCard = Info.UserCards.FirstOrDefault(card => card.CardNumber == uc.CardNumber); if (userCard != null) { userCard.PriceAlteration += uc.PriceAlteration; } }); }); var pricesResult = db.GetItemsPrice(doc.Root); var pricesInfo = new Campaign(); ParseAppliedActions(pricesResult, ref pricesInfo); var j = 1; result.ForEach(r => r.Number = j++); Info.Tickets.ForEach(t => { var item = pricesInfo.Tickets.FirstOrDefault(t2 => (t2.ScheduleID == t.ScheduleID) && (t2.SeatID == t.SeatID)); if (item != null) { t.Price = item.Price; } }); Info.Goods.ForEach(g => { var item = pricesInfo.Goods.FirstOrDefault(g2 => g2.GoodsID == g.GoodsID); if (item != null) { g.Price = item.Price; } }); Info.UserCards.ForEach(uc => { var item = pricesInfo.UserCards.FirstOrDefault(card => card.CardNumber == uc.CardNumber); if (item != null) { uc.Price = item.Price; } }); return new CheckCampaignsResult { Campaigns = result, Items = Info }; }, Logger: string.Format("ApplicableCampaigns(Info = {0})", Info))); }
public Task <CheckCampaignsResult> CheckCampaigns(SellInfo Info) { return(InvokeRemoteMethod <CheckCampaignsResult>(Args: Info)); }
public Task <PlaceOrderResult> PlaceOrder(SellInfo Info) { return(InvokeRemoteMethod <PlaceOrderResult>(Args: Info)); }
public HttpResponseMessage PutAway(string pdid, string describe) { var productinfo = this._iProductInfoService.Where(o => o.PdId.ToString() == pdid).FirstOrDefault(); if (productinfo == null) return JsonHelp.GetJsonContent(0, "尝试上架的商品在库中并未找到"); SellInfo sellInfo = new SellInfo { SellId = Guid.NewGuid(), PdId = Guid.Parse(pdid), PutawayTime = DateTime.Now, Describe = describe, SubTime = DateTime.Now }; // 缓存 this._RedisCache.Set(sellInfo.SellId.ToString(), Mapper.Map<DataSellInfo>(sellInfo)); return this._iSellInfoService.Add(sellInfo) ? JsonHelp.GetJsonContent(200, "添加成功") : JsonHelp.GetJsonContent(0, "添加失败"); }
public CheckCampaignsResult CheckCampaigns(SellInfo Info) { return(new Campaign().ApplicableCampaigns(Info)); }
protected void SaveLinkButton_OnClick(object sender, EventArgs e) { var returnType = Convert.ToInt32(ReturnType.SelectedItem.Value); var returnAmount = ReturnAmount.Number; var model = new SellInfo { TotalCashback = returnAmount, IsCashBack = returnType == 1, ReturnOrderID = _orderID, OperatorStockID = _operatorStockID }; model.Goods = new List <SellGoodInfo>(); model.Tickets = new List <SellTicketsInfo>(); for (int i = 0; i < OrderDetailsGrid.VisibleRowCount; i++) { var returnQuanityControl = (OrderDetailsGrid.FindRowCellTemplateControl(i, OrderDetailsGrid.Columns[9] as GridViewDataColumn, "ReturnQuantity") as ASPxSpinEdit); var returnQuantity = Convert.ToInt32(returnQuanityControl.Value.ToString()); var goodsID = OrderDetailsGrid.GetRowValues(i, "GoodsID"); var ticketID = OrderDetailsGrid.GetRowValues(i, "TicketID"); var isGoods = (OrderDetailsGrid.GetRowValues(i, "IsGoods").ToString().ToLower() == "true"); if (returnQuantity > 0) { if (isGoods) { model.Goods.Add(new SellGoodInfo { GoodsID = int.Parse(goodsID.ToString()), Count = returnQuantity }); } else { model.Tickets.Add(new SellTicketsInfo { TicketID = int.Parse(ticketID.ToString()) }); } } } var xsSubmit = new XmlSerializer(typeof(SellInfo)); var sww = new StringWriter(); xsSubmit.Serialize(XmlWriter.Create(sww), model); var xml = sww.ToString(); var order = new Order(); order.TX_Order(4, xml); if (order.IsError) { HeaderHF.Text = string.Format("<script>alert('{0}');</script>", order.ErrorMessage); } else { HeaderHF.Text = @"<script>Utilities.ClosePopup(0);</script>"; } }