Esempio n. 1
0
 private void InitCountryGrid()
 {
     BOMarket mktBo = (BOMarket)m_bo;
     if (base.FormMode == NanCrm.FormMode.Add)
     {
         mktBo.Init();
     }
     UpdateData(false);
     objList.DataSourceType = typeof(CountryMD);
     //this.olvcName.AspectGetter = delegate(object row)
     //{
     //    return "cfl";
     //};
     //this.olvcName.Renderer = new MappedImageRenderer(new Object[] { "cfl", Resources.ButtonChoose });
     objList.SmallImageList = imageList;
     this.olvcName.ImageGetter = delegate(object row)
     {
         return 0;
     };
     MarketMD mkt = (MarketMD)mktBo.GetBOTable();
     foreach (int id in mkt.CountryIds)
     {
         BOCountry ctyBo = new BOCountry();
         ctyBo.GetById(id);
         m_ctyList.Add((CountryMD)ctyBo.GetBOTable());
     }
     CountryMD cty = new CountryMD();
     cty.ID = -1;
     m_ctyList.Add(cty);
     objList.SetObjects(m_ctyList);
 }
Esempio n. 2
0
        private void objList_CellEditFinishing(object sender, CellEditEventArgs e)
        {
            if (e.ListViewItem.Index == objList.Items.Count - 1)
            {
                if (e.Cancel || string.IsNullOrWhiteSpace(e.NewValue.ToString()))
                {
                    return;
                }
                BOCountry bo = new BOCountry();
                bo.GetByName(e.NewValue.ToString());
                //objList.GetItem(e.ListViewItem.Index).RowObject = bo.GetBOTable();
                //e.ListViewItem.RowObject = (CountryMD)bo.GetBOTable();
                CountryMD old = (CountryMD)e.ListViewItem.RowObject;
                old.CopyFrom(bo.GetBOTable());
                //objList.RefreshItem(e.ListViewItem);


                CountryMD obj = (CountryMD)objList.AddEmptyRow();
                int maxIdInDb = BusinessObject.GetBONextID(BOIDEnum.Country);
                int maxIdOfUi = objList.Objects.Cast<CountryMD>().ToList().Max(x => x.ID);
                obj.ID = Math.Max(maxIdInDb, maxIdOfUi) + 1;
            }
        }