private void FrmAddEditSubAccount_Load(object sender, EventArgs e) { try { reciever = new SubExpencesReciever(); helper = new Helpers.DataHelper(); // Fill Main account type combo var mainAccount = _subExpencesList.GroupBy(x => x.Option_Name).Select(x => x.FirstOrDefault()); helper.FillCombo(cmbMainAccount, GetMainAccountList(mainAccount)); if (_model != null) { PopulateAccountType(_model.Expences_ID.ToString()); txtSubAccountType.Text = _model.SubExpences_Name; cmbMainAccount.SelectedIndex = GetMainAccountList(mainAccount).Select((obj, index) => new { obj, index }).Where(x => x.obj.Value == _model.Option_Name).Select(x => x.index).FirstOrDefault(); cmbAccountType.SelectedIndex = GetAccountTypeList(_model.Option_Name).Select((obj, index) => new { obj, index }).Where(x => x.obj.Value == _model.Expences_ID.ToString()).Select(x => x.index).FirstOrDefault(); toggleActive.Checked = _model.IsActive; } else { _model = new SubExpencesModel(); cmbMainAccount.SelectedIndex = 0; cmbAccountType.SelectedIndex = 0; } } catch (Exception ex) { } }
public FrmSubAccountDetail() { reciever = new SubExpencesReciever(); helper = new DataHelper(); InitializeComponent(); Configuration(); RefreshList(); }