Example #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            SOE = new SalesOfferEntities();

            // Call the Load method to get the data for the given DbSet
            // from the database.
            // The data is materialized as entities. The entities are managed by
            // the DbContext instance.
            //SOE.OfferVersionGroup.Load();

            // Bind the categoryBindingSource.DataSource to
            // all the Unchanged, Modified and Added Category objects that
            // are currently tracked by the DbContext.
            // Note that we need to call ToBindingList() on the
            // ObservableCollection<TEntity> returned by
            // the DbSet.Local property to get the BindingList<T>
            // in order to facilitate two-way binding in WinForms.



            SOE.OfferFile.Load();
            SOE.Offer.Load();

            //int[] All =new int[1];
            //All[0] = 100;
            //var otypes = (from o in SOE.Offer select o.TypeId).Distinct().Union(All);
            //offerTypeBindignSource.DataSource = otypes.ToList();

            //offerTypeBindignSource = SOE.Offer.GetTypeIdDistinct();


            IBindingList list = SOE.OfferFile.Local.ToBindingList();

            this.offerFileBindingSource.DataSource = list;
            this.offerBindingSource.DataSource     = list;
            list.ListChanged += List_ListChanged;

            //SOE.OfferVersionGroup.Load();
            //this.offerVersionGroupBindingSource.DataSource = SOE.OfferVersionGroup.Local.ToBindingList();


            //SOE.OfferItem.Load();
            //this.offerItemBindingSource.DataSource = SOE.OfferItem.Local.ToBindingList();
        }
Example #2
0
        public Form2(OfferVersionGroup obj, SalesOfferEntities SOE)
        {
            InitializeComponent();
            //SOEOI = new SalesOfferEntities();
            this.SOEOI = SOE;


            IList <OfferItem> oi = new System.ComponentModel.BindingList <OfferItem>();

            oi = SOE.OfferItem.Local.ToBindingList();
            // offerItemBindingSource = new BindingSource();
            offerItemBindingSource.DataSource = oi.Where(offi => offi.OfferVersionGroupId == obj.Id).ToList();


            offerBindingSource.DataSource = obj.OfferVersion.Offer;

            offerVersionBindingSource = new BindingSource();

            var qovid = ((from ov in SOEOI.OfferVersion
                          where ov.OfferId == obj.OfferVersion.OfferId
                          select ov.IssueDate)).SingleOrDefault();

            DateTime ovid;

            if (DateTime.TryParse(qovid.ToString(), out ovid))
            {
                labIssueDate.Text = ovid.ToString("yyyy/MM/dd");
            }
            else
            {
                labIssueDate.Text = null;
            }



            //offerVersionBindingSource.DataSource = SOEOI.OfferVersion.Local.ToBindingList().Where(ov => ov.OfferId == obj.OfferVersion.OfferId);
        }