private void uc_CreateUpdateContract_Load(object sender, EventArgs e) { if (company_id != 0) { cbox_companies.Items.Add(CompanyController.getById(company_id).name); cbox_companies.SelectedIndex = 0; } if (patent_id != 0) { cbox_patents.Items.Add(PatentController.getById(patent_id).number); cbox_patents.SelectedIndex = 0; } if (create_date > dtime_deposit_date.MinDate) { dtime_deposit_date.Value = create_date; } if (duration != 0) { nbox_duration.Value = duration; } if (price != 00.00) { tbox_price.Text = price.ToString(); } }
public void ReloadPanel() { pnl_patents.Controls.Clear(); var patents = PatentController.getAll(); // .OrderBy(t => t.id).Reverse() if (btn_orderby_depositDate.Checked) { patents = patents.OrderBy(p => p.deposit_date); // trier par date de dépôt } if (btn_orderby_molecule.Checked) { patents = patents.OrderBy(p => p.molecule_id); // trier par molécule } if (btn_orderby_company.Checked) { patents = patents.OrderBy(p => p.company_id); // trier par entreprise } foreach (var p in patents) { pnl_patents.Controls.Add(new uc_PatentModel { id = p.id, number = p.number, molecule_id = p.molecule_id, company_id = p.company_id, deposit_date = p.deposit_date, duration = p.duration, country = p.country }); } }
private void btn_search_Click(object sender, EventArgs e) { if (tbox_search.Text != "Rechercher...") { pnl_patents.Controls.Clear(); var patents = PatentController.getAll(); patents = patents.Where(m => m.number.Contains(tbox_search.Text) || m.country.Contains(tbox_search.Text)); foreach (var p in patents) { pnl_patents.Controls.Add(new uc_PatentModel { id = p.id, number = p.number, molecule_id = p.molecule_id, company_id = p.company_id, deposit_date = p.deposit_date, duration = p.duration, country = p.country }); } } else { ReloadPanel(); } }
private void uc_ContractModel_Load(object sender, EventArgs e) { lbl_id.Text = id.ToString(); lbl_company.Text = CompanyController.getById(company_id).name; lbl_patent.Text = PatentController.getById(patent_id).number; lbl_create_date.Text = create_date.ToString(); lbl_duration.Text = duration.ToString() + "an(s)"; lbl_price.Text = price.ToString().Replace('.', ',') + "€"; }
private void cbox_patents_Click(object sender, EventArgs e) { cbox_patents.Items.Clear(); var patents = PatentController.getAll(); foreach (var patent in patents) { cbox_patents.Items.Add(patent.number); } }
private void btn_delete_Click(object sender, EventArgs e) { if (PatentController.PatentUsed(id)) { PatentController.Delete(id); uc_MainPatent.Instance.ReloadPanel(); } else { MessageBox.Show("La molécule est utilisée par un brevet ou par un contrat", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_send_to_database_Click(object sender, EventArgs e) { if (id != 0) { PatentController.UpdatePatent(id, MoleculeController.getByName(cbox_molecules.Text), CompanyController.getByName(cbox_companies.Text), tbox_country.Text, tbox_number.Text, dtime_deposit_date.Value, (int)nbox_duration.Value); MessageBox.Show("Le brevet a été correctement mise à jour dans la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { PatentController.AddPatent(MoleculeController.getByName(cbox_molecules.Text), CompanyController.getByName(cbox_companies.Text), tbox_country.Text, tbox_number.Text, dtime_deposit_date.Value, (int)nbox_duration.Value); MessageBox.Show("Le brevet a été correctement ajoutée à la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } uc_MainPatent.Instance.ReloadPanel(); this.SendToBack(); }
private void btn_send_to_database_Click(object sender, EventArgs e) { if (id != 0) { ContractController.UpdateContract(id, CompanyController.getByName(cbox_companies.Text), PatentController.getByNumber(cbox_patents.Text), dtime_deposit_date.Value, (int)nbox_duration.Value, Convert.ToDouble(tbox_price.Text)); MessageBox.Show("Le contrat a été correctement mise à jour dans la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ContractController.AddContract(CompanyController.getByName(cbox_companies.Text), PatentController.getByNumber(cbox_patents.Text), dtime_deposit_date.Value, (int)nbox_duration.Value, Convert.ToDouble(tbox_price.Text.Replace('.', ','))); MessageBox.Show("Le contrat a été correctement ajoutée à la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } uc_MainContract.Instance.ReloadPanel(); this.SendToBack(); }