コード例 #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtRazon_Social.Text == string.Empty || this.txtNum_Documento.Text == string.Empty ||
                    this.txtDireccion.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    errorIcono.SetError(txtRazon_Social, "Ingrese un Valor");
                    errorIcono.SetError(txtNum_Documento, "Ingrese un Valor");
                    errorIcono.SetError(txtDireccion, "Ingrese un Valor");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NProveedor.Insertar(this.txtRazon_Social.Text.Trim().ToUpper(),
                                                   this.cbSector_Comercial.Text, cbTipo_Documento.Text,
                                                   txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text,
                                                   txtEmail.Text, txtUrl.Text);
                    }
                    else
                    {
                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdproveedor.Text),
                                                 this.txtRazon_Social.Text.Trim().ToUpper(),
                                                 this.cbSector_Comercial.Text, cbTipo_Documento.Text,
                                                 txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text,
                                                 txtEmail.Text, txtUrl.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);
            }
        }
コード例 #2
0
ファイル: frmProveedor.cs プロジェクト: Neo-VaLti/SisVentas
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtrazon_social.Text == string.Empty || this.txtNumDocument.Text == string.Empty ||
                    this.txtDireccion.Text == string.Empty)
                {
                    MensajeError("Incorrectos datos, ingresar bien");
                    errorIcono.SetError(txtrazon_social, "Ingrese un Valor");
                    errorIcono.SetError(txtNumDocument, "Ingrese un Valor");
                    errorIcono.SetError(txtDireccion, "Ingrese un Valor");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NProveedor.Insertar(this.txtrazon_social.Text.Trim().ToUpper(),
                                                   this.cbSector_Comercial.Text.Trim(), cbTipo_Documento.Text,
                                                   txtNumDocument.Text, txtDireccion.Text, txtTelefono.Text,
                                                   txtEmail.Text, txtURL.Text)
                        ;
                    }
                    else
                    {
                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtproveedor.Text), this.txtrazon_social.Text.Trim().ToUpper(),
                                                 this.cbSector_Comercial.Text.Trim(), cbTipo_Documento.Text,
                                                 txtNumDocument.Text, txtDireccion.Text, txtTelefono.Text,
                                                 txtEmail.Text, txtURL.Text);
                    }
                }

                if (rpta.Equals("OK"))
                {
                    if (this.IsNuevo)
                    {
                        this.MensajeOk("Se ingreso correctamente.");
                    }
                    else
                    {
                        this.MensajeOk("Se actualizo.");
                    }
                }

                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);
            }
        }
コード例 #3
0
        //boton guardar
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //La variable que almacena si se inserto
                //o se modifico la tabla
                string Rpta = "";
                if (this.txtsector_social.Text == string.Empty || txtDireccion.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos");
                    errorIcono.SetError(txtsector_social, "Ingrese un Valor");
                    errorIcono.SetError(txtDireccion, "Ingrese un Valor");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        Rpta = NProveedor.Insertar(this.txtsector_social.Text.Trim().ToUpper(),
                                                   cbsector_comercial.Text, txtDireccion.Text,
                                                   txtTelefono.Text, txtEmail.Text, txtURL.Text);
                    }
                    else
                    {
                        Rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdproveedor.Text),
                                                 this.txtsector_social.Text.Trim().ToUpper(),
                                                 cbsector_comercial.Text, txtDireccion.Text,
                                                 txtTelefono.Text, txtEmail.Text, txtURL.Text);
                    }

                    if (Rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Insercion correcta");
                        }
                        else
                        {
                            this.MensajeOk("Actualizacion correcta");
                        }
                    }
                    else
                    {
                        this.MensajeError(Rpta);
                    }
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostar();
                    this.txtIdproveedor.Text = "";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #4
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtRazon_Social.Text == string.Empty || this.txtNum_Documento.Text == string.Empty ||
                    this.txtDireccion.Text == string.Empty)
                {
                    MensajeError("Faltan ingresar datos");
                    errorIcono.SetError(txtRazon_Social, "Ingrese la Razon Social");
                    errorIcono.SetError(txtNum_Documento, "Ingrese un Numero de Documento");
                    errorIcono.SetError(txtDireccion, "Ingrese la Direccion");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NProveedor.Insertar(this.txtRazon_Social.Text.Trim().ToUpper(), this.cmbSector_Comercial.Text,
                                                   cmbTipo_Documento.Text, txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text,
                                                   txtEmail.Text, txtUrl.Text);
                    }
                    else
                    {
                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdProveedor.Text),
                                                 this.txtRazon_Social.Text.Trim().ToUpper(), this.cmbSector_Comercial.Text,
                                                 cmbTipo_Documento.Text, txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text,
                                                 txtEmail.Text, txtUrl.Text);
                    }
                }
                if (rpta.Equals("ok"))
                {
                    if (this.IsNuevo)
                    {
                        this.MensajeOk("Se inserto correctamente el registro");
                    }
                    else
                    {
                        this.MensajeOk("Se actualizo correctamente 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);
            }
        }
コード例 #5
0
 private void BtnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         string rpta = "";
         if (this.txtRazonSocial.Text == string.Empty || this.txtNDocumento.Text == string.Empty ||
             this.txtDireccion.Text == string.Empty)
         {
             MensajeError("Falta ingresar datos, seran remarcados");
             errorProviderIcono.SetError(txtRazonSocial, "Ingrese un valor");
             errorProviderIcono.SetError(txtNDocumento, "Ingrese un valor");
             errorProviderIcono.SetError(txtDireccion, "Ingrese un valor");
         }
         else
         {
             if (this.IsNuevo)
             {
                 rpta = NProveedor.Insertar(this.txtRazonSocial.Text.Trim().ToUpper(),
                                            this.cbnSComercial.Text, cbnTDocumento.Text, txtNDocumento.Text,
                                            txtDireccion.Text, txtTelefono.Text, txtEmail.Text, txtUrl.Text);
             }
             else
             {
                 rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdproveedor.Text)
                                          , this.txtRazonSocial.Text.Trim().ToUpper(),
                                          this.cbnSComercial.Text, cbnTDocumento.Text, txtNDocumento.Text,
                                          txtDireccion.Text, txtTelefono.Text, txtEmail.Text, txtUrl.Text);
             }
             if (rpta.Equals("OK"))
             {
                 if (this.IsNuevo)
                 {
                     this.MensajeOk("Se inserto correctamente");
                 }
                 else
                 {
                     this.MensajeOk("se actualizo correctamente");
                 }
             }
             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);
     }
 }
コード例 #6
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string respuesta = "";
                if (this.txtRazon_Social.Text == string.Empty || this.txtNumero_Documento.Text == string.Empty || this.cbxTipo_Documento.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos relevantes");
                    errorIcono.SetError(txtRazon_Social, "Ingrese la Razon Social");
                    errorIcono.SetError(txtNumero_Documento, "Ingrese el Numero de Documento");
                    errorIcono.SetError(cbxTipo_Documento, "Seleccione el Tipo de Documento");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        respuesta = NProveedor.Insertar(this.txtRazon_Social.Text.Trim().ToUpper(), this.cbxTipo_Documento.Text, txtNumero_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtCorreo.Text);
                    }
                    else
                    {
                        respuesta = NProveedor.Editar(Convert.ToInt32(this.txtID.Text), this.txtRazon_Social.Text.Trim().ToUpper(), this.cbxTipo_Documento.Text, txtNumero_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtCorreo.Text);
                    }

                    if (respuesta.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(respuesta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }

                gbxListado.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #7
0
ファイル: FormProveedor.cs プロジェクト: UML-Tesis/Sifa
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txt1Nombre.Text == string.Empty)
                {
                    MensajeError("Falta el Nombre");
                    errorProvider1.SetError(txt1Nombre, "Ingrese el Nombre");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NProveedor.Insertar(this.txt1Nombre.Text.Trim().ToUpper(), this.txt2Nombre.Text.Trim().ToUpper(), this.txt1Apellido.Text.Trim().ToUpper(), Convert.ToInt32(this.txt2Apellido.Text), Convert.ToInt32(this.txtTelefono.Text), this.cbDocumento.Text.Trim().ToUpper()
                                                   , this.txtsectorcomercial.Text.Trim().ToUpper(), this.txtDireccion.Text.Trim().ToUpper(), this.txtcorreo.Text.Trim().ToUpper(), this.txtruc.Text.Trim().ToUpper());
                    }
                    else
                    {
                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdProveedor.Text),
                                                 this.txt1Nombre.Text.Trim().ToUpper(), this.txt2Nombre.Text.Trim().ToUpper(), this.txt1Apellido.Text.Trim().ToUpper(), Convert.ToInt32(this.txt2Apellido.Text), Convert.ToInt32(this.txtTelefono.Text), this.cbDocumento.Text.Trim().ToUpper()
                                                 , this.txtsectorcomercial.Text.Trim().ToUpper(), this.txtDireccion.Text.Trim().ToUpper(), this.txtcorreo.Text.Trim().ToUpper(), this.txtruc.Text.Trim().ToUpper());
                    }

                    if (rpta.Equals("Ok"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOK("Guardado Correctamente");
                        }
                        else
                        {
                            this.MensajeOK("Actualizado Correctamente");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #8
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            try
            {
                string respuesta = string.Empty;
                //valido los campos:
                if (this.RazonSocialtextBox.Text == string.Empty || this.NumeroDocumentotextBox.Text == string.Empty ||
                    this.DirecciontextBox.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados.");
                    ErrorIconoerrorProvider.SetError(this.RazonSocialtextBox, "Ingrese un Valoe.....");
                    ErrorIconoerrorProvider.SetError(this.NumeroDocumentotextBox, "Ingrese un Valoe.....");
                    ErrorIconoerrorProvider.SetError(this.DirecciontextBox, "Ingrese un Valoe.....");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        respuesta = NProveedor.Insertat(
                            this.RazonSocialtextBox.Text.Trim().ToUpper(),
                            this.SectorComercialcomboBox.Text,
                            this.TipoDocumentocomboBox.Text,
                            this.NumeroDocumentotextBox.Text,
                            this.DirecciontextBox.Text,
                            this.TelefonotextBox.Text,
                            this.EmailtextBox.Text,
                            this.UrltextBox.Text
                            );
                    }
                    else
                    {
                        respuesta = NProveedor.Editar(
                            Convert.ToInt32(IdProveedortextBox.Text),
                            this.RazonSocialtextBox.Text.Trim().ToUpper(),
                            this.SectorComercialcomboBox.Text,
                            this.TipoDocumentocomboBox.Text,
                            this.NumeroDocumentotextBox.Text,
                            this.DirecciontextBox.Text,
                            this.TelefonotextBox.Text,
                            this.EmailtextBox.Text,
                            this.UrltextBox.Text
                            );
                    }

                    if (respuesta.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(respuesta);
                    }
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #9
0
ファイル: FrmProveedor.cs プロジェクト: HTomasH/LasVentas
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try   //Control de errores   bien....
            {
                //-->VALIDACION DE CAMPOS. NOTA en el curso de C# ví que esto se puede hacer en las propiedades GET/SET
                //----------------------------------------------------------------------------------------------------
                string rpta = "";

                //Controles que deben de tener valores obligatoriamente -- Si está vacía y como es un campo obligatorio,  pues hay que meterlo

                if (this.txtNombre.Text == string.Empty || this.txtIdProveedor.Text == string.Empty || this.txtNumeroDocu.Text == string.Empty)
                {
                    //--> MENSAJES A MOSTRAR SI LOS CAMPOS OBLIGATORIOS ESTUVIERAN VACIOS  -  Este metodo lo tengo en este mismo módulo
                    MensajeError("Faltan por indicar  datos, serán remarcados");
                    //--Vamos a indicar el mensaje a mostrar cuando salga el error.
                    errorIcono.SetError(txtNombre, "Indique un Nombre");
                    errorIcono.SetError(txtNumeroDocu, "Indique un número de documento");
                }
                else  //El textBox llega con valor,
                {
                    if (this.IsNuevo)  //Es un alta ??
                    {
                        //-->Si tuvieramos que guardar una imagen, lo tratariamos de esta forma     VIDEO 14 minuto  20 aprox:
                        //----------------------------------------------------------------------
                        //   System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        //   this.pxImagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                        //   byte[] imagen = ms.GetBuffer();


                        //-->Vamos a llamar al Metodo Insertar de la CapaNegocio enviandole los valores para insertar en la bb.dd

                        //rpta = NArticulo.Insertar(this.txtcDetalle.Text.Trim().ToUpper(), Convert.ToInt32(this.txtIdCodFam.Text),
                        //                            Convert.ToInt32(this.txtnStock.Text), Convert.ToInt32(this.txtidTipoIva.Text), Convert.ToDecimal(this.txtnPvP.Text),
                        //                            this.txtcCodigoBar.Text);

                        rpta = NProveedor.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtNumeroDocu.Text);
                    }
                    else    //Es una modificacion
                    {
                        //-->Vamos a llamar al Metodo Editar de la CapaNegocio enviandole los valores


                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdProveedor.Text),
                                                 this.txtNombre.Text.Trim().ToUpper(),
                                                 this.txtNumeroDocu.Text);
                    }

                    //-->Ahora vamos a ver si la operación tuvo éxito o no, el "OK" que estamos poniendo aquí es el que está
                    //   indicado  en la CAPADATOS en los metodos
                    //   Insertar y Editar de esta forma :  rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO se Ingreso el Registro";
                    //  Por eso pongo OK sino pondría lo que tuviera puesto...
                    if (rpta.Equals("OK")) //Comparando cadenas con  :  Equals()
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se Insertó de forma correcta el registro");
                        }
                        else
                        {
                            this.MensajeOk("Se Actualizó de forma correcta el registro");
                        }
                    }
                    else  //Si no han tenido éxito la inserción o modificacion ERROR
                    {
                        //-->Vamos a enviar al error el valor de rpta que va a ser lo que tengo puesto en la CAPADATOS
                        this.MensajeError(rpta);
                    }

                    //Borra la pelotilla del error si estuviera
                    errorIcono.Clear();

                    //->Una vez insertado el registro dejamos las variables como estaban.
                    this.IsNuevo  = false;
                    this.IsEditar = false;

                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #10
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //La variable que almacena si se inserto
                //o se modifico la tabla
                string Rpta = "";
                if (this.txtRazon_Social.Text == string.Empty || this.txtNum_Documento.Text == string.Empty || txtDireccion.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    errorIcono.SetError(txtRazon_Social, "Ingrese un Valor");
                    errorIcono.SetError(txtNum_Documento, "Ingrese un Valor");
                    errorIcono.SetError(txtDireccion, "Ingrese un Valor");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        //Vamos a insertar un Proveedor
                        Rpta = NProveedor.Insertar(this.txtRazon_Social.Text.Trim().ToUpper(),
                                                   cbTipo_Documento.Text,
                                                   txtNum_Documento.Text, txtDireccion.Text,
                                                   txtTelefono.Text, txtEmail.Text, txtUrl.Text);
                    }
                    else
                    {
                        //Vamos a modificar un Proveedor
                        Rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdproveedor.Text),
                                                 this.txtRazon_Social.Text.Trim().ToUpper(),
                                                 cbTipo_Documento.Text,
                                                 txtNum_Documento.Text, txtDireccion.Text,
                                                 txtTelefono.Text, txtEmail.Text, txtUrl.Text);
                    }
                    //Si la respuesta fue OK, fue porque se modifico
                    //o inserto el Proveedor
                    //de forma correcta
                    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
                    {
                        //Mostramos el mensaje de error
                        this.MensajeError(Rpta);
                    }
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                    this.txtIdproveedor.Text = "";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #11
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //Declaro una variable para evaluar si se insertó o modificó:
                string rpta = "";
                //Voy a validar los datos. En éste caso, el campo Razón Social no puede estar vacío. Los otros también.
                //string.Empty = quiere decir que está vacía:
                if (this.txtRazon_Social.Text == string.Empty ||
                    this.txtNum_Documento.Text == string.Empty ||
                    this.txtDireccion.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    //Que el icono de error aparezca al costado de la caja de texto: txtNombre.
                    errorIcono.SetError(txtRazon_Social, "Ingrese un Valor");
                    errorIcono.SetError(txtNum_Documento, "Ingrese un Valor");
                    errorIcono.SetError(txtDireccion, "Ingrese un Valor");
                }
                else
                {
                    //El usuario quiere realizar un registro:
                    if (this.IsNuevo)
                    {
                        //Se envían varios parámatros.
                        //Trim: para borrar los espacios en blanco.
                        //ToUpper: para convertir a mayúsculas.
                        rpta = NProveedor.Insertar(this.txtRazon_Social.Text.Trim().ToUpper(),
                                                   this.cbSector_Comercial.Text,
                                                   cbTipo_Documento.Text,
                                                   txtNum_Documento.Text,
                                                   txtDireccion.Text,
                                                   txtTelefono.Text,
                                                   txtEmail.Text,
                                                   txtUrl.Text);
                    }
                    else
                    {
                        //Se envían varios parámatros.
                        //Trim: para borrar los espacios en blanco.
                        //ToUpper: para convertir a mayúsculas.
                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdproveedor.Text),
                                                 this.txtRazon_Social.Text.Trim().ToUpper(),
                                                 this.cbSector_Comercial.Text,
                                                 cbTipo_Documento.Text,
                                                 txtNum_Documento.Text,
                                                 txtDireccion.Text,
                                                 txtTelefono.Text,
                                                 txtEmail.Text,
                                                 txtUrl.Text);
                    }

                    //Esto es para la respuesta (rpta) de DProveedor, en el método insertar:
                    //Equals: para comparar una cadena.
                    if (rpta.Equals("OK")) //OK, es si se insertó o modificó.
                    {
                        //Recibo un OK del insertr, porque IsNuevo está en true en el if:
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("se insertó de forma correcta el registro");
                        }
                        //Si no es Insertar(IsNuevo) es un editar:
                        else
                        {
                            this.MensajeOk("se actualizó de forma correcta el registro");
                        }
                    }
                    //Si No recibo un OK:
                    else
                    {
                        //rpta, es el que recibe los mensajes.
                        this.MensajeError(rpta);
                    }

                    //Lo dejó en false, porque ya ingresé el registro:
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    //Para Mostrar actualizado nuestro datalistado:
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #12
0
        private void Guardar()
        {
            try
            {
                string rpta = "";
                if (this.txtNombre.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese el nombre del provedor");
                    errorIcono.SetError(txtNombre, "Ingrese el nombre");
                }
                else if (this.txtNumDoc.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese el número de documento");
                    errorIcono.SetError(txtNombre, "Ingrese el número");
                }
                else if (this.txtDireccion.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese la direeción");
                    errorIcono.SetError(txtDireccion, "Ingrese la dirección");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NProveedor.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.cbTipoDoc.SelectedItem.ToString(), this.txtNumDoc.Text.Trim(),
                                                   this.txtDireccion.Text.Trim().ToUpper(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(), "A");
                    }
                    else
                    {
                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdProveedor.Text), this.txtNombre.Text.Trim().ToUpper(), this.cbTipoDoc.SelectedItem.ToString(),
                                                 this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim().ToUpper(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(), "A");
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOK("Se insertó correctamente");
                        }
                        else
                        {
                            this.MensajeOK("Se actualizó correctamente");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                    this.tabControl2.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #13
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            int valorclasificacion = 0;
            int valortipo          = 0;

            //Radiobuton clasificación
            if (rbGobierno.Checked == true)
            {
                valorclasificacion = 2;
            }
            if (rbJuridico.Checked == true)
            {
                valorclasificacion = 1;
            }
            if (rbNatural.Checked == true)
            {
                valorclasificacion = 0;
            }
            //Radiobuton tipo de proveedor
            if (rbNacional.Checked == true)
            {
                valortipo = 1;
            }
            else
            {
                valortipo = 0;
            }

            try
            {
                string rpta = "";
                if (txtCodigo.Text == string.Empty | txtRif.Text == string.Empty | txtNombre.Text == string.Empty)
                {
                    if (txtCodigo.Text == string.Empty)
                    {
                        MensajeError("Falta ingresar algunos datos, serán remarcados");
                        errorIcono.SetError(txtCodigo, "Ingrese el código del proveedor");
                    }
                    if (txtRif.Text == string.Empty)
                    {
                        MensajeError("Falta ingresar algunos datos, serán remarcados");
                        errorIcono.SetError(txtRif, "Ingrese el RIF del proveedor");
                    }
                    if (txtNombre.Text == string.Empty)
                    {
                        MensajeError("Falta ingresar algunos datos, serán remarcados");
                        errorIcono.SetError(txtNombre, "Ingrese el nombre o la razón social del proveedor");
                    }
                }
                else
                {
                    if (IsNuevo)
                    {
                        rpta = NProveedor.Insertar(Convert.ToInt32(txtCodigo.Text), txtRif.Text, txtNombre.Text, txtContacto.Text, txtTOficina.Text,
                                                   txtTFax.Text, txtTMovil.Text, txtCuenta.Text, txtCorreo.Text, txtWeb.Text, txtDireccion.Text, valortipo, valorclasificacion,
                                                   txtObservacion.Text, Convert.ToInt32(cmbBanco.SelectedValue), Convert.ToInt16(chkStatus.Checked));
                    }
                    else
                    {
                        rpta = NProveedor.Editar(Convert.ToInt32(txtCodigo.Text), txtRif.Text, txtNombre.Text, txtContacto.Text, txtTOficina.Text,
                                                 txtTFax.Text, txtTMovil.Text, txtCuenta.Text, txtCorreo.Text, txtWeb.Text, txtDireccion.Text, valortipo, valorclasificacion,
                                                 txtObservacion.Text, Convert.ToInt32(cmbBanco.SelectedValue), Convert.ToInt16(chkStatus.Checked));
                    }
                    if (rpta.Equals("OK"))
                    {
                        if (IsNuevo)
                        {
                            MensajeOk("El registro fue ingresado con exito");
                        }
                        else
                        {
                            MensajeOk("El registro fue modificado con exito");
                        }
                    }
                    else
                    {
                        MensajeError(rpta);
                    }
                    IsNuevo  = false;
                    IsEditar = false;
                    Botones();
                    LimpiarFrm();
                    Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }