示例#1
0
 private void addButton_Click(object sender, EventArgs e)
 {
     if (this.groupsComboBox.Text.Length != 0)
     {
         String _GroupName   = this.groupsComboBox.Text;
         String _Name        = this.nameTextBox.Text;
         String _MiddleName  = this.MidNameTextBox.Text;
         String _SurName     = this.surNameTextBox.Text;
         String _MobilePhone = this.mobilePhoneTextBox.Text;
         String _HomePhone   = this.homePhoneTextBox.Text;
         String _WorkPhone   = this.workPhoneTextBox.Text;
         String _Email       = this.emailTextBox.Text;
         String _Addres      = this.addrTextBox.Text;
         String _PhotoPath   = CurrentDirrectoryReturner.getDirrectory() + "\\data\\Photos\\" +
                               _GroupName + "_" + _SurName + "_" + _Name + "_" + _MiddleName + ".jpg";
         Person newPerson = new Person(_GroupName, _Name, _MiddleName, _SurName, _MobilePhone,
                                       _HomePhone, _WorkPhone, _Email, _Addres, _PhotoPath);
         int res = newPerson.save();
         if (res == 0)
         {
             this.updateGroupsList();
             this.updatePersonsList();
             File.Copy(this.currentPhotoPath, _PhotoPath, true);
             MessageBox.Show("Успешное сохранение!", "Успешно!");
         }
         else
         {
             MessageBox.Show("Ошибка! Информаци не была сохранена! Попробуйте повторить попытку!", "Ошибка!");
         }
     }
     else
     {
         MessageBox.Show("Ошибка! Вы не указали группу для нового контакта!", "Ошибка!");
     }
 }