public AccountActor GetSelectedItem(object source) { Session session = null; try { session = XpoHelper.GetNewSession(); ASPxComboBox combo = source as ASPxComboBox; //Get selected manufacturer if (combo.Value == null) { return(null); } Guid selectedId = (Guid)combo.Value; Person person = session.GetObjectByKey <Person>(selectedId); if (person == null) { return(null); } AccountActor ret = new AccountActor() { AccountActorTypeId = session.FindObject <AccountActorType>(new BinaryOperator("Code", Enum.GetName(typeof(AccountActorTypeEnum), AccountActorTypeEnum.SUPPLIER))).AccountActorTypeId, Code = person.Code, Description = person.Description, Name = person.Name, RefId = person.PersonId }; return(ret); } catch (Exception) { return(null); } finally { if (session != null) { session.Dispose(); } } }
protected void gridVoucherAllocation_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { try { using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork()) { if (VoucherId == null || VoucherId.Equals(Guid.Empty)) { throw new Exception("The operation is not supported. Please set VoucherId for the gridview."); } //Code // e.NewValues["VouchesId!Key"] = VoucherId; ASPxCallbackPanel panel = (ASPxCallbackPanel)gridVoucherAllocation .FindEditRowCellTemplateControl( gridVoucherAllocation.Columns["MasterAccountActor"] as GridViewDataColumn, "cpnMasterAcountActor"); AccountActorComboBox accountActorComboBox = (AccountActorComboBox)panel.FindControl("accountActorComboBox"); WebModule.Accounting.AllocationConfigure.Controls.AccountActor accountActor = accountActorComboBox.GetSelectedItem(); uow.CommitChanges(); } } catch (Exception) { throw; } finally { e.Cancel = true; gridVoucherAllocation.CancelEdit(); } }