コード例 #1
0
        public void ImpQrProd(Eproductos item)
        {
            List <Eproductos> prods = new List <Eproductos>()
            {
                item
            };
            LocalReport report    = new LocalReport();
            string      Telefono  = ConfigurationManager.AppSettings["Telefono"];
            string      Domicilio = ConfigurationManager.AppSettings["Domicilio"];
            string      Razon     = ConfigurationManager.AppSettings["Razon"];

            report.ReportPath = @"..\..\Reportes\Codigos.rdlc";

            report.DataSources.Add(new ReportDataSource("Productos", prods));
            report.EnableExternalImages = true;

            List <ReportParameter> paramList = new List <ReportParameter>();
            string file = "";

            string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\QRS";

            file = dir + "\\" + item.codigoBarras.Trim() + ".jpg";


            if (!File.Exists(file))
            {
                GetQR(item.codigoBarras);
            }

            paramList.Add(new ReportParameter("UrlImg", @"file:\" + new Uri(file).AbsolutePath));

            report.SetParameters(paramList);
            Export(report);
            Print();
        }
コード例 #2
0
        public void Insertar()
        {
            try
            {
                if (producto == null)
                {
                    producto = new Eproductos();
                }
                producto.a             = "Insertar";
                producto.descripcion   = txtDescri.Text;
                producto.refencia      = txtRef.Text;
                producto.marca         = txtMarca.Text;
                producto.fabricante    = txtFabri.Text;
                producto.cantidad      = int.Parse(txtCan.Text);
                producto.precio_mayor  = int.Parse(txtPreMa.Text);
                producto.precio_compra = int.Parse(txtPreCom.Text);
                producto.precio_venta  = int.Parse(txtPreVen.Text);

                acceso_producto.InsertarProductos(producto);
                if (acceso_producto.stringBuilder.Length != 0)
                {
                    MessageBox.Show(acceso_producto.stringBuilder.ToString(), "Para continuar:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("PRODUCTO registrado correctamente", "PRODUCTO REGISTRADO", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("ERROR {0}", ex.Message), "ERROR INESPERADO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
 public void InsertarProductos(Eproductos producto)
 {
     try {
         con.ConnectionString = Conexion.cadenaConexion;
         comando             = new SqlCommand("Sp_productos", con);
         comando.CommandType = CommandType.StoredProcedure;
         comando.Parameters.AddWithValue("@a", producto.a);
         comando.Parameters.AddWithValue("@id_producto", "");
         comando.Parameters.AddWithValue("@descripcion", producto.descripcion);
         comando.Parameters.AddWithValue("@referencia", producto.refencia);
         comando.Parameters.AddWithValue("@marca", producto.marca);
         comando.Parameters.AddWithValue("@fabricante", producto.fabricante);
         comando.Parameters.AddWithValue("@cantidad", producto.cantidad);
         comando.Parameters.AddWithValue("@precio_por_mayor", producto.precio_mayor);
         comando.Parameters.AddWithValue("@precio_venta", producto.precio_venta);
         comando.Parameters.AddWithValue("@precio_compra", producto.precio_compra);
         con.Open();
         comando.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         con.Close();
     }
 }
コード例 #4
0
        private List <Eproductos> getLista()
        {
            List <Eproductos> productos = new List <Eproductos>();

            foreach (DataGridViewRow item in DgProductos.Rows)
            {
                if (item.Cells[1].Value != null)
                {
                    if ((int)item.Cells[1].Value != 0)
                    {
                        Eproductos prods = new Eproductos();

                        prods.idProducto   = (int)item.Cells[0].Value;
                        prods.idUnidad     = (int)item.Cells[1].Value;
                        prods.descripcion  = (string)item.Cells[2].Value;
                        prods.codigoBarras = (string)item.Cells[3].Value;
                        prods.precio       = decimal.Parse(item.Cells[4].Value.ToString());
                        prods.precioReal   = decimal.Parse(item.Cells[5].Value.ToString());
                        prods.cantidad     = decimal.Parse(item.Cells[6].Value.ToString());
                        prods.estado       = (bool)item.Cells[7].Value;

                        productos.Add(prods);
                    }
                }
            }

            return(productos);
        }
コード例 #5
0
 private bool ValidarProductos(Eproductos producto)
 {
     stringBuilder.Clear();
     if (string.IsNullOrEmpty(producto.descripcion))
     {
         stringBuilder.Append("El campo DESCRIPCION es obligatorio");
     }
     if (string.IsNullOrEmpty(producto.fabricante))
     {
         stringBuilder.Append(Environment.NewLine + "El campo FABRICANTE es obligatorio");
     }
     if (string.IsNullOrEmpty(producto.marca))
     {
         stringBuilder.Append(Environment.NewLine + "El campo MARCA es obligatorio");
     }
     if (string.IsNullOrEmpty(producto.cantidad.ToString()))
     {
         stringBuilder.Append(Environment.NewLine + "El campo CANTIDAD es obligatorio");
     }
     if (string.IsNullOrEmpty(producto.precio_mayor.ToString()))
     {
         stringBuilder.Append(Environment.NewLine + "El campo PRECIO POR MAYOR es obligatorio");
     }
     if (string.IsNullOrEmpty(producto.precio_venta.ToString()))
     {
         stringBuilder.Append(Environment.NewLine + "El campo PRECIO VENTA es obligatorio");
     }
     if (string.IsNullOrEmpty(producto.precio_compra.ToString()))
     {
         stringBuilder.Append(Environment.NewLine + "El campo PRECIO COMPRA es obligatorio");
     }
     return(stringBuilder.Length == 0);
 }
コード例 #6
0
 public void InsertarProductos(Eproductos producto)
 {
     if (ValidarProductos(producto))
     {
         acceso_datos.InsertarProductos(producto);
     }
 }
コード例 #7
0
ファイル: LCargaMasiva.cs プロジェクト: herrerabc/TPV
        private void saveProducto(Eproductos item, ref ETransactionResult res)
        {
            Daproductos db = new Daproductos();

            db.productos_Insert(item, ref res);

            if (res.result == 0)
            {
                EMovimiento        mov     = new EMovimiento();
                EMovimientoDetalle detalle = new EMovimientoDetalle();
                ETransactionResult result  = new ETransactionResult();
                int     idDetalle          = 0;
                decimal totalCantidad      = 0;

                mov.fecha            = DateTime.Now;
                mov.idMovimiento     = (int)getIdMovimiento();
                mov.idTipoMovimiento = "EPT";
                mov.usuario          = "admin";

                totalCantidad = item.cantidad;
                idDetalle     = (int)getIdMovimientoDet();

                detalle.idDetalle      = idDetalle;
                detalle.idMovimiento   = mov.idMovimiento;
                detalle.tipoAfectacion = "E";
                detalle.idProducto     = item.idProducto;
                detalle.cantidad       = totalCantidad;

                _movimiento.Movimiento_Insert(mov, ref result);
                if (result.result == 0)
                {
                    _movimientoDetalle.MovimientoDetalle_Insert(detalle, ref result);
                }
            }
        }
コード例 #8
0
ファイル: Daproductos.cs プロジェクト: herrerabc/TPV
        public Eproductos productos_Get(Eproductos item, ref ETransactionResult _transResult)
        {
            Eproductos itemFinded = null;

            _transResult = new ETransactionResult();
            SqlTransaction transaction = null;

            try
            {
                using (SqlConnection sqlCon = new SqlConnection(conn))
                {
                    sqlCon.Open();
                    using (SqlCommand sqlCmd = new SqlCommand())
                    {
                        transaction        = sqlCon.BeginTransaction("SelectTransaction");
                        sqlCmd.Transaction = transaction;
                        sqlCmd.Connection  = sqlCon;
                        sqlCmd.CommandType = CommandType.StoredProcedure;
                        sqlCmd.Parameters.AddWithValue("@idProducto", item.idProducto);
                        sqlCmd.CommandText = "D_PR_productos_Select";
                        using (var reader = sqlCmd.ExecuteReader())
                            while (reader.Read())
                            {
                                itemFinded              = new Eproductos();
                                itemFinded.idProducto   = (int)reader["idProducto"];
                                itemFinded.idUnidad     = reader["idUnidad"] == DBNull.Value ? null : (int?)reader["idUnidad"];
                                itemFinded.descripcion  = (string)reader["descripcion"];
                                itemFinded.codigoBarras = (string)reader["codigoBarras"];
                                itemFinded.precio       = (decimal)reader["precio"];
                                itemFinded.precioReal   = (decimal)reader["precioReal"];
                                itemFinded.cantidad     = (decimal)reader["cantidad"];
                                itemFinded.estado       = (bool)reader["estado"];
                            }
                        transaction.Commit();
                        _transResult.message = "OK";
                        _transResult.result  = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                _transResult.message = ex.Message;
                _transResult.result  = 1;
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollBackEx)
                {
                    _transResult.rollbackMessage = rollBackEx.Message;
                    _transResult.result          = 1;
                }
            }
            return(itemFinded);
        }
コード例 #9
0
ファイル: Daproductos.cs プロジェクト: herrerabc/TPV
        public List <Eproductos> productos_GetAll(ref ETransactionResult _transResult)
        {
            var list = new List <Eproductos>();

            _transResult = new ETransactionResult();
            SqlTransaction transaction = null;

            try
            {
                using (SqlConnection sqlCon = new SqlConnection(conn))
                {
                    sqlCon.Open();
                    using (SqlCommand sqlCmd = new SqlCommand())
                    {
                        transaction        = sqlCon.BeginTransaction("SelectAllTranstaction");
                        sqlCmd.Transaction = transaction;
                        sqlCmd.Connection  = sqlCon;
                        sqlCmd.CommandType = CommandType.StoredProcedure;
                        sqlCmd.CommandText = "D_PR_productos_SelectAll";
                        using (var reader = sqlCmd.ExecuteReader())
                            while (reader.Read())
                            {
                                var item = new Eproductos();
                                item.idProducto   = (int)reader["idProducto"];
                                item.idUnidad     = reader["idUnidad"] == DBNull.Value ? null : (int?)reader["idUnidad"];
                                item.descripcion  = (string)reader["descripcion"];
                                item.codigoBarras = (string)reader["codigoBarras"];
                                item.precio       = (decimal)reader["precio"];
                                item.precioReal   = (decimal)reader["precioReal"];
                                item.cantidad     = (decimal)reader["cantidad"];
                                item.estado       = (bool)reader["estado"];
                                list.Add(item);
                            }
                        transaction.Commit();
                        _transResult.message = "OK";
                        _transResult.result  = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                _transResult.message = ex.Message;
                _transResult.result  = 1;
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollBackEx)
                {
                    _transResult.rollbackMessage = rollBackEx.Message;
                    _transResult.result          = 1;
                }
            }
            return(list);
        }
コード例 #10
0
 public static bool ActualizarProductos(Eproductos producto)
 {
     datos = acceso_datos.ActualizarProductos(producto);
     if (datos.Rows.Count > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #11
0
ファイル: Productos.cs プロジェクト: herrerabc/TPV
        private void btnQD_Click(object sender, EventArgs e)
        {
            Impresion          imp    = new Impresion();
            ETransactionResult result = new ETransactionResult();
            Eproductos         item   = new Eproductos()
            {
                idProducto = int.Parse(txtIdProd.Text.Trim())
            };

            item = (Eproductos)_productos.Get(item, ref result);

            imp.ImpQrProd(item);
        }
コード例 #12
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (producto == null)
            {
                producto = new Eproductos();
            }


            #region No duplicar valor en dataGrid
            try
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (txtDescRProducto.Text == row.Cells["referencia"].Value.ToString())
                    {
                        MessageBox.Show("YA SE INSERTO ESTE PRODUCTO");
                        txtDescRProducto.Clear();
                        txtDescRProducto.Focus();
                        return;
                    }
                }
            }
            catch { }
            #endregion ;

            producto.a           = "Buscar";
            producto.descripcion = txtDescRProducto.Text;
            producto.refencia    = txtDescRProducto.Text;

            if (Acceso_Productos.BuscarProductos(producto))
            {
                gvDatos.DataSource = Acceso_Productos.datos;
                id_producto        = int.Parse(gvDatos.CurrentRow.Cells["id_producto"].Value.ToString());
                txtDescri.Text     = gvDatos.CurrentRow.Cells["descripcion"].Value.ToString();
                txtRef.Text        = gvDatos.CurrentRow.Cells["referencia"].Value.ToString();
                txtMarca.Text      = gvDatos.CurrentRow.Cells["marca"].Value.ToString();
                txtFabri.Text      = gvDatos.CurrentRow.Cells["fabricante"].Value.ToString();
                txtCan.Text        = gvDatos.CurrentRow.Cells["cantidad"].Value.ToString();
                txtPreCom.Text     = gvDatos.CurrentRow.Cells["precio_compra"].Value.ToString();
                txtPreMa.Text      = gvDatos.CurrentRow.Cells["precio_por_mayor"].Value.ToString();
                txtPreVen.Text     = gvDatos.CurrentRow.Cells["precio_venta"].Value.ToString();

                btnAdd.Enabled   = true;
                txtDescu.Enabled = true;
            }
            else
            if (MessageBox.Show("ESTE PRODUCTO NO EXISTE DESEA AGREGAR ESTE PRODUCTO", "PARA CONTINUAR:", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                habilitarText();
            }
        }
コード例 #13
0
ファイル: EdicionMasiva.cs プロジェクト: herrerabc/TPV
        private string validaProducto(Eproductos item)
        {
            string validacion = string.Empty;

            if (string.IsNullOrEmpty(item.descripcion))
            {
                validacion += "\n La descripción del producto " + item.idProducto.ToString() + " no puede ir vacia.";
            }
            if (string.IsNullOrEmpty(item.codigoBarras))
            {
                validacion += "\n El Codigo de Barras del producto " + item.idProducto.ToString() + " no puede ir vacio.";
            }

            return(validacion);
        }
コード例 #14
0
 public DataTable ActualizarProductos(Eproductos producto)
 {
     con.ConnectionString = Conexion.cadenaConexion;
     comando             = new SqlCommand("Sp_productos", con);
     comando.CommandType = CommandType.StoredProcedure;
     comando.Parameters.AddWithValue("@a", producto.a);
     comando.Parameters.AddWithValue("@id_producto", producto.Id);
     comando.Parameters.AddWithValue("@descripcion", "");
     comando.Parameters.AddWithValue("@referencia", "");
     comando.Parameters.AddWithValue("@marca", "");
     comando.Parameters.AddWithValue("@fabricante", "");
     comando.Parameters.AddWithValue("@cantidad", producto.cantidad);
     comando.Parameters.AddWithValue("@precio_por_mayor", "");
     comando.Parameters.AddWithValue("@precio_venta", "");
     comando.Parameters.AddWithValue("@precio_compra", "");
     return(MetodosDatos.ejecutarComandoSelect(comando));
 }
コード例 #15
0
ファイル: Daproductos.cs プロジェクト: herrerabc/TPV
        public void productos_Delete(Eproductos item, ref ETransactionResult _transResult)
        {
            _transResult = new ETransactionResult();
            SqlTransaction transaction = null;

            try
            {
                using (SqlConnection sqlCon = new SqlConnection(conn))
                {
                    sqlCon.Open();
                    using (SqlCommand sqlCmd = new SqlCommand())
                    {
                        transaction        = sqlCon.BeginTransaction("DeleteTransaction");
                        sqlCmd.Transaction = transaction;
                        sqlCmd.Connection  = sqlCon;
                        sqlCmd.CommandType = CommandType.StoredProcedure;
                        sqlCmd.CommandText = "D_PR_productos_Delete";
                        sqlCmd.Parameters.AddWithValue("@idProducto", item.idProducto);
                        sqlCmd.ExecuteNonQuery();
                        transaction.Commit();
                        _transResult.message = "OK";
                        _transResult.result  = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                _transResult.message = ex.Message;
                _transResult.result  = 1;
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollBackEx)
                {
                    _transResult.rollbackMessage = rollBackEx.Message;
                    _transResult.result          = 1;
                }
            }
        }
コード例 #16
0
        private void setMovimiento(Eproductos item)
        {
            EMovimiento        mov     = new EMovimiento();
            EMovimientoDetalle detalle = new EMovimientoDetalle();
            ETransactionResult result  = new ETransactionResult();
            int     idDetalle          = 0;
            decimal totalCantidad      = 0;

            mov.fecha            = DateTime.Now;
            mov.idMovimiento     = (int)getIdMovimiento();
            mov.idTipoMovimiento = "EPT";
            mov.usuario          = usuario;
            mov.observacion      = "";

            totalCantidad = item.cantidad;
            idDetalle     = (int)getIdMovimientoDet();

            detalle.idDetalle      = idDetalle;
            detalle.idMovimiento   = mov.idMovimiento;
            detalle.tipoAfectacion = (totalCantidad < 0 ? "S" : "E");
            detalle.idProducto     = item.idProducto;
            detalle.cantidad       = Math.Abs(totalCantidad);

            _movimiento.Insert(mov, ref result);
            if (result.result == 0)
            {
                _movimientoDetalle.Insert(detalle, ref result);

                if (result.result != 0)
                {
                    Log.Error("Error al insertar detalle movimiento: " + result.message);
                }
            }
            else
            {
                Log.Error("Error al insertar movimiento: " + result.message);
            }
        }
コード例 #17
0
ファイル: Productos.cs プロジェクト: herrerabc/TPV
        private void llenaPnatalla()
        {
            ETransactionResult result = new ETransactionResult();
            Eproductos         prod   = (Eproductos)_productos.Get(new Eproductos {
                idProducto = int.Parse(codigoProducto.ToString())
            }, ref result);
            List <EunidadMedida> unidadMedida = _unidadMedida.GetAll(ref result).Cast <EunidadMedida>().ToList();

            cboUnidad.DisplayMember = "Descripcion";
            cboUnidad.ValueMember   = "Id";
            cboUnidad.DataSource    = unidadMedida.Select(p => new { Id = p.idUnidad, Descripcion = p.descripcion }).ToList();

            txtDescripcion.Text     = prod.descripcion;
            txtCodigoBarras.Text    = prod.codigoBarras;
            txtPrecio.Text          = prod.precio.ToString();
            txtPrecioReal.Text      = prod.precioReal.ToString();
            txtCantidad.Text        = prod.cantidad.ToString();
            cantidadInicial         = prod.cantidad;
            cboUnidad.SelectedValue = prod.idUnidad;
            chkEstado.Checked       = prod.estado;

            txtIdProd.Text = codigoProducto.ToString();
        }
コード例 #18
0
ファイル: Productos.cs プロジェクト: herrerabc/TPV
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (txtDescripcion.Text == string.Empty)
            {
                msjValida();
                txtDescripcion.Focus();
                return;
            }
            if (txtCodigoBarras.Text == string.Empty)
            {
                msjValida();
                txtCodigoBarras.Focus();
                return;
            }
            if (txtPrecio.Text == string.Empty)
            {
                msjValida();
                txtPrecio.Focus();
                return;
            }

            if (txtPrecioReal.Text == string.Empty)
            {
                msjValida();
                txtPrecioReal.Focus();
                return;
            }

            if (txtCantidad.Text == string.Empty)
            {
                msjValida();
                txtCantidad.Focus();
                return;
            }
            if (cboUnidad.SelectedIndex == -1)
            {
                msjValida();
                cboUnidad.Focus();
                return;
            }
            try
            {
                ETransactionResult result = new ETransactionResult();
                Eproductos         prod   = new Eproductos();

                prod.idProducto   = Convert.ToInt32(txtIdProd.Text);
                prod.idUnidad     = Convert.ToInt32(cboUnidad.SelectedValue.ToString());
                prod.descripcion  = txtDescripcion.Text;
                prod.codigoBarras = txtCodigoBarras.Text;
                prod.precio       = Convert.ToDecimal(txtPrecio.Text);
                prod.precioReal   = Convert.ToDecimal(txtPrecioReal.Text);
                prod.cantidad     = Convert.ToDecimal(txtCantidad.Text);
                prod.estado       = chkEstado.Checked;

                if (cambio)
                {
                    _productos.Update(prod, ref result);
                }
                else
                {
                    _productos.Insert(prod, ref result);
                }

                if (result.result != 0)
                {
                    throw new Exception(result.message);
                }

                setMovimiento();
                MessageBox.Show("Se guardo el cambio correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                Log.Error("Error al guardar producto", ex);
                MessageBox.Show("Error al guardar el cambio: " + ex.Message + " " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.DialogResult = DialogResult.OK;
            Close();
        }