private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text.Trim().Length <= 0)
            {
                MessageBox.Show("Debe indicar el nombre de la empresa", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                tabControlEmpresa.SelectedTab = tabDatosGenerales;
                txtNombre.Focus();
                return;
            }

            if (pbxLogoEmpresa.ImageLocation.Length > 0)
            {
                rutaImagen = pbxLogoEmpresa.ImageLocation.Replace("\\", "\\\\");
            }

            campos = " configuracion_empresa_nombre               = '" + txtNombre.Text.Trim() + "'," +
                     " configuracion_empresa_eslogan              = '" + txtEslogan.Text.Trim() + "'," +
                     " configuracion_empresa_rnc              = '" + txtIdentificacion.Text.Trim() + "'," +
                     " configuracion_empresa_direccion            = '" + txtDireccion.Text.Trim() + "'," +
                     " configuracion_empresa_telefono             = '" + txtTelefono.Text.Trim() + "'," +
                     " configuracion_empresa_correo_electronico   = '" + txtCorreoElectronico.Text.Trim() + "'," +
                     " configuracion_empresa_sitio_web            = '" + txtPaginaWeb.Text.Trim() + "'," +
                     " configuracion_empresa_logo                 = '" + rutaImagen + "'";
            tabla     = "Configuracion_empresa";
            condicion = " id = 1";
            try
            {
                if (conexion.actualizarRegistro(tabla, campos, condicion))
                {
                    MessageBox.Show("Configuración Actualizada", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error al actualizar el registro: " + error.Message, "Aviso - actualizarRegistro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text.Trim().Length <= 0)
            {
                MessageBox.Show("Debe indicar el nombre del vendedor", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                tabControlVendedores.SelectedTab = tabDatosGenerales;
                txtNombre.Focus();
                return;
            }

            if (pbxVendedor.ImageLocation.Length > 0)
            {
                rutaImagen = pbxVendedor.ImageLocation.Replace("\\", "\\\\");
            }

            if (string.IsNullOrEmpty(txtCodigo.Text))
            {
                tabla  = "Personas";
                campos = " persona_nombre, persona_identificacion, persona_correo_electronico, persona_direccion, persona_telefono_principal, " +
                         " persona_telefono_secundario, persona_fax, persona_celular, persona_observaciones, persona_tipo_id, persona_imagen";
                valores = "'" + txtNombre.Text.Trim() + "', '" + txtIdentificacion.Text.Trim() + "',  '" + txtCorreoElectronico.Text.Trim() + "'," +
                          "'" + txtDireccion.Text.Trim() + "', '" + txtTelefono1.Text.Trim() + "', '" + txtTelefono2.Text.Trim() + "'," +
                          "'" + txtFax.Text.Trim() + "', '" + txtCelular.Text.Trim() + "', '" + txtObservaciones.Text.Trim() + "'," +
                          "'3', '" + rutaImagen + "'";
                try
                {
                    if (conexion.insertarRegistro(tabla, campos, valores))
                    {
                        BuscarPersona();
                        tabla   = "Vendedores";
                        campos  = " persona_id, vendedor_comision";
                        valores = "'" + IdPersona + "','" + Comision + "'";
                        if (conexion.insertarRegistro(tabla, campos, valores))
                        {
                            MessageBox.Show("Registro Insertado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Limpiar(this);
                            LlenarDataGridView();
                        }
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al insertar el registro: " + error.Message, "Aviso - insertarRegistro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                campos = " persona_nombre               = '" + txtNombre.Text.Trim() + "'," +
                         " persona_identificacion       = '" + txtIdentificacion.Text.Trim() + "'," +
                         " persona_correo_electronico   = '" + txtCorreoElectronico.Text.Trim() + "'," +
                         " persona_direccion            = '" + txtDireccion.Text.Trim() + "'," +
                         " persona_telefono_principal   = '" + txtTelefono1.Text.Trim() + "'," +
                         " persona_telefono_secundario  = '" + txtTelefono2.Text.Trim() + "'," +
                         " persona_fax                  = '" + txtFax.Text.Trim() + "'," +
                         " persona_celular              = '" + txtCelular.Text.Trim() + "'," +
                         " persona_observaciones        = '" + txtObservaciones.Text.Trim() + "'," +
                         " persona_imagen               = '" + rutaImagen + "'";
                tabla     = " Personas";
                condicion = " id =" + IdPersona;
                try
                {
                    if (conexion.actualizarRegistro(tabla, campos, condicion))
                    {
                        campos    = " vendedor_comision    = '" + Comision + "'";
                        tabla     = " Vendedores";
                        condicion = " id =" + txtCodigo.Text;
                        if (conexion.actualizarRegistro(tabla, campos, condicion))
                        {
                            MessageBox.Show("Registro Actualizado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Limpiar(this);
                            LlenarDataGridView();
                        }
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el registro: " + error.Message, "Aviso - actualizarRegistro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
示例#3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (cmbTipoProducto.SelectedIndex < 0)
            {
                MessageBox.Show("Debe indicar un tipo de producto", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            if (cmbSuplidor.SelectedIndex < 0)
            {
                MessageBox.Show("Debe indicar un suplidor", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            if (string.IsNullOrEmpty(txtMesesGarantia.Text))
            {
                txtMesesGarantia.Text = "0";
            }

            if (string.IsNullOrEmpty(txtDiasEntrega.Text))
            {
                txtDiasEntrega.Text = "0";
            }

            if (string.IsNullOrEmpty(txtCodigo.Text))
            {
                string tabla  = "productos";
                string campos = "producto_nombre, producto_referencia, producto_codigo_barra, producto_costo, producto_precio, producto_descripcion, " +
                                "producto_meses_garantia, producto_dias_entrega, producto_bloqueado, producto_itbis, producto_inventario, " +
                                "tipo_producto_id, suplidor_id, producto_imagen";
                string valores = "'" + txtDenominacion.Text.Trim() + "', '" + txtReferencia.Text.Trim() + "', '" + txtCodigoBarra.Text.Trim() + "'," +
                                 "'" + txtCosto.Text.Trim() + "', '" + txtPrecioVenta.Text.Trim() + "', '" + txtDescripcion.Text.Trim() + "'," +
                                 "'" + txtMesesGarantia.Text.Trim() + "', '" + txtDiasEntrega.Text.Trim() + "', '" + chkBloqueado.Checked + "'," +
                                 "'" + chkITBIS.Checked + "', '" + chkProductoInventario.Checked + "', '" + cmbTipoProducto.SelectedValue + "'," +
                                 "'" + cmbSuplidor.SelectedValue + "', '" + pbxProducto.ImageLocation + "'";
                if (conexion.insertarRegistro(tabla, campos, valores))
                {
                    MessageBox.Show("Registro Insertado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Limpiar(this);
                    LlenarDataGridView();
                }
                else
                {
                    MessageBox.Show("Error al insertar registro", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
            }
            else
            {
                string campos = " producto_nombre            = '" + txtDenominacion.Text.Trim() + "'," +
                                " producto_referencia        = '" + txtReferencia.Text.Trim() + "'," +
                                " producto_codigo_barra      = '" + txtCodigoBarra.Text.Trim() + "'," +
                                " producto_costo             = '" + txtCosto.Text.Trim() + "'," +
                                " producto_precio            = '" + txtPrecioVenta.Text.Trim() + "'," +
                                " producto_descripcion       = '" + txtDescripcion.Text.Trim() + "'," +
                                " producto_meses_garantia    = '" + txtMesesGarantia.Text.Trim() + "'," +
                                " producto_dias_entrega      = '" + txtDiasEntrega.Text.Trim() + "'," +
                                " producto_bloqueado         = '" + chkBloqueado.Checked + "'," +
                                " producto_itbis             = '" + chkITBIS.Checked + "'," +
                                " producto_inventario        = '" + chkProductoInventario.Checked + "'," +
                                " tipo_producto_id           = '" + cmbTipoProducto.SelectedValue + "'," +
                                " suplidor_id                = '" + cmbSuplidor.SelectedValue + "'," +
                                " producto_imagen            = '" + pbxProducto.ImageLocation + "'";
                string tabla     = "productos";
                string condicion = " id =" + txtCodigo.Text;
                if (conexion.actualizarRegistro(tabla, campos, condicion))
                {
                    MessageBox.Show("Registro Actualizado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Limpiar(this);
                    LlenarDataGridView();
                }
                else
                {
                    MessageBox.Show("Error al actualizar el registro", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
            }
        }
示例#4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text.Trim().Length <= 0)
            {
                MessageBox.Show("Debe indicar el nombre del usuario", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                txtNombre.Focus();
                return;
            }

            if (txtUsuario.Text.Trim().Length <= 0)
            {
                MessageBox.Show("Debe indicar el usuario", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                txtUsuario.Focus();
                return;
            }

            if (txtContrasena.Text.Trim().Length <= 0)
            {
                MessageBox.Show("Debe indicar la contraseña", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                txtContrasena.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtCodigo.Text))
            {
                tabla   = "Usuarios";
                campos  = " usuario_nombre_completo, usuario_nombre, usuario_contrasena, usuario_tipo_id, usuario_estado_registro";
                valores = "'" + txtNombre.Text.Trim() + "', '" + txtUsuario.Text.Trim() + "', md5('" + txtContrasena.Text.Trim() + "')," +
                          "'" + cmbTiposUsuarios.SelectedValue + "', '" + Bloqueado + "'";
                try
                {
                    if (conexion.insertarRegistro(tabla, campos, valores))
                    {
                        MessageBox.Show("Registro Insertado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Limpiar(this);
                        LlenarDataGridView();
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al insertar el registro: " + error.Message, "Aviso - insertarRegistro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                campos = " usuario_nombre_completo  = '" + txtNombre.Text.Trim() + "'," +
                         " usuario_nombre           = '" + txtUsuario.Text.Trim() + "'," +
                         " usuario_contrasena       = md5('" + txtContrasena.Text.Trim() + "')," +
                         " usuario_tipo_id          = '" + cmbTiposUsuarios.SelectedValue + "'," +
                         " usuario_estado_registro  = '" + Bloqueado + "'";
                tabla     = " usuarios";
                condicion = " id =" + txtCodigo.Text;
                try
                {
                    if (conexion.actualizarRegistro(tabla, campos, condicion))
                    {
                        MessageBox.Show("Registro Actualizado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Limpiar(this);
                        LlenarDataGridView();
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el registro: " + error.Message, "Aviso - actualizarRegistro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }