private void cmbT2Copy_SelectedValueChanged(object sender, EventArgs e) { string strT2Rate = this.txtT2Rate.Text; string strComRate = this.txtComRate.Text; this.dT2Rate = Commons.ReadDouble(strT2Rate) / 100; this.dComRate = Commons.ReadDouble(strComRate) / 100; if (dT2Rate == 0 || dComRate == 0) { return; } Objects.T2Product item = (Objects.T2Product)cmbT2Copy.SelectedItem; Objects.Item target = CEVEMarketFile.lstItem.Find(obj => obj.Name == item.Name); Dictionary <string, Price> dicResult = CEVEMarketAPI.SearchPriceJson(new List <string>() { target.TypeID }); this.lblTargetSell.Text = strBaseSellPrice + string.Format("{0:C}", dicResult[target.TypeID].sell.min * item.Volume).Trim('¥'); if (item != null) { lvBase.Items.Clear(); double dPriceSumBase = 0; foreach (string strKey in item.Items.Keys) { ListViewItem li = new ListViewItem(strKey); li.UseItemStyleForSubItems = false; //材料效率减免 int nItem = (int)Math.Ceiling(item.Items[strKey] * (1 - dT2Rate)); li.SubItems.Add(string.Format("{0:N}", nItem)); lvBase.Items.Add(li); //价格查询 target = CEVEMarketFile.lstItem.Find(obj => obj.Name == strKey); dicResult = CEVEMarketAPI.SearchPriceJson(new List <string>() { target.TypeID }); dPriceSumBase += nItem * dicResult[target.TypeID].sell.min; } this.lblBuyPrice0.Text = strBuyPrice + string.Format("{0:C}", dPriceSumBase).Trim('¥'); DoCalComponentCost(); } }
private static void OutputBluePrintResult(Excel.IXLWorksheet xLSheet, string strKeyWord, ref int nRow, ref int nCol) { BluePrint bluePrint = lstBluePrint.Find(Item => Item.BPName == strKeyWord || Item.ProductName == strKeyWord); if (bluePrint == null) { return; } //价格查询 List <string> lstSearch = new List <string>(); lstSearch.Add(bluePrint.ProductID.ToString()); foreach (BluePrintMtls Mtls in bluePrint.Materials) { lstSearch.Add(Mtls.TypeID.ToString()); } Dictionary <string, Price> dicResult = CEVEMarketAPI.SearchPriceJson(lstSearch); xLSheet.Cell(nRow, nCol).Value = "产物"; xLSheet.Cell(nRow, nCol + 1).Value = "流程产量"; xLSheet.Cell(nRow, nCol + 2).Value = "流程数"; xLSheet.Cell(nRow, nCol + 3).Value = "物品ID"; xLSheet.Cell(nRow, nCol + 4).Value = "卖单价"; xLSheet.Cell(nRow, nCol + 5).Value = "收单价"; nRow++; xLSheet.Cell(nRow, nCol).Value = bluePrint.ProductName; xLSheet.Cell(nRow, nCol + 1).Value = bluePrint.ProductQty; xLSheet.Cell(nRow, nCol + 2).Value = 1; xLSheet.Cell(nRow, nCol + 3).Value = bluePrint.ProductID; //double dMtlsSell = dicResult[Mtls.TypeID.ToString()].sell.min * Math.Ceiling(dQty); xLSheet.Cell(nRow, nCol + 4).Value = dicResult[bluePrint.ProductID.ToString()].sell.min; xLSheet.Cell(nRow, nCol + 5).Value = dicResult[bluePrint.ProductID.ToString()].buy.max; nRow++; xLSheet.Cell(nRow, nCol).Value = "材料"; xLSheet.Cell(nRow, nCol + 1).Value = "需求量"; xLSheet.Cell(nRow, nCol + 2).Value = "总需求量"; xLSheet.Cell(nRow, nCol + 3).Value = "物品ID"; xLSheet.Cell(nRow, nCol + 4).Value = "卖单价"; xLSheet.Cell(nRow, nCol + 5).Value = "收单价"; nRow++; List <string> lstNext = new List <string>(); foreach (BluePrintMtls Mtls in bluePrint.Materials) { lstNext.Add(Mtls.Name); xLSheet.Cell(nRow, nCol).Value = Mtls.Name; xLSheet.Cell(nRow, nCol + 1).Value = Mtls.Qty; xLSheet.Cell(nRow, nCol + 2).Value = Mtls.Qty; xLSheet.Cell(nRow, nCol + 3).Value = Mtls.TypeID; xLSheet.Cell(nRow, nCol + 4).Value = dicResult[Mtls.TypeID.ToString()].sell.min; xLSheet.Cell(nRow, nCol + 5).Value = dicResult[Mtls.TypeID.ToString()].buy.max; nRow++; } nRow++; foreach (string strNextName in lstNext) { OutputBluePrintResult(xLSheet, strNextName, ref nRow, ref nCol); } return; }
private void DoCalLowerCost() { lvMoon.Items.Clear(); //材料列表 List <Objects.SearchingItem> lstOthers = new List <Objects.SearchingItem>(); Objects.SearchingItem FuelC = new Objects.SearchingItem(); FuelC.Name = "氮燃料块"; lstOthers.Add(FuelC); Objects.SearchingItem FuelA = new Objects.SearchingItem(); FuelA.Name = "氦燃料块"; lstOthers.Add(FuelA); Objects.SearchingItem FuelG = new Objects.SearchingItem(); FuelG.Name = "氧燃料块"; lstOthers.Add(FuelG); Objects.SearchingItem FuelM = new Objects.SearchingItem(); FuelM.Name = "氢燃料块"; lstOthers.Add(FuelM); //组件列表 foreach (ListViewItem Target in lvLower.Items) { Objects.Reaction reaction = this.lstLowerReaction.Find(X => { return(X.Name == Target.Text); }); if (reaction != null) { //有反应配方 foreach (string strKey in reaction.Input.Keys) { Objects.SearchingItem item = lstOthers.Find(X => { return(X.Name == strKey); }); if (item != null) { //item.Volume += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text) / reaction.Output * reaction.Input[strKey]); item.Volume += (int)(ReadDouble(Target.SubItems[2].Text) * reaction.Input[strKey]); } else { item = new Objects.SearchingItem(); item.Name = strKey; //item.Volume = (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text) / reaction.Output * reaction.Input[strKey]); item.Volume += (int)(ReadDouble(Target.SubItems[2].Text) * reaction.Input[strKey]); lstOthers.Add(item); } } } else { //无反应配方 Objects.SearchingItem item = lstOthers.Find(X => { return(X.Name == Target.Text); }); if (item != null) { item.Volume += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text)); } else { item = new Objects.SearchingItem(); item.Name = Target.Text; item.Volume = (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text)); lstOthers.Add(item); } } } double dPriceSumMoon = 0; foreach (Objects.SearchingItem Result in lstOthers) { ListViewItem li = new ListViewItem(Result.Name); li.UseItemStyleForSubItems = false; li.SubItems.Add(string.Format("{0:N}", Result.Volume)); lvMoon.Items.Add(li); //价格查询 Objects.Item target = CEVEMarketFile.lstItem.Find(obj => obj.Name == Result.Name); Dictionary <string, Price> dicResult = CEVEMarketAPI.SearchPriceJson(new List <string>() { target.TypeID }); dPriceSumMoon += Result.Volume * dicResult[target.TypeID].sell.min; } this.lblBuyPrice3.Text = strBuyPrice + string.Format("{0:C}", dPriceSumMoon).Trim('¥'); }
private void DoCalComponentCost() { lvHigher.Items.Clear(); //材料列表 List <Objects.SearchingItem> lstOthers = new List <Objects.SearchingItem>(); //组件列表 foreach (ListViewItem Target in lvBase.Items) { Objects.Reaction reaction = this.lstT2ComponentReaction.Find(X => { return(X.Name == Target.Text); }); if (reaction != null) { //有反应配方 foreach (string strKey in reaction.Input.Keys) { Objects.SearchingItem item = lstOthers.Find(X => { return(X.Name == strKey); }); if (item != null) { //材料个数 int nVol = (int)Math.Ceiling(reaction.Input[strKey] * (1 - dComRate) * ReadDouble(Target.SubItems[1].Text)); //每流程一个的材料不可缩减 item.Volume += nVol < ReadDouble(Target.SubItems[1].Text) ? (int)ReadDouble(Target.SubItems[1].Text) : nVol; item.Size += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text) / reaction.Output); } else { item = new Objects.SearchingItem(); item.Name = strKey; //材料个数 int nVol = (int)Math.Ceiling(reaction.Input[strKey] * (1 - dComRate) * ReadDouble(Target.SubItems[1].Text)); //每流程一个的材料不可缩减 item.Volume = nVol < ReadDouble(Target.SubItems[1].Text) ? (int)ReadDouble(Target.SubItems[1].Text) : nVol; item.Size += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text) / reaction.Output); lstOthers.Add(item); } } } else { //无反应配方 Objects.SearchingItem item = lstOthers.Find(X => { return(X.Name == Target.Text); }); if (item != null) { item.Volume += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text)); } else { item = new Objects.SearchingItem(); item.Name = Target.Text; item.Volume = (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text)); lstOthers.Add(item); } } } int nLineSum = 0; double dPriceSumHigher = 0; foreach (Objects.SearchingItem Result in lstOthers) { ListViewItem li = new ListViewItem(Result.Name); li.UseItemStyleForSubItems = false; li.SubItems.Add(string.Format("{0:N}", Result.Volume)); Objects.Reaction reaction = this.lstHigherReaction.Find(X => { return(X.Name == Result.Name); }); if (reaction != null) { int nLineNumHigher = (int)Math.Ceiling(Result.Volume / reaction.Output); li.SubItems.Add(string.Format("{0:N}", nLineNumHigher)); nLineSum += nLineNumHigher; } lvHigher.Items.Add(li); //价格查询 Objects.Item target = CEVEMarketFile.lstItem.Find(obj => obj.Name == Result.Name); Dictionary <string, Price> dicResult = CEVEMarketAPI.SearchPriceJson(new List <string>() { target.TypeID }); dPriceSumHigher += Result.Volume * dicResult[target.TypeID].sell.min; } this.lblBuyPrice1.Text = strBuyPrice + string.Format("{0:C}", dPriceSumHigher).Trim('¥'); this.lblLineSum1.Text = strLineSum + nLineSum.ToString(); DoCalHigherCost(); }