コード例 #1
0
ファイル: Main.cs プロジェクト: q394304565/Addresslist
 /// <summary>
 /// 加载数据源
 /// </summary>
 /// <param name="action"></param>
 private void LoadData(Action action = null)
 {
     HandleData(() =>
     {
         _contactPersonGroups = BLLOperate.GetContactPersonGroupsByUId(GlobalData.Current.CurrentUser.Id);
         _contactPersons      = BLLOperate.GetContactPersonsByUId(GlobalData.Current.CurrentUser.Id);
         if (action != null)
         {
             action();
         }
     }, s => MessageBox.Show(this, s));
 }
コード例 #2
0
 private void ContactPersonOperate_Load(object sender, EventArgs e)
 {
     userInfo.TxtName.Text      = ContactPerson.Name;
     userInfo.TxtEmail.Text     = ContactPerson.Email;
     userInfo.TxtAddress.Text   = ContactPerson.Address;
     userInfo.TxtCallPhone.Text = ContactPerson.Callphone;
     userInfo.TxtTelephone.Text = ContactPerson.Telephone;
     userInfo.DtBirthday.Text   = string.IsNullOrEmpty(ContactPerson.Birthday) ? DateTime.Now.Date.ToShortDateString() : ContactPerson.Birthday;
     if (ContactPerson.Favicon != null)
     {
         using (var myStream = new MemoryStream())
         {
             foreach (byte a in ContactPerson.Favicon)
             {
                 myStream.WriteByte(a);
             }
             var myImage = Image.FromStream(myStream);
             myStream.Close();
             userInfo.PbFavicon.Image = myImage;
         }
     }
     userInfo.CbSex.SelectedValue = ContactPerson.Sex;
     HandleData(() =>
     {
         var contactPersonGroups = new List <TB_ContactPersonGroup>();
         contactPersonGroups.Add(new TB_ContactPersonGroup {
             Id = 0, Name = "未分组"
         });
         var groups = BLLOperate.GetContactPersonGroupsByUId(GlobalData.Current.CurrentUser.Id);
         contactPersonGroups.AddRange(groups);
         cbGroups.DataSource    = contactPersonGroups;
         cbGroups.DisplayMember = "Name";
         cbGroups.ValueMember   = "Id";
         cbGroups.SelectedValue = ContactPerson.UType;
     });
 }