public AgentDodajAzuriraj(AgentBasic ag) { InitializeComponent(); a = ag; label1.Visible = false; txtIme.Visible = false; label2.Visible = false; txtPrezime.Visible = false; }
private void btnAzuriraj_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { MessageBox.Show("Odaberite agenta!"); return; } int agId = Int32.Parse(listView1.SelectedItems[0].SubItems[0].Text); AgentBasic ab = DTOManager.GetAgentBasic(agId); AgentDodajAzuriraj ada = new AgentDodajAzuriraj(ab); if (ada.ShowDialog() == System.Windows.Forms.DialogResult.OK) { PopulateInfos(); } }
//Funkcije za update i save entiteta public static AgentBasic GetAgentBasic(int id) { AgentBasic ab = new AgentBasic(); try { ISession s = DataLayer.GetSession(); Agent a = s.Load <Agent>(id); ab = new AgentBasic(a.Id, a.Telefon, a.Email, a.Sifra, a.RadniStaz); s.Close(); } catch (Exception ec) { MessageBox.Show(ec.Message); } return(ab); }
public static void UpdateAgentBasic(AgentBasic ab) { try { ISession s = DataLayer.GetSession(); Agent a = s.Load <Agent>(ab.AgentId); a.Telefon = ab.AgentTelefon; a.Email = ab.AgentEmail; a.Sifra = ab.AgentSifra; a.RadniStaz = ab.AgentStaz; s.Update(a); s.Flush(); s.Close(); } catch (Exception ec) { MessageBox.Show(ec.Message); } }
private void btnSnimi_Click(object sender, EventArgs e) { if (a != null) { AgentBasic ab = new AgentBasic(); ab.AgentEmail = txtEmail.Text; ab.AgentTelefon = txtTelefon.Text; ab.AgentSifra = txtSifra.Text; ab.AgentStaz = (int)numStaz.Value; ab.AgentId = a.AgentId; DTOManager.UpdateAgentBasic(ab); } else { Agent ag = new Agent(); ag.Ime = txtIme.Text; ag.Prezime = txtPrezime.Text; ag.Telefon = txtTelefon.Text; ag.Email = txtEmail.Text; ag.Sifra = txtSifra.Text; ag.RadniStaz = (int)numStaz.Value; DTOManager.SaveAgent(ag); } }
public AgentDodajAzuriraj() { InitializeComponent(); a = null; }