private void cmdDelete_Click(object sender, RoutedEventArgs e) { Cursor = Cursors.Wait; try { FriendServices.Delete(lstUsers.SelectedValue as Friends); Clean(); Bind(); } catch (Exception ex) { CatchException(ex); } Cursor = null; }
public LoanTo(ThumbItem thumbitem) { InitializeComponent(); if (thumbitem == null) { return; } _strId = thumbitem.Id; _selectedItems = thumbitem.EType; cboAlias.ItemsSource = FriendServices.Gets(); cboAlias.DisplayMemberPath = "Alias"; imgTitle.Source = Util.CreateSmallImage(thumbitem.Cover); lblTitle.Text = thumbitem.Name; Loan objLoan = LoanServices.Get(_strId); if (objLoan != null) { txtEndDate.Text = objLoan.EndDate.ToShortDateString(); //Fix since 2.7.12.0 if (objLoan.Friend != null) { cboAlias.Text = objLoan.Friend.Alias; } txtStartDate.Text = objLoan.StartDate.ToShortDateString(); } else { txtStartDate.Text = DateTime.Now.ToShortDateString(); txtEndDate.Text = DateTime.Now.AddDays(10).ToShortDateString(); } }
private void cmdSave_Click(object sender, RoutedEventArgs e) { Cursor = Cursors.Wait; try { Friends objFriend = FriendServices.Get(txtAlias.Text); if (objFriend == null) { objFriend = new Friends(); } objFriend.Adresse = txtAdress.Text; objFriend.Alias = txtAlias.Text; if (string.IsNullOrEmpty(txtBirhtDate.Text) == false) { DateTime datTemp; if (DateTime.TryParse(txtBirhtDate.Text, out datTemp)) { objFriend.BirthDate = datTemp; } else { objFriend.BirthDate = null; } } else { objFriend.BirthDate = null; } objFriend.Comments = txtComments.Text; objFriend.EMail = txtEmail.Text; string firstName; string lastName; FriendServices.SplitName(txtFullName.Text, out firstName, out lastName); objFriend.FirstName = firstName; objFriend.LastName = lastName; if (string.IsNullOrEmpty(txtMaxLoan.Text) == false) { int lgnTemp; if (int.TryParse(txtMaxLoan.Text, out lgnTemp)) { objFriend.NbrMaxLoan = lgnTemp; } else { objFriend.NbrMaxLoan = 0; } } else { objFriend.NbrMaxLoan = 0; } objFriend.PhoneNumber = txtPhone.Text; objFriend.Picture = Util.SaveImageData(imgPhotos.Source); if (cboSex.Text == "Man") { objFriend.Sex = true; } else { objFriend.Sex = false; } FriendServices.Update(objFriend); Close(); } catch (Exception ex) { CatchException(ex); } Cursor = null; }
private void Bind() { lstUsers.ItemsSource = FriendServices.Gets(); }
public FriendController(FriendServices services) { this.Services = services; }