示例#1
0
        private void Btnguardar_Click(object sender, EventArgs e)
        {
            try
            {
                string Rpta = "";
                if (this.Txtnombre.Text == string.Empty || this.Txtapellidos.Text == string.Empty ||
                    this.Txtnumdocumento.Text == string.Empty ||
                    this.Txtdireccion.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    Erroricono.SetError(Txtnombre, "Ingrese un Valor");
                    Erroricono.SetError(Txtapellidos, "Ingrese un Valor");
                    Erroricono.SetError(Txtnumdocumento, "Ingrese un Valor");
                    Erroricono.SetError(Txtdireccion, "Ingrese un Valor");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        Rpta = Ncliente.Insertar(this.Txtnombre.Text.Trim().ToUpper(),
                                                 this.Txtapellidos.Text.Trim().ToUpper(),
                                                 this.Cmbsexo.Text, Dtfechanacimiento.Value, Cmbtipodocumento.Text,
                                                 Txtnumdocumento.Text, Txtdireccion.Text, Txttelefono.Text,
                                                 Txtemailcli.Text);
                    }
                    else
                    {
                        Rpta = Ncliente.Editar(Convert.ToInt32(this.Txtidcliente.Text),
                                               this.Txtnombre.Text.Trim().ToUpper(),
                                               this.Txtapellidos.Text.Trim().ToUpper(),
                                               this.Cmbsexo.Text, Dtfechanacimiento.Value, Cmbtipodocumento.Text,
                                               Txtnumdocumento.Text, Txtdireccion.Text, Txttelefono.Text,
                                               Txtemailcli.Text);
                    }

                    if (Rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se Insertó de forma correcta el registro");
                        }
                        else
                        {
                            this.MensajeOk("Se Actualizó de forma correcta el registro");
                        }
                    }
                    else
                    {
                        this.MensajeError(Rpta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string respuesta = "";

                if (txtNombre.Text == string.Empty)
                {
                    Utilidades.MensajeError("Falta ingresar algunos datos.");
                    errorIcono.SetError(txtNombre, "Ingrese el nombre del cliente");
                }
                else if (txtApellido.Text == string.Empty)
                {
                    Utilidades.MensajeError("Falta ingresar algunos datos.");
                    errorIcono.SetError(txtApellido, "Ingrese el apellido del cliente");
                }
                else if (txtNumDocumento.Text == string.Empty)
                {
                    Utilidades.MensajeError("Falta ingresar algunos datos.");
                    errorIcono.SetError(txtNumDocumento, "Ingrese el número de documento");
                }
                else if (txtDireccion.Text == string.Empty)
                {
                    Utilidades.MensajeError("Falta ingresar algunos datos.");
                    errorIcono.SetError(txtDireccion, "Ingrese la dirección del cliente");
                }
                else
                {
                    if (isNuevo)
                    {
                        respuesta = Ncliente.Insertar(txtNombre.Text.Trim().ToUpper(), txtApellido.Text.Trim().ToUpper(), cbSexo.Text, dtFechaNacimineto.Value,
                                                      cbTipoDocumento.Text, txtNumDocumento.Text, txtDireccion.Text, mtxtTelefono.Text, txtEmail.Text);
                    }
                    else
                    {
                        respuesta = Ncliente.Editar(Convert.ToInt32(txtIdCliente.Text), txtNombre.Text.Trim().ToUpper(), txtApellido.Text.Trim().ToUpper(),
                                                    cbSexo.Text, dtFechaNacimineto.Value, cbTipoDocumento.Text, txtNumDocumento.Text, txtDireccion.Text, mtxtTelefono.Text, txtEmail.Text);
                    }

                    if (respuesta.Equals("Ok"))
                    {
                        if (isNuevo)
                        {
                            Utilidades.MensajeOK("El cliente se agregó correctamente");
                        }
                        else
                        {
                            Utilidades.MensajeOK("La cliente se editó correctamente");
                        }
                    }
                    else
                    {
                        Utilidades.MensajeError(respuesta);
                    }
                    isNuevo  = false;
                    isEditar = false;
                    HabilitarBotones();
                    Limpiar();
                    Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }