public int CompareTo(object obj) { ClientRauPlatnic cl = (ClientRauPlatnic)obj; if (sumaPlata > cl.sumaPlata) { if (tipClient == "PF") { return(1); } else { return(0); } } else if (sumaPlata < cl.sumaPlata) { if (tipClient == "PF") { return(-1); } else { return(0); } } else if (sumaPlata > cl.sumaPlata) { if (tipClient == "PJ") { return(1); } else { return(0); } } else if (sumaPlata < cl.sumaPlata) { if (tipClient == "PJ") { return(-1); } else { return(0); } } else { return(0); } }
public Form1() { InitializeComponent(); ClientRauPlatnic cl1 = new ClientRauPlatnic(1, "Edy", "Romana Square", "PF", 120, new int[] { 2, 3, 4 }); client.Add(cl1); client.Add(new ClientRauPlatnic(2, "Andrei", "Romana Square", "PJ", 320, new int[] { 2, 3, 4 })); client.Add(new ClientRauPlatnic(3, "Alexandra", "Romana Square", "PF", 220, new int[] { 2, 3, 4 })); client.Sort(); }
public Form1() { InitializeComponent(); float[] vectorPlati = { 3.5f, 3.6f, 3.7f }; float[] vectorPlati2 = { 1.2f, 1.5f, 2.3f }; float[] vectorPlati3 = { 10.2f, 15.3f, 9.6f }; ClientRauPlatnic client1 = new ClientRauPlatnic(1, "Dina", "Voinesti", "PF", 12000, vectorPlati); ClientRauPlatnic client2 = new ClientRauPlatnic(2, "Sebi", "Bucuresti", "PF", 2000, vectorPlati2); ClientRauPlatnic client3 = new ClientRauPlatnic(3, "Chihaia", "Bucuresti", "PF", 5000, vectorPlati3); listClienti.Add(client1); listClienti.Add(client2); listClienti.Add(client3); }
static void Main(string[] args) { Application.Run(new Form1()); float[] vectorPlati = { 3.5f, 3.6f, 3.7f }; float[] vectorPlati2 = { 1.2f, 1.5f, 2.3f }; ClientRauPlatnic client1 = new ClientRauPlatnic(1, "Dina", "Voinesti", "PF", 1200, vectorPlati); ClientRauPlatnic client2 = (ClientRauPlatnic)client1.Clone(); client1.setVectorPlati(vectorPlati2); Console.WriteLine(client1); Console.WriteLine(client2); Console.WriteLine(client1.CompareTo(client2)); Console.WriteLine((double)client1); client1 = client1 + 3.6f; Console.WriteLine(client1); }
private void button1_Click(object sender, EventArgs e) { if (tbCod.Text == "") { errorProvider1.SetError(tbCod, "Introduceti Codul!"); } else if (tbNume.Text == "") { errorProvider1.SetError(tbNume, "Introduceti Numele!"); } else if (tbAdresa.Text == "") { errorProvider1.SetError(tbAdresa, "Introduceti Adresa!"); } else if (!rbPF.Checked && !rbPJ.Checked) { errorProvider1.SetError(groupBox1, "Introduceti tipul de persoana(PF/PJ)"); } else if (tbSuma.Text == "") { errorProvider1.SetError(tbSuma, "Introduceti suma!"); } else if (tbPlati.Text == "") { errorProvider1.SetError(tbPlati, "Introduceti datele platilor lunare"); } else { try { int c = Convert.ToInt32(tbCod.Text); string n = tbNume.Text; string a = tbAdresa.Text; string t = ""; if (rbPF.Checked) { t = "PF"; } else if (rbPJ.Checked) { t = "PJ"; } double s = Convert.ToDouble(tbSuma.Text); string[] vector = tbPlati.Text.Split(','); int[] plati = new int[vector.Length]; for (int i = 0; i < vector.Length; i++) { plati[i] = Convert.ToInt32(vector[i]); } ClientRauPlatnic cli = new ClientRauPlatnic(c, n, a, t, s, plati); client.Add(cli); client.Sort(); MessageBox.Show(cli.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { tbCod.Clear(); tbNume.Clear(); tbAdresa.Clear(); rbPF.Checked = false; rbPJ.Checked = false; tbSuma.Clear(); tbPlati.Clear(); errorProvider1.Clear(); } } }
private void button1_Click(object sender, EventArgs e) { int cod = 0; String nume = null; String adresa = null; String tip = null; float sumaPlata = 0; float[] vectorPlati = null; Boolean isValide = true; try { if (string.IsNullOrWhiteSpace(tbCod.Text)) { throw new Exception("Cod should not be empty"); } else { cod = int.Parse(tbCod.Text); } if (string.IsNullOrWhiteSpace(tbNume.Text)) { throw new Exception("Nume should not be empty"); } else { nume = tbNume.Text; } if (string.IsNullOrWhiteSpace(tbAdresa.Text)) { throw new Exception("Adresa should not pe empty"); } else { adresa = tbAdresa.Text; } if (string.IsNullOrWhiteSpace(tbTip.Text)) { throw new Exception("Tip should not be empty"); } else { tip = tbTip.Text; } if (string.IsNullOrWhiteSpace(tbSuma.Text)) { throw new Exception("Suma should not be empty"); } else { sumaPlata = float.Parse(tbSuma.Text); } if (string.IsNullOrWhiteSpace(tbPlati.Text)) { throw new Exception("Plati should not be empty"); } else { String[] args = tbPlati.Text.Split(','); vectorPlati = new float[args.Length]; for (int i = 0; i < args.Length; i++) { vectorPlati[i] = float.Parse(args[i]); } } ClientRauPlatnic client = new ClientRauPlatnic(cod, nume, adresa, tip, sumaPlata, vectorPlati); listClienti.Add(client); } catch (Exception et) { MessageBox.Show(et.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } listClienti.Sort(new DescComparer()); }