public void displayCells() { serialText.Text = lol.ItemID; imeText.Text = lol.ItemName; cenaText.Text = lol.Price.ToString(); List <string> row = new List <string>(); ItemsDatabase db = new ItemsDatabase(); if (lol.type == "Software") { SoftwareItem i = db.ReadSoftware(_code); row.Add(i.LicenseKey); row.Add(i.SizeInMB.ToString()); row.Add(i.version); } else if (lol.type == "Computer") { Computer c = db.ReadComputer(_code); row.Add(c.NoOfCores.ToString()); row.Add(c.AmountOfRam.ToString()); row.Add(c.HDDSize.ToString()); row.Add(c.weight.ToString()); } else if (lol.type == "Monitor") { Monitor m = db.ReadMonitor(_code); row.Add(m.weight.ToString()); row.Add(m.Resolution); row.Add(m.diag); row.Add(m.MonitorType); } dataGridView1.Rows.Add(row.ToArray()); }
private void button1_Click(object sender, EventArgs e) { string itemID = textBox1.Text; string itemName = textBox2.Text; double price; int sizeinmb = Convert.ToInt32(textBox5.Text); string licensekey = textBox4.Text; Double.TryParse(textBox3.Text, out price); SoftwareItem newItem = new SoftwareItem(itemID, itemName, price, licensekey, sizeinmb); itemsBaza db = new itemsBaza(); db.SaveSofwareItem(newItem); MessageBox.Show("Izdelek dodan"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; }
private void addButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(nameTextBox.Text) || string.IsNullOrWhiteSpace(codeTextBox.Text) || string.IsNullOrWhiteSpace(developerTextBox.Text) || string.IsNullOrWhiteSpace(priceTextBox.Text) || string.IsNullOrWhiteSpace(sizeTextBox.Text) || string.IsNullOrWhiteSpace(licenseTextBox.Text) || string.IsNullOrWhiteSpace(versionTextBox.Text)) { MessageBox.Show("You forgot to fill in all the boxes!"); } else { string Price = priceTextBox.Text + currencyComboBox.SelectedItem.ToString(); string Size = sizeTextBox.Text + memorySizeComboBox.SelectedIndex.ToString(); SoftwareItem newSotfwareItem = new SoftwareItem(nameTextBox.Text, codeTextBox.Text, developerTextBox.Text, Price, Size, licenseTextBox.Text, versionTextBox.Text); newSotfwareItem.addToDatabase(); int error = newSotfwareItem.addToDatabase(); if (error == 1) { MessageBox.Show("This object already exists within the database"); } if (error == 0) { MessageBox.Show("You succesfully added a new Program!"); } } }
public SoftwareResult(SoftwareItem item) : base() { Items.Add(new DirectoryItem(new string('*', item.Title.Length + 4))); Items.Add(new DirectoryItem("* " + item.Title + " *")); Items.Add(new DirectoryItem(new string('*', item.Title.Length + 4))); if (item.Screenshots != null) { foreach (var screenshot in item.Screenshots) { Items.Add(new DirectoryItem(ItemType.GIF, "Screenshot", "GIF:" + screenshot)); } } Items.AddRange(item.Description.WrapToDirectoryItems()); Items.Add(new DirectoryItem("")); Items.Add(new DirectoryItem("Downloads")); Items.Add(new DirectoryItem("=========")); foreach (var download in item.Downloads) { //Items.Add(new DirectoryItem(new string('-', download.Title.Length))); //Items.Add(new DirectoryItem(download.Title)); //Items.Add(new DirectoryItem(new string('-', download.Title.Length))); foreach (var link in download.Links) { Items.Add(new DirectoryItem(link.Text + ":")); Items.Add(new DirectoryItem(Core.Helpers.FileTypeHelpers.GetItemTypeFromFileName(link.Url), download.Title, "BIN:" + link.Url)); } Items.Add(new DirectoryItem("Filesize: " + download.Size)); Items.Add(new DirectoryItem("OS: " + download.Os)); Items.Add(new DirectoryItem("")); } }
private bool BeCompatibleWithSystem(SoftwareOrder order, SoftwareItem item) { if (item.Selected) { return(order.IsLegacySystem == item.IsLegacySoftware); } else { return(true); } }
private void softwareDataGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e) { ItemsDatabase db = new ItemsDatabase(); var row = softwareDataGrid.CurrentCell.RowIndex; var column = softwareDataGrid.CurrentCell.ColumnIndex; string licenceKey = softwareDataGrid.Rows[row].Cells[0].Value.ToString(); double sizeInMB = Convert.ToDouble(softwareDataGrid.Rows[row].Cells[1].Value); string itemID = hardwareDataGrid.Rows[row].Cells[2].Value.ToString(); string itemName = hardwareDataGrid.Rows[row].Cells[3].Value.ToString(); double price = Convert.ToDouble(hardwareDataGrid.Rows[row].Cells[4].Value); SoftwareItem softwareItem = new SoftwareItem(itemID, itemName, price, licenceKey, sizeInMB); db.EditSoftwareItem(softwareItem); }
private void delSoftware_Click(object sender, EventArgs e) { ItemsDatabase db = new ItemsDatabase(); var row = softwareDataGrid.CurrentCell.RowIndex; string itemID = hardwareDataGrid.Rows[row].Cells[2].Value.ToString(); SoftwareItem softwareItem = new SoftwareItem(itemID, "", 0.0, "", 0.0); db.DeleteSoftware(softwareItem); MessageBox.Show("Izdelek izbrisan!"); List <SoftwareItem> softwareItems = new List <SoftwareItem>(); softwareItems = db.ReadSoftwareItems(); softwareDataGrid.DataSource = softwareItems; }
private void dodaj_btn_Click(object sender, EventArgs e) { string selected = comboBox1.SelectedItem.ToString(); if (selected == "Software") { string ime = imeText.Text; string code = serialText.Text; double price = Convert.ToDouble(cenaText.Text); string license = dataGridView1[0, 0].Value.ToString(); double size = Convert.ToDouble(dataGridView1[1, 0].Value.ToString()); string verzija = dataGridView1[2, 0].Value.ToString(); SoftwareItem si = new SoftwareItem(ime, code, size, price, license, verzija); ItemsDatabase itd = new ItemsDatabase(); itd.SaveItem(si); clearTables(); } else if (selected == "Computer") { string ime = imeText.Text; string code = serialText.Text; double price = Convert.ToDouble(cenaText.Text); int cores = Convert.ToInt32(dataGridView1[0, 0].Value.ToString()); int ram = Convert.ToInt32(dataGridView1[1, 0].Value.ToString()); int hdd = Convert.ToInt32(dataGridView1[2, 0].Value.ToString()); double teza = Convert.ToDouble(dataGridView1[3, 0].Value.ToString()); Computer c = new Computer(ime, code, price, teza, cores, ram, hdd); ItemsDatabase itd = new ItemsDatabase(); itd.SaveItem(c); clearTables(); } else if (selected == "Monitor") { string ime = imeText.Text; string code = serialText.Text; double price = Convert.ToDouble(cenaText.Text); double teza = Convert.ToDouble(dataGridView1[0, 0].Value.ToString()); string locljivost = dataGridView1[1, 0].Value.ToString(); string diag = dataGridView1[2, 0].Value.ToString(); string tip = dataGridView1[3, 0].Value.ToString(); Monitor m = new Monitor(ime, code, price, teza, diag, locljivost, tip); ItemsDatabase itd = new ItemsDatabase(); itd.SaveItem(m); clearTables(); } }
private void button_spremeni_Click(object sender, EventArgs e) { if (lol.type == "Software") { string ime = imeText.Text; string code = serialText.Text; double price = Convert.ToDouble(cenaText.Text); string license = dataGridView1[0, 0].Value.ToString(); double size = Convert.ToDouble(dataGridView1[1, 0].Value.ToString()); string verzija = dataGridView1[2, 0].Value.ToString(); SoftwareItem si = new SoftwareItem(ime, code, size, price, license, verzija); ItemsDatabase itd = new ItemsDatabase(); itd.UpdateItem(si, _code); prejsn_form.RefreshTable(); //SoftwareItem newItem = new SoftwareItem(name, code,) } else if (lol.type == "Computer") { string ime = imeText.Text; string code = serialText.Text; double price = Convert.ToDouble(cenaText.Text); int cores = Convert.ToInt32(dataGridView1[0, 0].Value.ToString()); int ram = Convert.ToInt32(dataGridView1[1, 0].Value.ToString()); int hdd = Convert.ToInt32(dataGridView1[2, 0].Value.ToString()); double teza = Convert.ToDouble(dataGridView1[3, 0].Value.ToString()); Computer c = new Computer(ime, code, price, teza, cores, ram, hdd); ItemsDatabase itd = new ItemsDatabase(); itd.UpdateItem(c, _code); prejsn_form.RefreshTable(); } else if (lol.type == "Monitor") { string ime = imeText.Text; string code = serialText.Text; double price = Convert.ToDouble(cenaText.Text); double teza = Convert.ToDouble(dataGridView1[0, 0].Value.ToString()); string locljivost = dataGridView1[1, 0].Value.ToString(); string diag = dataGridView1[2, 0].Value.ToString(); string tip = dataGridView1[3, 0].Value.ToString(); Monitor m = new Monitor(ime, code, price, teza, diag, locljivost, tip); ItemsDatabase itd = new ItemsDatabase(); itd.UpdateItem(m, _code); prejsn_form.RefreshTable(); } }
private void button3_Click(object sender, EventArgs e) { var row = dataGridView2.CurrentCell.RowIndex; string itemID = dataGridView2.Rows[row].Cells[2].Value.ToString(); itemsBaza db = new itemsBaza(); SoftwareItem softwareItemToDelete = new SoftwareItem(itemID, " ", 0.0, " ", 0); db.DeleteSoftwareItem(softwareItemToDelete); MessageBox.Show("Izdelek izbrisan"); List <SoftwareItem> seznamS = new List <SoftwareItem>(); seznamS = db.ReadItemsS(); dataGridView2.DataSource = seznamS; }
private void button2_Click(object sender, EventArgs e) { string itemID = textBox23.Text; string itemName = textBox8.Text; double price; Double.TryParse(textBox7.Text, out price); string licensekey = textBox6.Text; int sizeinMB = Convert.ToInt32(textBox5.Text); SoftwareItem softwareItem = new SoftwareItem(itemID, itemName, price, licensekey, sizeinMB); itemsBaza db = new itemsBaza(); db.EditSoftware(softwareItem); MessageBox.Show("Izdelek urejen"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; }
public SoftwareItem SoftwareXml2Obj(XmlNode Software) { SoftwareItem item; String Name = ""; String Description = ""; String Path = ""; String InstallArgs = ""; List<String> AdditionalCmd = new List<String>(); bool IsSelected = false; var properties = Software.ChildNodes; foreach (XmlNode info in properties) { //Name = "1234"; switch (info.Name) { case "Name": Name = info.InnerText; continue; case "Description": Description = info.InnerText; continue; case "Path": Path = info.InnerText; continue; case "InstallArgs": InstallArgs = info.InnerText; continue; case "IsSelected": if (info.InnerText.Trim() == "True" || info.InnerText.Trim() == "true") IsSelected = true; continue; case "AdditionalCmd": AdditionalCmd.Add(info.InnerText); continue; default: continue; } } item = new SoftwareItem(Name, Description, Path, InstallArgs, IsSelected, AdditionalCmd); return item; }
public static void install(SoftwareItem software, Action Complete) { ThreadControl.Task(() => { var p = new System.Diagnostics.Process(); p.StartInfo.FileName = software.Path; p.StartInfo.Arguments = software.InstallArgs; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = false; p.Start(); string data = p.StandardOutput.ReadToEnd(); //p.BeginOutputReadLine(); p.WaitForExit(); p.Close(); /*if (software.AdditionalCmd.Trim() != "") { p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = ""; p.StartInfo.CreateNoWindow = true; p.Start(); p.StandardInput.WriteLine(software.AdditionalCmd); p.StandardInput.WriteLine("&exit"); p.WaitForExit(); p.Close(); }*/ if (software.AdditionalCmd.Count > 0) { foreach (var command in software.AdditionalCmd) { if (command.Trim() != "") { ShellCommand.Run(command); } } } }, Complete ); }
private void addButton_Click(object sender, EventArgs e) { string itemID = textBox1.Text; string itemName = textBox2.Text; double price; Double.TryParse(textBox3.Text, out price); if (comboBox1.SelectedIndex == 0) { double weight; Double.TryParse(textBox4.Text, out weight); HardwareItem hardwareItem = new HardwareItem(itemID, itemName, price, weight); ItemsDatabase db = new ItemsDatabase(); db.SaveItemHardware(hardwareItem); MessageBox.Show("Izdelek dodan!"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; } else if (comboBox1.SelectedIndex == 1) { double weight; int noOfCores; int amountOfRAM; int hddSize; Double.TryParse(textBox10.Text, out weight); Int32.TryParse(textBox9.Text, out noOfCores); Int32.TryParse(textBox12.Text, out amountOfRAM); Int32.TryParse(textBox11.Text, out hddSize); Computer computer = new Computer(itemID, itemName, price, weight, noOfCores, amountOfRAM, hddSize); ItemsDatabase db = new ItemsDatabase(); db.SaveItemComputer(computer); MessageBox.Show("Izdelek dodan!"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox10.Text = ""; textBox9.Text = ""; textBox11.Text = ""; textBox12.Text = ""; } else if (comboBox1.SelectedIndex == 2) { double weight; string resolution = textBox13.Text; string monitorType = textBox7.Text; Double.TryParse(textBox8.Text, out weight); Monitor monitor = new Monitor(itemID, itemName, price, weight, resolution, monitorType); ItemsDatabase db = new ItemsDatabase(); db.SaveItemMonitor(monitor); MessageBox.Show("Izdelek dodan!"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox8.Text = ""; textBox13.Text = ""; textBox7.Text = ""; } else if (comboBox1.SelectedIndex == 3) { string licenceKey = textBox5.Text; double sizeInMB; Double.TryParse(textBox6.Text, out sizeInMB); SoftwareItem softwareItem = new SoftwareItem(itemID, itemName, price, licenceKey, sizeInMB); ItemsDatabase db = new ItemsDatabase(); db.SaveItemSoftware(softwareItem); MessageBox.Show("Izdelek dodan!"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox5.Text = ""; textBox6.Text = ""; } }