private void frmAddAccount_Load(object sender, EventArgs e) { TypesDAL tdal = new TypesDAL(); cbo_Type.ValueMember = "Id"; cbo_Type.DisplayMember = "Name"; cbo_Type.DataSource = tdal.GetAllType(); if (this.Tag != null) { AccountDAL adal = new AccountDAL(); Account acc = adal.GetAccountById(Convert.ToInt32(this.Tag)); cbo_Type.SelectedValue = acc.Type; txt_Money.Text = acc.Money.ToString(); com_Isout.Text = acc.IsOut == "是" ? "支出" : "收入"; date_datetime.Value = acc.DateTime; DetailDAL ddal = new DetailDAL(); grid_detail.DataSource = ddal.GetDetialList(acc.Id); } }
public void BindData() { //绑定列表数据 AccountDAL dal = new AccountDAL(); grid_account.DataSource = dal.GetAllAccount(); //绑定下拉列表框数据 TypesDAL tdal = new TypesDAL(); cbo_Type.ValueMember = "Id"; cbo_Type.DisplayMember = "Name"; List <Type> list = new List <Type>() { new Type { Id = 0, Name = "-全部-" } }; list.AddRange(tdal.GetAllType()); cbo_Type.DataSource = list; }