Example #1
0
        private void GuardarServicio()
        {
            try
            {
                string rpta = "";
                if (this.txtNombre.Text == string.Empty || this.txtPrecio.Text == string.Empty)
                {
                    MensajeError("Por favor llene todos los campos con informacion valida");
                    errorIcono.SetError(txtNombre, "Ingrese un nombre valido");
                    errorIcono.SetError(txtPrecio, "Ingrese un Numero valido");
                }

                else
                {
                    rpta = NServicios.Insertar(txtNombre.Text, txtObservaciones.Text, Convert.ToDouble(txtPrecio.Text));
                    Close();
                }
                if (rpta.Equals("OK"))
                {
                    this.MensajeOk("Se agrego el Servicio correctamente");
                }
                else
                {
                    this.MensajeError("Vuelva a intentarlo");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Example #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";

                if (this.txtNombre.Text == string.Empty || this.txtCosto.Text == string.Empty)
                {
                    mensajeError("falta ingresar algunos datos");
                    errorIcono.SetError(txtNombre, "ingrese un datos");
                    errorIcono.SetError(txtCosto, "ingrese un valor");
                }
                else
                {
                    if (this.Nuevo)
                    {
                        rpta = NServicios.Insertar(this.txtNombre.Text.ToUpper(), Convert.ToDecimal(this.txtCosto.Text));
                    }
                    else
                    {
                        rpta = NServicios.Editar(Convert.ToInt32(txtSer_id.Text), this.txtNombre.Text.ToUpper(), Convert.ToDecimal(this.txtCosto.Text));
                    }
                    if (rpta.Equals("OK"))
                    {
                        if (this.Nuevo)
                        {
                            this.mensajeOk("se registro El Servicio");
                        }
                        else
                        {
                            this.mensajeOk("se actualizaron los datos del Servicio");
                        }
                    }
                    else
                    {
                        this.mensajeError(rpta);
                    }

                    this.Nuevo  = false;
                    this.Editar = false;
                    this.Botones();
                    this.limpiar();
                    this.mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }