private void InitializeBinding() { IList <string> bmList = new List <string>(); string bmfileName = @"bm.xml"; using (System.IO.Stream fStream = new System.IO.FileStream(bmfileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite)) { try { System.Xml.Serialization.XmlSerializer xmlFormat = new System.Xml.Serialization.XmlSerializer(typeof(List <string>)); bmList = (List <string>)xmlFormat.Deserialize(fStream); } catch (System.Exception ex) { } } cmbBm.DataSource = bmList; cmbQx.DataSource = ROLEDao.QueryForList(); cmbQx.ValueMember = "ID"; cmbQx.DisplayMember = "DESCRIPTION"; }
private void BindingGrid() { mYhList.Clear(); var users = USERDao.QueryForList(); if (users != null) { foreach (var user in users) { Yh yh = new Yh { Xh = user.ID, Xm = user.REAL_NAME, Dlm = user.NAME, Xb = user.GENDER, Bm = user.DEPT, Lxdh = user.TEL, Email = user.EMAIL, Password = user.PASSWORD }; var userRoles = USERROLEDao.QueryForListByUserId(user.ID); if (userRoles != null && userRoles.Count > 0) { ROLE role = ROLEDao.Get(userRoles[0].ROLE_ID); if (role != null) { yh.Qx = role.DESCRIPTION; } } mYhList.Add(yh); } } mYhList.Sort(yhComparer); gcMain.DataSource = mYhList; gcMain.RefreshDataSource(); }