public TownMerchant(CommodityList commodities) : base(basisparam) { Commodities = commodities; initTalkAction(); //Controller.AI = new NonActionAI(Controller); }
public void ExportTest() { //客户 Customer customer1 = new Customer(20181123, "Tom"); Customer customer2 = new Customer(20185462, "Bob"); Customer customer3 = new Customer(20184762, "Cindy"); //添加几种商品 CommodityList.AddCommodity(new Commodity("pencil", 1)); CommodityList.AddCommodity(new Commodity("pen", 10)); CommodityList.AddCommodity(new Commodity("cellPhone", 1000)); //订单明细实例,由商品组成 OrderDetail orderDetails1 = new OrderDetail(CommodityList.commodities[0], 10); OrderDetail orderDetails2 = new OrderDetail(CommodityList.commodities[1], 5); OrderDetail orderDetails3 = new OrderDetail(CommodityList.commodities[2], 15); //实列化订单 Order order1 = new Order(1, customer1); Order order2 = new Order(2, customer2); Order order3 = new Order(3, customer3); order1.AddCommodity(orderDetails1); order2.AddCommodity(orderDetails1); order2.AddCommodity(orderDetails2); order3.AddCommodity(orderDetails3); OrderService os = new OrderService(); os.AddOrder(order1); os.AddOrder(order2); os.AddOrder(order3); }
/// <summary> /// Commodity controls are created and deleted dynamically therefore these controls /// are binded through different class called CommoditiesEntryModel. /// Each row of controls has new instance of EntryModel class. /// Every new commodity is added to CommodityList /// </summary> /// <param name="parameter"></param> private void _AddNewCommodity(object parameter) { CommoditiesEntryViewModel CommView = new CommoditiesEntryViewModel(); CommView.CombList = _VList; CommView.ParentList = CommodityList; CommodityList.Add(CommView); }
public OpenShopMenu(CommodityList commodities) : base(new ShopMenu(),true,true) { Commodities = commodities; PlayerSellMode = false; doneOpen = false; //IsOperationExit = delegate { return false; }; }
public void GetByCommodityNameTest() { //客户 Customer customer1 = new Customer(20181123, "Tom"); Customer customer2 = new Customer(20185462, "Bob"); Customer customer3 = new Customer(20184762, "Cindy"); //添加几种商品 CommodityList.AddCommodity(new Commodity("pencil", 1)); CommodityList.AddCommodity(new Commodity("pen", 10)); CommodityList.AddCommodity(new Commodity("cellPhone", 1000)); //订单明细实例,由商品组成 OrderDetail orderDetails1 = new OrderDetail(CommodityList.commodities[0], 10); OrderDetail orderDetails2 = new OrderDetail(CommodityList.commodities[1], 5); OrderDetail orderDetails3 = new OrderDetail(CommodityList.commodities[2], 15); //实列化订单 Order order1 = new Order(1, customer1); Order order2 = new Order(2, customer2); Order order3 = new Order(3, customer3); order1.AddCommodity(orderDetails1); order2.AddCommodity(orderDetails1); order2.AddCommodity(orderDetails2); order3.AddCommodity(orderDetails3); OrderService os = new OrderService(); os.AddOrder(order1); os.AddOrder(order2); os.AddOrder(order3); List <Order> orders = os.GetByCommodityName("pencil"); foreach (Order order0 in orders) { bool value = false; foreach (OrderDetail orderDetail in order0.OrderDetailsList) { if (orderDetail.Commodity.Name == "pencil") { value = true; } break; } if (value == false) { Assert.Fail(); } } }
public void init() { //客户 Customer customer1 = new Customer(20181123, "Tom", 13597585641); Customer customer2 = new Customer(20185462, "Bob", 14358887627); Customer customer3 = new Customer(20184762, "Cindy", 18976651626); //添加几种商品 CommodityList.AddCommodity(new Commodity("pencil", 1, 001)); CommodityList.AddCommodity(new Commodity("pen", 10, 002)); CommodityList.AddCommodity(new Commodity("cellPhone", 1000, 003)); CommodityList.AddCommodity(new Commodity("pants", 100, 004)); CommodityList.AddCommodity(new Commodity("skirt", 150, 005)); //订单明细实例,由商品组成 OrderDetail orderDetails1 = new OrderDetail(CommodityList.commodities[0], 10); OrderDetail orderDetails2 = new OrderDetail(CommodityList.commodities[1], 5); OrderDetail orderDetails3 = new OrderDetail(CommodityList.commodities[2], 15); OrderDetail orderDetails4 = new OrderDetail(CommodityList.commodities[3], 6); OrderDetail orderDetails5 = new OrderDetail(CommodityList.commodities[4], 9); //实列化订单 Order order1 = new Order(20180412665, customer1); Order order2 = new Order(20161206238, customer1); Order order3 = new Order(20181115125, customer2); order1.AddCommodity(orderDetails1); order1.AddCommodity(orderDetails2); order2.AddCommodity(orderDetails2); order2.AddCommodity(orderDetails4); order3.AddCommodity(orderDetails3); order3.AddCommodity(orderDetails5); orderService = new OrderService(); //添加订单 orderService.AddOrder(order1); orderService.AddOrder(order2); orderService.AddOrder(order3); this.orderBindingSource.DataSource = orderService.queryAllOrders(); }
public void GetByCustomerNameTest() { //客户 Customer customer1 = new Customer(20181123, "Tom"); Customer customer2 = new Customer(20185462, "Bob"); Customer customer3 = new Customer(20184762, "Cindy"); //添加几种商品 CommodityList.AddCommodity(new Commodity("pencil", 1)); CommodityList.AddCommodity(new Commodity("pen", 10)); CommodityList.AddCommodity(new Commodity("cellPhone", 1000)); //订单明细实例,由商品组成 OrderDetail orderDetails1 = new OrderDetail(CommodityList.commodities[0], 10); OrderDetail orderDetails2 = new OrderDetail(CommodityList.commodities[1], 5); OrderDetail orderDetails3 = new OrderDetail(CommodityList.commodities[2], 15); //实列化订单 Order order1 = new Order(1, customer1); Order order2 = new Order(2, customer2); Order order3 = new Order(3, customer3); order1.AddCommodity(orderDetails1); order2.AddCommodity(orderDetails1); order2.AddCommodity(orderDetails2); order3.AddCommodity(orderDetails3); OrderService os = new OrderService(); os.AddOrder(order1); os.AddOrder(order2); os.AddOrder(order3); List <Order> orders = os.GetByCustomerName(customer1.Name); foreach (Order order in orders) { Assert.AreEqual(order.Customer.Name, customer1.Name); } }
private void _OpenDefaultGraph() { string[] lines = null; // Create an open file dialog box and only show *.grf files. try { OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Filter = "Graph File |*.grf"; //read all lines of file if (true == openDlg.ShowDialog()) { lines = File.ReadAllLines(openDlg.FileName); _openedFileName = openDlg.FileName; Graph = new NetGraph(true); //following block of code try to read the file and create graph // to fully understant this code please read the graph file in notepad string[] IDs = lines[0].Split(','); foreach (string id in IDs) { int currID = int.Parse(id); _VList.Add(currID); Graph.AddVertex(new NetVertex(currID)); } _IDCount = _VList.Count; string[] edges = lines[1].Split(','); string[] temp; int idTo, idFrom; int from = 0, to = 0; int count = Graph.VertexCount; foreach (string part in edges) { temp = part.Split('-'); idFrom = int.Parse(temp[0]); idTo = int.Parse(temp[1]); for (int i = 0; i < count; i++) { if (Graph.Vertices.ElementAt(i).ID == idFrom) { from = i; } if (Graph.Vertices.ElementAt(i).ID == idTo) { to = i; } } // _AddNewGraphEdge(_existingVertices[--idTo], _existingVertices[--idFrom]); _AddNewGraphEdge(Graph.Vertices.ElementAt(from), Graph.Vertices.ElementAt(to)); } string[] commodities = lines[2].Split(','); if (commodities.Length > 0) { CommodityList.RemoveAt(0); } foreach (string part in commodities) { temp = part.Split('-'); from = int.Parse(temp[0]); to = int.Parse(temp[1]); if (from != to) { CommoditiesEntryViewModel cvm = new CommoditiesEntryViewModel(); cvm.OriginID = from; cvm.DestinationID = to; cvm.DemandVal = int.Parse(temp[2]); cvm.CombList = _VList; cvm.ParentList = CommodityList; CommodityList.Add(cvm); } } NotifyPropertyChanged("Graph"); } } catch (IOException e) { ExceptionMessage.Show("Could Not Open File\n" + e.ToString()); Graph = null; } catch (Exception ex) { ExceptionMessage.Show("Something wrong with the Data in the File\n" + ex.ToString()); Graph = null; } }
/// <summary> /// This method takes graph file data for networkx graph and /// creates vertexes, edges. It also creates random commodities with /// valid paths. /// </summary> /// <param name="lines">graph file text</param> private void _DrawGraphWithCommodities(string [] lines) { int CommodityNum = this._NumberOfCommoditiesVal; int MinComm = this._MinimumDemandVal; int MaxComm = this._MaximumDemandVal + 1; int nodeID = 0; bool CommoditySet = false; List <int> Origins = new List <int>(); List <int> Destinations = new List <int>(); List <float> Demands = new List <float>(); int OriginID = 0, DestID = 0; float demand = 0; SortedSet <int> nodeList = new SortedSet <int>(); // HashSet<int> nodeList = new HashSet<int>(); HashSet <int> edgeOutNodes = new HashSet <int>(); Random random = new Random(); Dictionary <int, LinkedList <int> > EdgeMap = new Dictionary <int, LinkedList <int> >(); Graph = new NetGraph(true); try { foreach (string line in lines) //create and add vertex to the graph { string[] IDs = line.Split(' '); if (int.TryParse(IDs[0], out nodeID)) { foreach (string id in IDs) { int currID = int.Parse(id); if (nodeList.Add(currID)) { // _VList.Add(currID); Graph.AddVertex(new NetVertex(currID)); } } } } for (int i = 0; i < nodeList.Count; i++) { _VList.Add(nodeList.ElementAt(i)); } this._IDCount = this._VList.Count(); int from = 0, to = 0, curID = 0; int count = Graph.VertexCount; bool valid = true; //create edges, and keep record of vertex with edges going out for each valid vertex foreach (string line in lines) { string[] IDs = line.Split(' '); if (int.TryParse(IDs[0], out nodeID)) { EdgeMap.Add(nodeID, new LinkedList <int>()); for (int j = 1; j < IDs.Length; j++) { curID = int.Parse(IDs[j]); valid = true; if (EdgeMap.ContainsKey(curID)) { foreach (int id in EdgeMap[curID]) { if (id == nodeID) { valid = false; } } } if (valid) { edgeOutNodes.Add(nodeID); EdgeMap[nodeID].AddLast(curID); for (int i = 0; i < count; i++) { if (Graph.Vertices.ElementAt(i).ID == nodeID) { from = i; } if (Graph.Vertices.ElementAt(i).ID == curID) { to = i; } } this._AddNewGraphEdge(Graph.Vertices.ElementAt(from), Graph.Vertices.ElementAt(to)); } } } } //commodity is choosed at random, if that commodity does not already exist //check if it has valid path. if it exists then just add demand to it. for (int i = 0; i < _NumberOfCommoditiesVal; i++) { CommoditySet = false; while (!CommoditySet) { OriginID = random.Next(0, edgeOutNodes.Count); OriginID = edgeOutNodes.ElementAt(OriginID); DestID = random.Next(0, nodeList.Count); DestID = nodeList.ElementAt(DestID); demand = random.Next(MinComm, MaxComm); for (int j = 0; j < Origins.Count; j++) { if (Origins[j] == OriginID && Destinations[j] == DestID) { CommoditySet = true; Demands[j] += demand; break; } } if (CommoditySet) { break; } this._path = null; if (this._HasPath(OriginID, DestID, nodeList.Count, EdgeMap)) { // this._GetSimulationEdges(OriginID, DestID); Origins.Add(OriginID); Destinations.Add(DestID); Demands.Add(demand); CommoditySet = true; } } } if (Origins.Count > 0) { CommodityList.Remove(CommodityList.ElementAt(0)); } for (int i = 0; i < Origins.Count; i++) { CommoditiesEntryViewModel cvm = new CommoditiesEntryViewModel(); cvm.OriginID = Origins[i]; cvm.DestinationID = Destinations[i]; cvm.DemandVal = Demands[i]; cvm.CombList = _VList; cvm.ParentList = CommodityList; CommodityList.Add(cvm); } NotifyPropertyChanged("Graph"); } catch (Exception ex) { ExceptionMessage.Show("Something wrong with the Data in the File\n" + ex.ToString()); Graph = null; } }
public void init(MyCharacterController owner, PlayerController customer, CommodityList commoditylist, bool playersellmode = false) { WindowOwner = owner; PlayerSellMode = playersellmode; Customer = customer; CommodityList = commoditylist; if (PlayerSellMode) { // プレイヤが持ち物を売るとき initPlayerSellMode(); } else { // 販売 initNormalMode(); } MaxPageNum = (int)Mathf.Ceil(Commodities.Length / (float)Window.RowSize); CurrentPageNum = 0; Debug.LogFormat("C:{0} R:{1} P:{2}",Commodities.Length,Window.RowSize,MaxPageNum); setOnePageTexts(); clearMultiSelected(); Message = new MessageMenu(this.WindowOwner); }
/// <summary> /// Initializes a new instance of the <see cref="Home.Order"/> class. /// </summary> /// <param name="client">Client.</param> public Order(Client client) { //_commodities = new ArrayList (); _commodities = new CommodityList <Commodity> (); _client = client; }
/// <summary> /// 获取统计数据 /// </summary> /// <returns></returns> public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.totalNum> GetTotalListExt(Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO Search) { LogHelper.Debug("CommodityChangeBP.GetTotalListExt,入参:" + JsonHelper.JsonSerializer(Search)); try { var query = from m in Commodity.ObjectSet() join n in CommodityStock.ObjectSet() on m.Id equals n.CommodityId into CommodityList from com in CommodityList.DefaultIfEmpty() where Search.Appids.Contains(m.AppId) select new Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO { Id = com.Id, CommodityId = com.CommodityId, AppId = m.AppId, Barcode = com.Barcode, No_Code = com.No_Code, JDCode = com.JDCode, //备注编码 Name = m.Name, SubId = m.SubId, SubOn = com.SubTime, ModifiedId = m.ModifieId, ModifiedOn = com.ModifiedOn, State = m.State, IsDel = m.IsDel }; #region 查询条件 //根据供应商 if (Search.AppidsList.Count > 0) { query = query.Where(p => Search.AppidsList.Contains(p.AppId)); } //商铺名称 if (Search.AppId != Guid.Empty) { query = query.Where(p => p.AppId == Search.AppId); } //商品名称 if (!string.IsNullOrEmpty(Search.Name)) { query = query.Where(p => Search.Name.Contains(p.Name) || p.Name.Contains(Search.Name)); } //备注编码 if (!string.IsNullOrEmpty(Search.JDCode)) { query = query.Where(p => p.JDCode == Search.JDCode); } //商品条形码 if (!string.IsNullOrEmpty(Search.Barcode)) { query = query.Where(p => p.Barcode == Search.Barcode); } //发布人 if (Search.SubId != Guid.Empty) { query = query.Where(p => p.SubId == Search.SubId); } if (!string.IsNullOrEmpty(Search.SubStarTime)) { var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; StartTime = DateTime.Parse(Search.SubStarTime); query = query.Where(p => p.SubOn >= StartTime); } if (!string.IsNullOrEmpty(Search.SubEndTime)) { var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; EndTime = DateTime.Parse(Search.SubEndTime).AddDays(1); query = query.Where(p => p.SubOn <= EndTime); } if (Search.ModifiedId != Guid.Empty) { query = query.Where(p => p.ModifiedId == Search.ModifiedId); } if (!string.IsNullOrEmpty(Search.ModStarTime)) { var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; StartTime = DateTime.Parse(Search.ModStarTime); query = query.Where(p => p.ModifiedOn >= StartTime); } if (!string.IsNullOrEmpty(Search.ModEndTime)) { var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value; EndTime = DateTime.Parse(Search.ModEndTime).AddDays(1); query = query.Where(p => p.ModifiedOn <= EndTime); } if (Search.State != -1) { if (Search.State == 3) { //已删除的数据 query = query.Where(p => p.IsDel == true); } else { query = query.Where(p => p.State == Search.State && p.IsDel == false); } } #endregion totalNum num = new totalNum(); num.totalGoods = query.Count(); num.selling = query.Where(p => p.State == 0 && p.IsDel == false).Count(); num.soldout = query.Where(p => p.State == 1 && p.IsDel == false).Count(); num.isdel = query.Where(p => p.IsDel == true).Count(); List <totalNum> list = new List <totalNum>(); list.Add(num); return(list); } catch (Exception ex) { LogHelper.Error("CommodityChangeBP.GetTotalListExt异常", ex); } return(new List <totalNum>()); }