public static EVEItem QueryInventory(EVEItem item) { var cmd = con_store.CreateCommand(); cmd.CommandText = "SELECT * FROM store WHERE id = @type"; cmd.Parameters.AddWithValue("@type", item.typeID); var reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); var number = reader.GetInt32(1); var price = reader.GetInt32(2); item.number = number; item.price = price; reader.Close(); return(item); } else { reader.Close(); return(null); } }
public static List <EVEItem> QueryBlueprintProductionMaterials(int typeID) { var cmd = con.CreateCommand(); cmd.CommandText = "SELECT typeID,quantity FROM blueprint_material WHERE id = @type AND activityType = 2"; cmd.Parameters.AddWithValue("@type", typeID); var reader = cmd.ExecuteReader(); if (reader.HasRows) { List <EVEItem> itemList = new List <EVEItem>(); while (reader.Read()) { var item = new EVEItem(); item.typeID = reader.GetInt32(0); item.request_quantity = reader.GetInt32(1); item.name = QueryName(item.typeID); QueryInventory(item); itemList.Add(item); } reader.Close(); return(itemList); } else { reader.Close(); return(null); } }
public static List <EVEItem> QueryAllInventory() { var cmd = con_store.CreateCommand(); cmd.CommandText = "SELECT * FROM store"; var reader = cmd.ExecuteReader(); if (reader.HasRows) { List <EVEItem> itemList = new List <EVEItem>(); while (reader.Read()) { var item = new EVEItem(); item.typeID = reader.GetInt32(0); item.number = reader.GetInt32(1); item.price = reader.GetInt32(2); item.name = reader.GetString(3); itemList.Add(item); } reader.Close(); return(itemList); } else { reader.Close(); return(null); } }
public static void UpdateInventoryNumber(EVEItem item) { var cmd = con_store.CreateCommand(); cmd.CommandText = "Update store SET number = @number WHERE id = @type"; cmd.Parameters.AddWithValue("@type", item.typeID); cmd.Parameters.AddWithValue("@number", item.number); var reader = cmd.ExecuteReader(); return; }
private void Production_Click(object sender, EventArgs e) { Production_Materials_List.BeginUpdate(); int index = 0; foreach (ListViewItem item in Production_Materials_List.Items) { EVEItem eveItem = Production_Materials_EVEList[index]; DataManager.QueryInventory(eveItem); eveItem.number = eveItem.number - int.Parse(item.SubItems[1].Text); DataManager.UpdateInventoryNumber(eveItem); index++; } Production_Materials_List.EndUpdate(); DataManager.EnterInventory(Production_Blueprint.targetID, int.Parse(Production_Number.Text), int.Parse(Production_SingleCost.Text.Replace(",", "")), Production_Blueprint.targetName); updateBlueprintInfo(); }
private void updateInventoryItem(EVEItem item) { item = DataManager.QueryInventory(item); InventoryCost.Text = item.price.ToString("###,###"); InventoryNumber.Text = item.number.ToString(); }
private void updateBlueprintInfo() { Production_Materials_List.BeginUpdate(); int index = 0; int outNumber = 0; int production_Number = 1; int save = 0; float cost = 0; bool canProduction = true; if (int.TryParse(Production_Number.Text, out outNumber)) { if (outNumber == 0) { outNumber = 1; } production_Number = outNumber; } if (int.TryParse(Production_BlueprintSave.Text, out outNumber)) { save += outNumber; } if (int.TryParse(Production_BuildingsSave.Text, out outNumber)) { save += outNumber; } if (int.TryParse(Production_BlueprintCost.Text, out outNumber)) { cost += outNumber; } if (int.TryParse(Production_InventCost.Text, out outNumber)) { cost += outNumber; } if (int.TryParse(Production_BuildingsCost.Text, out outNumber)) { cost += outNumber; } cost = cost / production_Number; foreach (ListViewItem item in Production_Materials_List.Items) { EVEItem eveItem = Production_Materials_EVEList[index]; DataManager.QueryInventory(eveItem); int number = (int)Math.Round(eveItem.request_quantity * ((100 - save) * 0.01f)); float market_price = PriceService.GetPrice(eveItem.typeID).sell.min; item.SubItems[1].Text = (number * production_Number).ToString(); item.SubItems[2].Text = (eveItem.number).ToString(); if (number * production_Number > eveItem.number) { item.ForeColor = Color.Red; canProduction = false; } else { item.ForeColor = Color.Black; } item.SubItems[3].Text = (eveItem.price).ToString(); item.SubItems[4].Text = (market_price).ToString(); if (eveItem.number > 0) { cost += number * eveItem.price; } else { cost += number * market_price; } index++; } Production_Materials_List.EndUpdate(); var priceS = PriceService.GetPrice(Production_Blueprint.targetID); float sell = priceS.sell.min; float buy = priceS.buy.max; Production_SingleCost.Text = cost.ToString("###,###"); Production_Cost.Text = (cost * production_Number).ToString("###,###"); Production_Sell.Text = sell.ToString("###,###"); Production_Buy.Text = buy.ToString("###,###"); Production_SingleProfit.Text = (sell - cost).ToString("###,###"); Production_Profit.Text = ((sell - cost) * production_Number).ToString("###,###"); Production.Enabled = canProduction; }