示例#1
0
 private void Add()
 {
     try
     {
         Survey survey = new Survey(txtName.Text, Convert.ToInt32(txtQuantity.Text), username);
         var    exist  = _service.Get(txtName.Text.ToUpper(), username);
         if (!exist)
         {
             _service.Add(survey);
             frmQuestions frmQuestions = new frmQuestions();
             frmQuestions.SurveyId = _service.GetId(survey);
             frmQuestions.Quantity = Convert.ToInt32(txtQuantity.Text);
             frmQuestions.userName = username;
             this.Hide();
             frmQuestions.Show();
         }
         else
         {
             MessageBox.Show("Ya tiene una encuesta con ese nombre, escriba uno diferente");
         }
     }catch (Exception e)
     {
         MessageBox.Show("Ha ocurrido un error, verifique los valores introducidos sean correctos");
     }
 }
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (_id <= 0)
     {
         MessageBox.Show("Debe Seleccionar la encuesta a editar", "Notificacion");
     }
     else
     {
         frmQuestions frmQuestions = new frmQuestions();
         frmQuestions.SurveyId = _id;
         frmQuestions.Quantity = Convert.ToInt32(_quantity);
         frmQuestions.userName = username;
         this.Hide();
         frmQuestions.Show();
     }
 }