I populate combobox this way for now manually only for testing:
private void FillComboBoxDziały_Click(object sender, EventArgs e)
{
using (ISession dbSession =
SessionProvider.Instance.SessionFactory.OpenSession())
{
IList<Dział> dzialy =
dbSession.Linq<Dział>().ToList<Dział>();
foreach (var dzial in dzialy)
{
//lbPersons.Items.Add(osoba.Imie +
osoba.SumaWydatkow);
comboBox1.DisplayMember = "Nazwa";
comboBox1.DataSource = dzialy;
//comboBox1.ValueMember = "Id";
}
}
}
So how i should modify in add person?
On 27 Mar, 17:02, Oskar Berggren <[email protected]> wrote:
> Clearly you already have a Dział in the SelectedValue. Either use this
> instance directly, or change the way you populate the combobox.
>
> /Oskar
>
> Den 27 mars 2012 16:57 skrev beginnerFNH <[email protected]>:
>
>
>
>
>
>
>
> > I tried this way:
>
> > using (ISession dbSession =
> > SessionProvider.Instance.SessionFactory.OpenSession())
> > {
> > using (ITransaction transaction =
> > dbSession.BeginTransaction())
> > {
> > Osoba newPerson = new Osoba
> > {
> > Imie = txtFirstName.Text,
> > SumaWydatkow =
> > Convert.ToInt32(numericSumaWydatkow.Value),
> > Dział = dbSession.Load<Dział>(Convert.ToInt32
> > (comboBox1.SelectedValue))
> > };
>
> > dbSession.Save(newPerson);
>
> > transaction.Commit();
> > MessageBox.Show("You have successfully added
> > person");
> > }
> > }
>
> > but i retrive an error:
>
> > Unable to cast object of type 'hms.core.Entities.Dział' to type
> > 'System.IConvertible'.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group
> > athttp://groups.google.com/group/nhusers?hl=en.
On 27 Mar, 17:02, Oskar Berggren <[email protected]> wrote:
> Clearly you already have a Dział in the SelectedValue. Either use this
> instance directly, or change the way you populate the combobox.
>
> /Oskar
>
> Den 27 mars 2012 16:57 skrev beginnerFNH <[email protected]>:
>
>
>
>
>
>
>
> > I tried this way:
>
> > using (ISession dbSession =
> > SessionProvider.Instance.SessionFactory.OpenSession())
> > {
> > using (ITransaction transaction =
> > dbSession.BeginTransaction())
> > {
> > Osoba newPerson = new Osoba
> > {
> > Imie = txtFirstName.Text,
> > SumaWydatkow =
> > Convert.ToInt32(numericSumaWydatkow.Value),
> > Dział = dbSession.Load<Dział>(Convert.ToInt32
> > (comboBox1.SelectedValue))
> > };
>
> > dbSession.Save(newPerson);
>
> > transaction.Commit();
> > MessageBox.Show("You have successfully added
> > person");
> > }
> > }
>
> > but i retrive an error:
>
> > Unable to cast object of type 'hms.core.Entities.Dział' to type
> > 'System.IConvertible'.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group
> > athttp://groups.google.com/group/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.