private void OnButtonCautaNumeClicked(object sender, EventArgs e) { int c = validareCauta(); if (c == 0) { Op_Text x2 = new Op_Text("abc.txt"); System.Collections.ArrayList k = new System.Collections.ArrayList(); k = x2.GetMedicamente(); foreach (Medicamente y in k) { if (y.nume == txtCautNume.Text.ToUpper()) { lstAfisare.Items.Clear(); lstAfisare.Items.Add(y.Afisare()); break; } else { lstAfisare.Items.Clear(); lstAfisare.Items.Add("Medicamentul nu a fost gasit!"); continue; } } } }
private void OnButtonEditareClicked(object sender, EventArgs e) { Op_Text abc = new Op_Text("abc.txt"); ArrayList w = abc.GetMedicamente(); Edit e1 = new Edit(w); e1.Show(); }
private void OnButtonAfisareClicked(object sender, EventArgs e) { lstAfisare.Items.Clear(); Op_Text ad = new Op_Text("abc.txt"); ArrayList r = ad.GetMedicamente(); foreach (Medicamente q in r) { lstAfisare.Items.Add(q.Afisare()); } }
private void OnsortPretDscClicked(object sender, EventArgs e) { Op_Text b = new Op_Text("abc.txt"); ArrayList m = b.GetMedicamente(); m.Sort(new ComparaDsc()); lstAfisare.Items.Clear(); foreach (Medicamente w in m) { lstAfisare.Items.Add(w.Afisare()); } }
private void OnsortPretAscClicked(object sender, EventArgs e) { Op_Text p = new Op_Text("abc.txt"); ArrayList k = p.GetMedicamente(); k.Sort(new Compara()); lstAfisare.Items.Clear(); foreach (Medicamente q in k) { lstAfisare.Items.Add(q.Afisare()); } }
private void OnButtonCautaDataClicked(object sender, EventArgs e) { int d = validareData(); if (d == 0) { Op_Text bb = new Op_Text("abc.txt"); ArrayList q = bb.GetMedicamente(); foreach (Medicamente m in q) { if (m.dataActualizare >= Convert.ToDateTime(dataLeft.Text) && m.dataActualizare <= Convert.ToDateTime(dataRight.Text)) { lstAfisare.Items.Clear(); lstAfisare.Items.Add(m.Afisare()); } else { lstAfisare.Items.Clear(); lstAfisare.Items.Add("Niciun medicament gasit in intervalul introdus."); } } } }
private void OnButtonAdaugaClicked(object sender, EventArgs e) { int validare = Validare(); if (validare == 0) { nrMed++; Denumire.ForeColor = Color.LimeGreen; Pret.ForeColor = Color.LimeGreen; Tip.ForeColor = Color.LimeGreen; Pres.ForeColor = Color.LimeGreen; int ty = 0, prt = 0; if (comp1.Checked == true) { ty = 1; } else if (sir1.Checked == true) { ty = 2; } else if (ung1.Checked == true) { ty = 3; } if (Y1.Checked == true) { prt = 1; } else if (N1.Checked == true) { prt = 0; } Medicamente m = new Medicamente(txtDenumire.Text, Convert.ToDouble(txtPret.Text), ty, prt); lstAfisare.Items.Clear(); lstAfisare.Items.Add(nrMed + "." + m.Afisare()); Op_Text x1 = new Op_Text("abc.txt"); x1.AddMedicament(m); } else { switch (validare) { case 1: Denumire.ForeColor = Color.Red; break; case 2: Pret.ForeColor = Color.Red; break; case 3: Tip.ForeColor = Color.Red; break; case 4: Pres.ForeColor = Color.Red; break; default: break; } } }
public Edit(ArrayList w) { InitializeComponent(); this.Size = new System.Drawing.Size(500, 500); this.StartPosition = FormStartPosition.Manual; this.Location = new System.Drawing.Point(700, 100); this.Font = new Font("Arial", 9, FontStyle.Bold); this.ForeColor = Color.Black; this.Text = "Editare"; sel.Width = LATIME_CONTROL + 120; sel.Top = 10; sel.Text = "Selectati medicamentul din lista:"; sel.ForeColor = Color.Black; sel.BackColor = Color.Transparent; this.Controls.Add(sel); Op_Text y = new Op_Text("abc.txt"); w = y.GetMedicamente(); ComboBox c1 = new ComboBox(); c1.Location = new Point(5, DIMENSIUNE_PAS_Y * 2); c1.Text = "Alegeti..."; c1.Width = LATIME_CONTROL + 150; c1.DropDownHeight = 100; foreach (Medicamente l in w) { c1.Items.Add(l.infoComplet); } this.Controls.Add(c1); btnSel.Text = "Selectati"; btnSel.Width = LATIME_CONTROL; btnSel.Location = new Point(320, DIMENSIUNE_PAS_Y * 2); this.Controls.Add(btnSel); btnSel.Click += OnButtonSelClicked; void OnButtonSelClicked(object sender, EventArgs e) { Label NewDen = new Label(); NewDen.Width = LATIME_CONTROL - 20; NewDen.Text = "Denumire:"; NewDen.BackColor = Color.Transparent; NewDen.Top = DIMENSIUNE_PAS_Y * 3; this.Controls.Add(NewDen); Label NewPrice = new Label(); NewPrice.Width = LATIME_CONTROL - 20; NewPrice.Text = "Pret:"; NewPrice.BackColor = Color.Transparent; NewPrice.Top = DIMENSIUNE_PAS_Y * 4; this.Controls.Add(NewPrice); TextBox txtNewDen = new TextBox(); txtNewDen.Width = LATIME_CONTROL; txtNewDen.Location = new Point(DIMENSIUNE_PAS_X - 35, DIMENSIUNE_PAS_Y * 3); this.Controls.Add(txtNewDen); TextBox txtNewPrice = new TextBox(); txtNewPrice.Width = LATIME_CONTROL; txtNewPrice.Location = new Point(DIMENSIUNE_PAS_X - 35, DIMENSIUNE_PAS_Y * 4); this.Controls.Add(txtNewPrice); Label newTip = new Label(); newTip.Width = LATIME_CONTROL - 20; newTip.Text = "Tip:"; newTip.Top = DIMENSIUNE_PAS_Y * 5; newTip.BackColor = Color.Transparent; this.Controls.Add(newTip); CheckBox comp = new CheckBox(); comp.Location = new Point(DIMENSIUNE_PAS_X - 35, DIMENSIUNE_PAS_Y * 5); comp.Text = "Comprimat"; comp.Width = LATIME_CONTROL; comp.BackColor = Color.Transparent; this.Controls.Add(comp); CheckBox sir = new CheckBox(); sir.Location = new Point(DIMENSIUNE_PAS_X - 35, DIMENSIUNE_PAS_Y * 6); sir.Text = "Sirop"; sir.BackColor = Color.Transparent; sir.Width = LATIME_CONTROL; this.Controls.Add(sir); CheckBox ung = new CheckBox(); ung.Location = new Point(DIMENSIUNE_PAS_X - 35, DIMENSIUNE_PAS_Y * 7); ung.Text = "Unguent"; ung.Width = LATIME_CONTROL; ung.BackColor = Color.Transparent; this.Controls.Add(ung); Label newPres = new Label(); newPres.Width = LATIME_CONTROL - 20; newPres.Top = DIMENSIUNE_PAS_Y * 8; newPres.Text = "Prescriptie:"; newPres.BackColor = Color.Transparent; this.Controls.Add(newPres); RadioButton Y = new RadioButton(); Y.Location = new Point(DIMENSIUNE_PAS_X - 35, DIMENSIUNE_PAS_Y * 8); Y.Text = "Da"; Y.Width = LATIME_CONTROL - 100; Y.BackColor = Color.Transparent; this.Controls.Add(Y); RadioButton N = new RadioButton(); N.Location = new Point(DIMENSIUNE_PAS_X + 15, DIMENSIUNE_PAS_Y * 8); N.Text = "Nu"; N.BackColor = Color.Transparent; N.Width = LATIME_CONTROL; this.Controls.Add(N); Button btnSave = new Button(); btnSave.Text = "Salvati"; btnSave.Width = LATIME_CONTROL; btnSave.Location = new Point(DIMENSIUNE_PAS_X - 35, DIMENSIUNE_PAS_Y * 9); this.Controls.Add(btnSave); btnSave.Click += OnButtonSaveClicked; void OnButtonSaveClicked(object sender, EventArgs e) { int v = ValidareEdit(); if (v == 0) { string s1 = txtNewDen.Text; double p = Convert.ToDouble(txtNewPrice.Text); int t = 0; int pr = 0; if (comp.Checked == true) { t = 1; } else if (sir.Checked == true) { t = 2; } else if (ung.Checked == true) { t = 3; } if (Y.Checked == true) { pr = 1; } else if (N.Checked == true) { pr = 0; } Medicamente x = new Medicamente(s1, p, t, pr); y.ModificaLinie("abc.txt", c1.SelectedIndex, x); } else { switch (v) { case 1: NewDen.ForeColor = Color.Red; break; case 2: NewPrice.ForeColor = Color.Red; break; case 3: newTip.ForeColor = Color.Red; break; case 4: newPres.ForeColor = Color.Red; break; } } } int ValidareEdit() { if (txtNewDen.Text == string.Empty || txtNewDen.Text.Length > LUNGIME_MAX) { return(1); } else if (txtNewPrice.Text == string.Empty || Convert.ToDouble(txtNewPrice.Text) < PRET_MIN) { return(2); } else if ((comp.Checked == true && sir.Checked == true && ung.Checked == true) || (sir.Checked == false && ung.Checked == false && comp.Checked == false)) { return(3); } else if (Y.Checked == false && N.Checked == false) { return(4); } return(0); } } }