示例#1
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtRazon_Social.Text == string.Empty || this.txtNumDocumento.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(txtNumDocumento, "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,
                                                   txtNumDocumento.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,
                                                 txtNumDocumento.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);
            }
        }
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (Editar == true)
     {
         if (Comprobar_Campos() == string.Empty)
         {
             if (Obtener_Id(AuxiliarNombre) == 0)
             {
                 MessageBox.Show("Error: id no encontrado!");
             }
             else
             {
                 if (AuxiliarNombre == tbNombreProveedor.Text)
                 {
                     MessageBox.Show(NProveedor.Editar(Obtener_Id(tbNombreProveedor.Text), tbNombreProveedor.Text, tbContactoProveedor.Text));
                     Limpiar_Campos();
                     Editar = false;
                 }
                 else if (NombreExistente(tbNombreProveedor.Text))
                 {
                     MessageBox.Show(string.Format("Error: el nombre '{0}' ya se encuentra en uso!", tbNombreProveedor.Text));
                 }
                 else
                 {
                     MessageBox.Show(NProveedor.Editar(Obtener_Id(AuxiliarNombre), tbNombreProveedor.Text, tbContactoProveedor.Text));
                     Limpiar_Campos();
                     Editar = false;
                 }
             }
         }
         else
         {
             MessageBox.Show(Comprobar_Campos());
         }
     }
     else
     {
         if (Comprobar_Campos() == string.Empty)
         {
             if (NombreExistente(tbNombreProveedor.Text))
             {
                 MessageBox.Show(string.Format("Error: el nombre '{0}' ya se encuentra en uso!", tbNombreProveedor.Text));
             }
             else
             {
                 MessageBox.Show(NProveedor.Insertar(tbNombreProveedor.Text, tbContactoProveedor.Text));
                 Limpiar_Campos();
             }
         }
         else
         {
             MessageBox.Show(Comprobar_Campos());
         }
     }
     Mostrar();
 }
示例#3
0
        //metodo guardar datos
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            //insertar datos
            try
            {
                string rpta = "";
                if (this.txtNombre.Text == string.Empty || this.txtContacto.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados.");
                    errorIcono.SetError(this.txtNombre, "Ingrese un nombre");
                    errorIcono.SetError(this.txtContacto, "Ingrese un contacto");
                }
                else
                {
                    if (this.EsNuevo)
                    {
                        //nombre,descripcion,imagen,activa
                        rpta = NProveedor.Insertar(this.txtNombre.Text.Trim().ToUpper(),
                                                   this.txtContacto.Text.Trim().ToUpper(), Convert.ToInt32(this.CheckearActivo(chkActivo)));
                    }
                    else
                    {
                        //id,nombre,descripcion,imagen,activa
                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtCodigo.Text),
                                                 this.txtNombre.Text.Trim().ToUpper(), this.txtContacto.Text.Trim().ToUpper(), Convert.ToInt32(this.CheckearActivo(chkActivo)));
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.EsNuevo)
                        {
                            this.MensajeOK("Se inserto de forma correcta el registro.");
                        }
                        else
                        {
                            this.MensajeOK("Se modificó de forma correcta el registro.");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    //preparamos para nuevos datos
                    this.EsNuevo  = false;
                    this.EsEditar = false;
                    this.Botones();
                    this.LimpiarControles();
                    this.MostrarDatos();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
示例#4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";

                if (this.txtRazonSocial.Text == string.Empty || this.txtNumDocumento.Text == string.Empty || this.txtDireccion.Text == string.Empty)
                {
                    MensajeError("Falta Ingresar algunos datos, seran remarcados");
                    errorIcono.SetError(txtRazonSocial, "Ingrese la razon social");
                    errorIcono.SetError(txtNumDocumento, "Ingrese el numero de documento");
                    errorIcono.SetError(txtDireccion, "Ingrese la direccion");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NProveedor.Insertar(this.txtRazonSocial.Text.Trim().ToUpper(), this.cboxSectorComercial.Text, this.cboxTipoDocumento.Text.Trim().ToUpper(), this.txtNumDocumento.Text.Trim(), this.txtDireccion.Text.Trim(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(), this.txtUrl.Text.Trim());
                    }
                    else
                    {
                        rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdProveedor.Text.Trim()), this.txtRazonSocial.Text.Trim().ToUpper(), this.cboxSectorComercial.Text, this.cboxTipoDocumento.Text.Trim().ToUpper(), this.txtNumDocumento.Text.Trim(), this.txtDireccion.Text.Trim(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(), this.txtUrl.Text.Trim());
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            MensajeOk("Se inserto de forma correcta el registro");
                        }
                        else
                        {
                            MensajeOk("Se actualizo de forma correcta el registro");
                        }
                    }
                    else
                    {
                        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
 //guardar
 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,seran remarcados");
             errorIcono.SetError(txtRazon_social, "Ingrese la rzon social");
             errorIcono.SetError(txtNum_documento, "Ingrese el numero de documento");
             errorIcono.SetError(txtDireccion, "Ingrese su direccion");
         }
         else
         {
             if (this.isNuevo) //si es nuevo
             {                 //opcional txtNombre.Text.Trim.Upper
                 rpta = NProveedor.Insertar(this.txtRazon_social.Text, this.cmbSector_comercial.Text, this.cmbTipo_documento.Text, this.txtNum_documento.Text, this.txtDireccion.Text, this.txtTelefono.Text, this.txtEmail.Text, this.txtUrl.Text);
             }
             else
             {
                 rpta = NProveedor.Editar(Convert.ToInt32(this.txtIdproveedor.Text), this.txtRazon_social.Text, this.cmbSector_comercial.Text, this.cmbTipo_documento.Text, this.txtNum_documento.Text, this.txtDireccion.Text, this.txtTelefono.Text, this.txtEmail.Text, this.txtUrl.Text);
             }
             if (rpta.Equals("Ok"))
             {
                 if (this.isNuevo)
                 {
                     this.MensajeOk("Se inserto de forma correcta el registro");
                 }
                 else
                 {
                     this.MensajeOk("Se actualizo de forma correcta el registro");
                 }
             }
             else
             {
                 this.MensajeError(rpta);
             }
             //despues de editar o guardar dejarlos en false
             this.isNuevo  = false;
             this.isEditar = false;
             this.Botones();
             this.Limpiar();
             this.Mostrar();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }