Exemplo n.º 1
0
        private void Dtg_bebestible_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                var item = dtg_bebestible.SelectedItem as DataRowView;

                if (item != null)
                {
                    string        Orden = item.Row[0].ToString();
                    string        bebes = item.Row[2].ToString();
                    BebestibleBLL bb    = new BebestibleBLL();


                    int idb = bb.Get_bebyid(bebes);
                    int ido = Int32.Parse(Orden);
                    bb.Alter_bebestible_Despachado(ido, idb);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex);
            }
        }
        private void Btn_anular_Click(object sender, RoutedEventArgs e)
        {
            PedidoBLL      pb = new PedidoBLL();
            IngredienteBLL ib = new IngredienteBLL();
            BebestibleBLL  bb = new BebestibleBLL();
            DataTable      dt = new DataTable();

            int id_pe = Int32.Parse(txt_id_pedido.Text);

            string tipo     = pb.Get_tipo_pedido(id_pe);
            string ni       = txt_nombreInsumo.Text;
            int    idinsumo = -1;

            if (tipo == "Pedido de ingredientes")
            {
                idinsumo = ib.Get_idbynom(ni);
            }
            else if (tipo == "Pedido de bebestibles")
            {
                idinsumo = bb.Get_bebyid(ni);
            }
            pb.Anularpedido(id_pe, idinsumo);
            txt_id_pedido.Text          = "";
            txt_cant.Text               = "";
            txt_monto.Text              = "";
            txt_nombreInsumo.Text       = "";
            txt_stockcocina_bar.Text    = "";
            txt_stock_bodega.Text       = "";
            txt_stock_critico.Text      = "";
            txt_stock_total.Text        = "";
            cbb_proveedor.SelectedIndex = -1;

            if (tipo == "Pedido de bebestibles")
            {
                dt = pb.Get_detaPediById_bebestible(id_pe);
                dtg_detalle.ItemsSource = dt.DefaultView;
            }
            else if (tipo == "Pedido de ingredientes")
            {
                dt = pb.Get_detPediById_ingredientes(id_pe);
                dtg_detalle.ItemsSource = dt.DefaultView;
            }
        }
        private void Btn_Aceptar_pedido_Click(object sender, RoutedEventArgs e)
        {
            bool cantidad    = true;
            bool id_prov     = true;
            bool monto_total = true;


            if (txt_cant.Text.Trim() == "")
            {
                cantidad    = false;
                lb1.Content = "Debe ingresar una cantidad";
            }

            if (cbb_proveedor.SelectedIndex == -1)
            {
                id_prov     = false;
                lb2.Content = "Debe seleccionar un proveedor";
            }

            if (txt_monto.Text.Trim() == "")
            {
                monto_total = false;
                lb3.Content = "Ingrese un monto";
            }

            if (cantidad && id_prov && monto_total)
            {
                PedidoBLL      pb        = new PedidoBLL();
                BebestibleBLL  bb        = new BebestibleBLL();
                IngredienteBLL ib        = new IngredienteBLL();
                DataTable      dt        = new DataTable();
                int            id_pedido = Int32.Parse(txt_id_pedido.Text);
                int            monto     = Int32.Parse(txt_monto.Text);
                int            id_provee = Int32.Parse(cbb_proveedor.SelectedValue.ToString());
                string         ni        = txt_nombreInsumo.Text;
                string         tipo      = pb.Get_tipo_pedido(id_pedido);
                int            idinsumo  = -1;
                if (tipo == "Pedido de ingredientes")
                {
                    idinsumo = ib.Get_idbynom(ni);
                }
                else if (tipo == "Pedido de bebestibles")
                {
                    idinsumo = bb.Get_bebyid(ni);
                }
                int canti = Int32.Parse(txt_cant.Text);
                pb.Alter_detalle_pedido(canti, id_provee, monto, idinsumo, id_pedido);
                pb.Alter_montototalporboleta(id_pedido);
                txt_id_pedido.Text       = "";
                txt_cant.Text            = "";
                txt_monto.Text           = "";
                txt_nombreInsumo.Text    = "";
                txt_stockcocina_bar.Text = "";
                txt_stock_bodega.Text    = "";
                txt_stock_critico.Text   = "";
                txt_stock_total.Text     = "";
                if (rdb_todos.IsChecked == true)
                {
                    DataTable dtt = pb.Get_all_pedidos();
                    dtg_pedidos.ItemsSource = dtt.DefaultView;
                }
                else if (rdb_todos_hoy.IsChecked == true)
                {
                    DataTable dth = pb.Get_all_pedidos_hoy();
                    dtg_pedidos.ItemsSource = dth.DefaultView;
                }
                else if (rdb_todos_senana.IsChecked == true)
                {
                    DataTable dts = pb.Get_all_pedidos_semana();
                    dtg_pedidos.ItemsSource = dts.DefaultView;
                }
                else if (rdb_todos_mes.IsChecked == true)
                {
                    DataTable dtm = pb.Get_all_pedidos_mes();
                    dtg_pedidos.ItemsSource = dtm.DefaultView;
                }
                //cbb_proveedor.SelectedIndex = -1;

                if (tipo == "Pedido de bebestibles")
                {
                    dt = pb.Get_detaPediById_bebestible(id_pedido);
                    dtg_detalle.ItemsSource = dt.DefaultView;
                }
                else if (tipo == "Pedido de ingredientes")
                {
                    dt = pb.Get_detPediById_ingredientes(id_pedido);
                    dtg_detalle.ItemsSource = dt.DefaultView;
                }
            }
        }