public void InitControl() { this.Cursor = Cursors.WaitCursor; using (Services.BaseTypeServices bts = new Services.BaseTypeServices()) { // var bi = bts.QueryByWithDescendants(x => x.Enable && (x.BaseTypeName == "公司部门" || x.BaseTypeName == "政府部门" || x.BaseTypeName == "科目类型")); //责任部门 var com = bts.Department;//bi.Where(x => x.BaseTypeName == "公司部门").FirstOrDefault(); cmbResponsibleBy.DataSource = com?.HaveItem.Where(x => x.Enable).OrderBy(x => x.ItemOrder).ToList(); cmbResponsibleBy.ValueMember = "Id"; cmbResponsibleBy.DisplayMember = "ItemName"; if (com != null) { //协助部门 //checkcombobox cmbAssistBy.DisplayMember = "NameConcatenated"; cmbAssistBy.ValueMember = "Selected"; cmbAssistBy.DisplayMemberSingleItem = "Name"; cmbAssistBy.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; //DropdownList 数据源放在后面 cmbAssistBy.DataSource = new PresentationControls.ListSelectionWrapper <Models.TypeItem>(com?.HaveItem, "ItemName"); //.Where(x => x.Enable).OrderBy(x => x.ItemOrder) } //收费单位 com = bts.ChargeBy;// bi.Where(x => x.BaseTypeName == "收费单位").FirstOrDefault(); cmbChargeBy.DataSource = com?.HaveItem.Where(x => x.Enable).OrderBy(x => x.ItemOrder).ToList(); cmbChargeBy.ValueMember = "Id"; cmbChargeBy.DisplayMember = "ItemName"; } this.Cursor = Cursors.Arrow; }
public Models.Tree GetData() {//更新node if (_currentAccount == null) { return(null); } using (var bts = new Services.BaseTypeServices()) { int i = 0; int.TryParse(tbAccLevel.Text, out i); _currentAccount.AccountLevel = i; _currentAccount.Name = tbAccountName.Text; _currentAccount.AccountId = tbAccID.Text; int.TryParse(tbFinanceLevel.Text, out i); _currentAccount.FinanceLevel = i; _currentAccount.FinanceAccountId = tbFinanceID.Text; _currentAccount.FinanceName = tbFinanceName.Text; _currentAccount.Comment = tbCommet.Text; _currentAccount.Label = tbLabel.Text; if (cmbResponsibleBy.SelectedIndex != -1) { _currentAccount.ResposibleByID = (int)cmbResponsibleBy.SelectedValue; //using (Services.TypeItemServices tis = new Services.TypeItemServices()) //{ // var ds = tis.Query().Find(cmbResponsibleBy.SelectedValue); // //_currentAccount.ResponsibleBy = ds; // //var ds = tis.Query(); // //var itementity = ds.Attach((Models.TypeItem)(cmbResponsibleBy.SelectedItem)); // //_currentAccount.ResponsibleBy = itementity?.Entity; //} } if (_currentAccount.AssistBy == null) { _currentAccount.AssistBy = new List <Models.AccountDepartment>(); } else { _currentAccount.AssistBy.Clear(); } foreach (var c in cmbAssistBy.CheckBoxItems) {//checkbox if (c.Checked) { var items = (PresentationControls.ObjectSelectionWrapper <Models.TypeItem>)(c.ComboBoxItem); if (items == null || items.Item == null) { continue; } var ad = new Models.AccountDepartment(); ad.Account = _currentAccount; ad.AccountID = _currentAccount.Id; ad.DeptID = items.Item.Id; _currentAccount.AssistBy.Add(ad); } } if (_currentAccount.GetType() == typeof(Models.ExpenseAccounts)) {//费用 if (cmbChargeBy.SelectedIndex != -1) { ((Models.ExpenseAccounts)_currentAccount).ChargingByID = ((Models.TypeItem)(cmbChargeBy.SelectedItem)).Id; ////if (((Models.ExpenseAccounts)_currentAccount).ChargingBy == null) //// ((Models.ExpenseAccounts)_currentAccount).ChargingBy = new Models.AccountDepartment(); //((Models.ExpenseAccounts)_currentAccount).ChargingBy = (Models.TypeItem)(cmbChargeBy.SelectedItem) ; //// ((Models.ExpenseAccounts)_currentAccount).ChargingBy.Account = _currentAccount; ((Models.ExpenseAccounts)_currentAccount).PricingComent = tbPricingComent.Text; ((Models.ExpenseAccounts)_currentAccount).IsCharged = cbIsCharging.Checked == true ? 1 : 0; } } } return(_currentAccount); }