Ejemplo n.º 1
0
 private void btnEditar_Click_1(object sender, EventArgs e)
 {
     try
     {
         ProductosLista operador = (ProductosLista)dgvProductos.CurrentRow.DataBoundItem;
         AltaProducto   form     = new AltaProducto(operador.Id);
         form.ShowDialog();
         CargarGrilla();
     }
     catch (Exception ex)
     {
         _Log.Error($"btnEditar_Click Exception: {ex}");
         CargarGrilla();
     }
 }
Ejemplo n.º 2
0
 private void btnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         //todo _MesaProRepo
         ProductosLista prodDgv = (ProductosLista)dgvProducto.CurrentRow.DataBoundItem;
         _MesaProRepo.InsertTempPedidoMesa(_IdMesa, prodDgv.Id);
         CargarListadoPedido();
     }
     catch (Exception ex)
     {
         _Log.Error($"GesationMesaOcupada btnAgregar_Click exception: {ex}");
         MessageBox.Show("Ops, se produjo un inconveniente. Contacte con sistemas.");
     }
 }
        public List <ProductosLista> GetProductos()
        {
            List <ProductosLista> resultado = new List <ProductosLista>();
            ProductosLista        registro;

            try
            {
                #region Using SQL Connection
                using (SqlConnection cn = new SqlConnection())
                {
                    cn.ConnectionString = ConfigurationManager.AppSettings["TPPROG"];
                    cn.Open();

                    #region Using Sql Command
                    using (SqlCommand cm = new SqlCommand())
                    {
                        cm.CommandType = CommandType.StoredProcedure;
                        cm.CommandText = "SP_GetAllProductos";
                        cm.Connection  = cn;

                        #region Log
                        string log = $"EXEC {cm.CommandText} ";
                        foreach (SqlParameter i in cm.Parameters)
                        {
                            switch (i.SqlDbType)
                            {
                            case SqlDbType.VarChar:
                                log += String.Format("'{0}',", (i.Value == null ? "NULL" : i.Value));
                                break;

                            case SqlDbType.DateTime:
                                log += String.Format("'{0:yyyyMMdd HH:mm:ss.fff}',", (i.Value == null ? "NULL" : i.Value));
                                break;

                            default:
                                log += String.Format("{0},", (i.Value == null ? "NULL" : i.Value));
                                break;
                            }
                        }

                        log = log.Substring(0, log.Length - 1);
                        _Log.Info(log);
                        #endregion

                        SqlDataReader rd = cm.ExecuteReader();

                        while (rd.Read())
                        {
                            registro             = new ProductosLista();
                            registro.Id          = rd.GetInt32(0);
                            registro.Precio      = rd.GetDecimal(1);
                            registro.Stock       = rd.GetInt32(2);
                            registro.Descripcion = string.IsNullOrEmpty(rd.GetString(3)) ? string.Empty : rd.GetString(3);
                            registro.Sku         = string.IsNullOrEmpty(rd.GetString(4)) ? string.Empty : rd.GetString(4);

                            resultado.Add(registro);
                        }

                        cm.Dispose();
                    }
                    #endregion
                    cn.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                _Log.Error($"EjecutarProcedure AltaOperador Exception: {ex}");
            }

            return(resultado);
        }