SHARE
TWEET

Untitled

a guest Dec 10th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp6
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             FormLogin f = new FormLogin();
  18.             if (f.ShowDialog() == DialogResult.OK)
  19.             {
  20.                 InitializeComponent();
  21.                 tableTableAdapter.Fill(bazadedate5DataSet.Table); //pus pt ca sa ramana tot timpul de baza de date de aceea se pun
  22.                 calculatoareListBox.Items.Clear();
  23.                 foreach (DataRowView drv in tableBindingSource.List)
  24.                 {
  25.                     calculatoareListBox.Items.Add("Producator:" + drv["Producator"].ToString() + " Model:" + drv["Model"].ToString() + " Garantie:" + drv["Garantie"].ToString() + " Cantitate:" + drv["Cantitate"].ToString() + " Pret:" + drv["Pret"].ToString());
  26.                 }
  27.             }
  28.         }
  29.  
  30.         private void tableBindingNavigatorSaveItem_Click(object sender, EventArgs e)
  31.         {
  32.             this.Validate();
  33.             this.tableBindingSource.EndEdit();
  34.             this.tableAdapterManager.UpdateAll(this.bazadedate5DataSet);
  35.  
  36.         }
  37.  
  38.         private void Form1_Load(object sender, EventArgs e)
  39.         {
  40.             // TODO: This line of code loads data into the 'bazadedate5DataSet.Table' table. You can move, or remove it, as needed.
  41.             this.tableTableAdapter.Fill(this.bazadedate5DataSet.Table);
  42.  
  43.         }
  44.  
  45.         private void adaugaButton_Click(object sender, EventArgs e)
  46.         {
  47.             errorProvider1.Clear();
  48.             if (pretTextBox.Text.ToString() == "")
  49.             {
  50.                 errorProvider1.SetError(pretTextBox, "Pretul trebuie completat");
  51.             }
  52.             else
  53.             {
  54.                 tableTableAdapter.Insert(producatorTextBox.Text, modelTextBox.Text, Int32.Parse(garantieComboBox.Text), Int32.Parse(cantitateNumericUpDown.Text), double.Parse(pretTextBox.Text));
  55.                 // Salvarea datelor
  56.                 tableAdapterManager.UpdateAll(bazadedate5DataSet);
  57.                 // Reincarcarea datelor
  58.                 tableTableAdapter.Fill(bazadedate5DataSet.Table);
  59.                 //upDATE IN BAZA DE DATE
  60.                 calculatoareListBox.Items.Clear();
  61.                 foreach (DataRowView drv in tableBindingSource.List)
  62.                 {
  63.                     calculatoareListBox.Items.Add("Producator:" + drv["Producator"].ToString() + " Model:" + drv["Model"].ToString() + " Garantie:" + drv["Garantie"].ToString() + " Cantitate:" + drv["Cantitate"].ToString() + " Pret:" + drv["Pret"].ToString());
  64.                 }
  65.             }
  66.         }
  67.  
  68.         private void ordonarePretButton_Click(object sender, EventArgs e)
  69.         {
  70.             List<Calculator> lista = new List<Calculator>();
  71.             foreach (DataRowView drv in tableBindingSource.List)
  72.             {
  73.                 Calculator c = new Calculator(drv["Producator"].ToString(), drv["Model"].ToString(), Int32.Parse(drv["Garantie"].ToString()), Int32.Parse(drv["Cantitate"].ToString()), float.Parse(drv["Pret"].ToString()));
  74.                 lista.Add(c);
  75.             }
  76.             calculatoareOrdonateListBox.Items.Clear();
  77.             lista.Sort((x, y) => x.Pret.CompareTo(y.Pret));
  78.             foreach (Calculator c in lista)
  79.             {
  80.                 calculatoareOrdonateListBox.Items.Add("Producator:" + c.Producator + " Model:" + c.Model + " Garantie:" + c.Garantie + " Cantitate:" + c.Cantitate + " Pret:" + c.Pret);
  81.             }
  82.         }
  83.  
  84.         private void ordonareGarantieButton_Click(object sender, EventArgs e)
  85.         {
  86.             List<Calculator> lista = new List<Calculator>();
  87.             foreach (DataRowView drv in tableBindingSource.List)
  88.             {
  89.                 Calculator c = new Calculator(drv["Producator"].ToString(), drv["Model"].ToString(), Int32.Parse(drv["Garantie"].ToString()), Int32.Parse(drv["Cantitate"].ToString()), float.Parse(drv["Pret"].ToString()));
  90.                 lista.Add(c);
  91.             }
  92.             calculatoareOrdonateListBox.Items.Clear();
  93.             lista.Sort((x, y) => x.Garantie.CompareTo(y.Garantie));
  94.             foreach (Calculator c in lista)
  95.             {
  96.                 calculatoareOrdonateListBox.Items.Add("Producator:" + c.Producator + " Model:" + c.Model + " Garantie:" + c.Garantie + " Cantitate:" + c.Cantitate + " Pret:" + c.Pret);
  97.             }
  98.         }
  99.  
  100.         private void afisareCantitateButton_Click(object sender, EventArgs e)
  101.         {
  102.             List<Calculator> lista = new List<Calculator>();
  103.             foreach (DataRowView drv in tableBindingSource.List)
  104.             {
  105.                 Calculator c = new Calculator(drv["Producator"].ToString(), drv["Model"].ToString(), Int32.Parse(drv["Garantie"].ToString()), Int32.Parse(drv["Cantitate"].ToString()), float.Parse(drv["Pret"].ToString()));
  106.                 lista.Add(c);
  107.             }
  108.             calculatoareOrdonateListBox.Items.Clear();
  109.             foreach (Calculator c in lista)
  110.             {
  111.                 if(c.Cantitate==Int32.Parse(afisareCantitateComboBox.Text.ToString()))
  112.                      calculatoareOrdonateListBox.Items.Add("Producator:" + c.Producator + " Model:" + c.Model + " Garantie:" + c.Garantie + " Cantitate:" + c.Cantitate + " Pret:" + c.Pret);
  113.             }
  114.         }
  115.  
  116.         private void stergeButton_Click(object sender, EventArgs e)
  117.         {
  118.             string aux = calculatoareListBox.SelectedItem.ToString().Substring(11);
  119.             string [] aux2 = aux.Split(' ');
  120.             aux = aux2[0];
  121.             foreach (DataRowView drv in tableBindingSource.List)
  122.             {
  123.                 if (drv["Producator"].ToString() == aux)
  124.                 {
  125.                     drv.Delete();
  126.                     // Salvarea datelor
  127.                     tableAdapterManager.UpdateAll(bazadedate5DataSet);
  128.                     // Reincarcarea datelor
  129.                     tableTableAdapter.Fill(bazadedate5DataSet.Table);
  130.                 }
  131.             }
  132.             calculatoareListBox.Items.Clear();
  133.             foreach (DataRowView drv in tableBindingSource.List)
  134.             {
  135.                 calculatoareListBox.Items.Add("Producator:" + drv["Producator"].ToString() + " Model:" + drv["Model"].ToString() + " Garantie:" + drv["Garantie"].ToString() + " Cantitate:" + drv["Cantitate"].ToString() + " Pret:" + drv["Pret"].ToString());
  136.             }
  137.         }
  138.     }
  139. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top