Ash_
Ash_
CC#
Created by Ash_ on 12/20/2022 in #help
❔ I need help with logic
Hey, i want to create a little algorithm that is able to calculate - via multiple criteria - the cheapest way to create a network cable. The criteria are these: the plug has a price, a category and a variable that says if it needs an additional cover or not, the cover itself has a price and the actual cable also has a price and a category, also the cable can be either for installation work or general use... Somehow i'd need to program it to be able to take all of these into consideration. as of now i only have a number that consists of the pagage size (e.g. 10) and the price (e.g. 10 bucks) for the price per used thing, but i can't just sort them from this because usually the more/longer things you use, the cheaper it gets... say i need ten meters of cable, i'd need 10 meters of actual cable, two plugs and maybe some covers, depending on if the plugs need some or not...
6 replies
CC#
Created by Ash_ on 12/15/2022 in #help
❔ shorter way to export a list to a csv?
Hey, i am searching for a quicker way to export a list to a csv with head than my solution under this, could anyone help me shorten this?
public static string AsCsv()
{
string filename = DateTime.Now.ToString(DateTime.Now.ToString("yyyy-MM-dd_HH:mm"))+"-Artikel.csv";
TextWriter tw = new StreamWriter("../../Exports/"+filename);
for (int i = -1; i < Auftrag.Auftragsliste.Count; i++)
{
if (i==-1)
{
_line = "GTIN" + Stringseperator + "Artikelnummer" + Stringseperator + "Bezeichnung"
+ Stringseperator + "Warengruppe" + Stringseperator + "Preis";
}
else
{
for (int j = 0; j < 5; j++)
{
switch (j)
{
case 0:
_gtin = Auftrag.Auftragsliste.ElementAt(i).Gtin;
break;
case 1:
_artikelnummer = Auftrag.Auftragsliste.ElementAt(i).Artikelnummer;
break;
case 2:
_bezeichnung = Auftrag.Auftragsliste.ElementAt(i).Bezeichnung;
break;
case 3:
_warengruppe = Auftrag.Auftragsliste.ElementAt(i).Warengruppe;
break;
case 4:
_preis = Auftrag.Auftragsliste.ElementAt(i).Preis;
break;
}
}
_line = _gtin + Stringseperator + _artikelnummer + Stringseperator + _bezeichnung + Stringseperator + _warengruppe + Stringseperator + _preis;
}
tw.WriteLine(_line);
}
tw.Close();
return filename;
}
public static string AsCsv()
{
string filename = DateTime.Now.ToString(DateTime.Now.ToString("yyyy-MM-dd_HH:mm"))+"-Artikel.csv";
TextWriter tw = new StreamWriter("../../Exports/"+filename);
for (int i = -1; i < Auftrag.Auftragsliste.Count; i++)
{
if (i==-1)
{
_line = "GTIN" + Stringseperator + "Artikelnummer" + Stringseperator + "Bezeichnung"
+ Stringseperator + "Warengruppe" + Stringseperator + "Preis";
}
else
{
for (int j = 0; j < 5; j++)
{
switch (j)
{
case 0:
_gtin = Auftrag.Auftragsliste.ElementAt(i).Gtin;
break;
case 1:
_artikelnummer = Auftrag.Auftragsliste.ElementAt(i).Artikelnummer;
break;
case 2:
_bezeichnung = Auftrag.Auftragsliste.ElementAt(i).Bezeichnung;
break;
case 3:
_warengruppe = Auftrag.Auftragsliste.ElementAt(i).Warengruppe;
break;
case 4:
_preis = Auftrag.Auftragsliste.ElementAt(i).Preis;
break;
}
}
_line = _gtin + Stringseperator + _artikelnummer + Stringseperator + _bezeichnung + Stringseperator + _warengruppe + Stringseperator + _preis;
}
tw.WriteLine(_line);
}
tw.Close();
return filename;
}
84 replies
CC#
Created by Ash_ on 11/12/2022 in #help
❔ How do i sort a list of objects by multiple possible items
Hey, i'm trying to write a method to return a list of objects by letting the user choose which item of the object they want it sorted by, code follows
40 replies
CC#
Created by Ash_ on 10/30/2022 in #help
troubles with a simple list...
Hey, i've created - or at least tried to create a list with entries but it only saves "Warenspeichersystem.Artikel"... here's the code: https://pastebin.com/rrQ34eLR , what did i do wrong?
8 replies
CC#
Created by Ash_ on 9/13/2022 in #help
How do i create a external file containing previously entered strings?
My program (a gtin verifier) asks the user to enter a gtin, which it saves as a string. After that the Method returns a true or false, depending on if the code is valid or not. for efficiency's sake i want it to save every input of the user and the true/false result to a file so if someone enters a code that was already calculated it just reads the result from the file instead of having to acutally calculate it, i'll send the code in a bit
55 replies