コード例 #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            SaveClientAnswer answerClient = clientService.Save(MapOutClient(), MapOutAdministrator());

            MessageBox.Show(answerClient.Message);
            FillTable();
            EmptyTextBoxes();
            TxtCedula.Focus();
        }
コード例 #2
0
        void guardarPersona()
        {
            try
            {
                string genero = string.Empty;
                if (RadioSexoM.Checked)
                {
                    genero = "Masculino";
                }
                else
                {
                    genero = "Femenino";
                }

                string tipoPersona = string.Empty;
                if (RadioButton1.Checked)
                {
                    tipoPersona = "1";
                }
                else if (RadioButton2.Checked)
                {
                    tipoPersona = "2";
                }
                else if (RadioButton3.Checked)
                {
                    tipoPersona = "3";
                }

                using (SqlConnection sqlCon = new SqlConnection(connectionString))
                {
                    sqlCon.Open();
                    string     query  = "INSERT INTO persona (tipo_persona_id,nombre,cedula,edad,sexo,telefono,direccion) VALUES (@tipo_persona_id,@nombre,@cedula,@edad,@sexo,@telefono,@direccion)";
                    SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
                    sqlCmd.Parameters.AddWithValue("@tipo_persona_id", tipoPersona);
                    sqlCmd.Parameters.AddWithValue("@nombre", (TxtNombre.FindControl("TxtNombre") as TextBox).Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@cedula", (TxtCedula.FindControl("TxtCedula") as TextBox).Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@edad", (TxtEdad.FindControl("TxtEdad") as TextBox).Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@sexo", genero);
                    sqlCmd.Parameters.AddWithValue("@telefono", (TxTtelefono.FindControl("TxTtelefono") as TextBox).Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@direccion", (TxtDireccion.FindControl("TxtDireccion") as TextBox).Text.Trim());
                    sqlCmd.ExecuteNonQuery();

                    lblSuccessMessage.Text    = "Registro Con Exito";
                    lblSuccessMessage.Visible = true;
                    lblErrorMessage.Text      = "";
                    lblErrorMessage.Visible   = true;

                    sqlCmd.Parameters.Clear();
                }
            }
            catch (Exception ex)
            {
                lblSuccessMessage.Text = "";
                lblErrorMessage.Text   = ex.Message;
            }
        }
コード例 #3
0
 public void LimpiarCamposCliente()
 {
     TxtCedula.Clear();
     TxtNombre.Clear();
     TxtApellido.Clear();
     TxtTelefono.Clear();
     TxtTelefono.Clear();
     TxtCelular.Clear();
     TxtEmail.Clear();
 }
コード例 #4
0
ファイル: FrmEdClientes.cs プロジェクト: Dyyel/Fact
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (TxtNombreComercial.Text == "" || TxtCedula.Text == "" || CbEstado.Text == "" || TxtId.Text != "")
            {
                MessageBox.Show("Datos no validos");
            }

            else
            {
                try
                {
                    if (validaCedula(TxtCedula.Text))
                    {
                        entities1.Clientes.Add(new Clientes
                        {
                            NombreComercial = TxtNombreComercial.Text,

                            Cédula = TxtCedula.Text,

                            Estado = CbEstado.Text
                        });

                        entities1.SaveChanges();
                        MessageBox.Show("Datos guardados con exito");
                        this.Close();
                    }
                    else
                    {
                        if (!validaCedula(TxtCedula.Text))
                        {
                            MessageBox.Show("Cedula no valida");
                            TxtCedula.Clear();
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Datos guardados incorrectamente");
                }
            }
        }
コード例 #5
0
 private void ChangeStatus()
 {
     EmptyTextBoxes();
     TxtCedula.Focus();
     DisplayButtons(false, false, true);
 }
コード例 #6
0
ファイル: Doctores.cs プロジェクト: 1522/Proyecto-Final
 private void BtnGuardar_Click(object sender, EventArgs e)
 {
     if (TxtNombre.Text == "")
     {
         MessageBox.Show("Falta el Nombre!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtNombre.Focus();
     }
     else if (TxtApPat.Text == "")
     {
         MessageBox.Show("Falta el Apellido Paterno!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtApPat.Focus();
     }
     else if (TxtApMat.Text == "")
     {
         MessageBox.Show("Falta el Apellido Materno!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtApMat.Focus();
     }
     else if (TxtDomicilio.Text == "")
     {
         MessageBox.Show("Falta el Domicilio!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtDomicilio.Focus();
     }
     else if (TxtTelefono.Text == "")
     {
         MessageBox.Show("Falta el Teléfono!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtTelefono.Focus();
     }
     else if (TxtFechaNac.Text == "/" || TxtFechaNac.Text == "__/__/____")
     {
         MessageBox.Show("Falta la fecha de Nacimiento!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtFechaNac.Focus();
     }
     else if (CmbSexo.Text == "")
     {
         MessageBox.Show("Falta elegir el Sexo!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         CmbSexo.Focus();
     }
     else if (TxtCedula.Text == "")
     {
         MessageBox.Show("Falta la Cédula Profésional", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtCedula.Focus();
     }
     else if (CmbEspecialidad.Text == "")
     {
         MessageBox.Show("Falta elegir la Especialidad", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         CmbEspecialidad.Focus();
     }
     else
     {
         try
         {
             if (Estado == true)
             {
                 GuardaNuevo();
                 MessageBox.Show("Registro Guardado!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 BtnGuardar.Enabled = false;
             }
             else
             {
                 modifica();
                 MessageBox.Show("Los Cambios se Guardaron Exitosamente!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 BtnGuardar.Enabled = false;
             }
         }
         catch
         {
             MessageBox.Show("Error!!", "Doctores");
         }
     }
 }