예제 #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);
     }
 }
        private void cbHojaExcel_SelectedIndexChanged(object sender, EventArgs e)
        {
            dgvExcelImportar.DataSource = null;
            prodImports.Clear();
            bool bandera = false;

            AuxCategorias.Clear();
            AuxProveedores.Clear();
            DataTable dt = tableCollection[cbHojaExcel.SelectedItem.ToString()];

            //dgvExcelImportar.DataSource = dt;
            try
            {
                if (dt != null)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ProductoImport pImp = new ProductoImport();
                        pImp.Codigo        = dt.Rows[i]["Codigo"].ToString();
                        pImp.Nombre        = dt.Rows[i]["Nombre"].ToString();
                        pImp.Marca         = dt.Rows[i]["Marca"].ToString();
                        pImp.Stock         = Convert.ToInt32(dt.Rows[i]["Stock"].ToString());
                        pImp.Precio_compra = Convert.ToDecimal(dt.Rows[i]["Precio_Compra"].ToString());
                        pImp.Precio_venta  = Convert.ToDecimal(dt.Rows[i]["Precio_Venta"].ToString());
                        if (NCategoria.NombreExistente(dt.Rows[i]["Categoria"].ToString()))
                        {
                            pImp.Categoria = dt.Rows[i]["Categoria"].ToString();
                        }
                        else
                        {
                            NCategoria.Insertar(dt.Rows[i]["Categoria"].ToString(), "");
                            AuxCategorias.Add(dt.Rows[i]["Categoria"].ToString());
                            pImp.Categoria = dt.Rows[i]["Categoria"].ToString();
                        }
                        if (NProveedor.NombreExistente(dt.Rows[i]["Proveedor"].ToString()))
                        {
                            pImp.Proveedor = dt.Rows[i]["Proveedor"].ToString();
                        }
                        else
                        {
                            NProveedor.Insertar(dt.Rows[i]["Proveedor"].ToString(), "");
                            AuxProveedores.Add(dt.Rows[i]["Proveedor"].ToString());
                            pImp.Proveedor = dt.Rows[i]["Proveedor"].ToString();
                        }
                        prodImports.Add(pImp);
                        bandera = true;
                    }
                    if (bandera)
                    {
                        MessageBox.Show("Se realizó una importacion parcial de categorias y proveedores," +
                                        "si no importa los datos y cierra el fomulario se eliminaran automaticamente los datos parcialmente cargados!");
                        dgvExcelImportar.DataSource = prodImports;
                        lblRegistros.Text           = "Registros: " + dgvExcelImportar.Rows.Count.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }