Exemple #1
0
        private void Btn_Busca_Ped_Click(object sender, RoutedEventArgs e)
        {
            Recepcionar_Pedido_Negocio  RecepN  = new Recepcionar_Pedido_Negocio();
            List <Recepcion_pedido_dto> detalle = new List <Recepcion_pedido_dto>();
            DataTable          resp             = new DataTable();
            Compartido_Negocio comp             = new Compartido_Negocio();

            if (txt_id_pedido.Text != "")
            {
                try
                {
                    resp = RecepN.ObternerPedidoHDR(txt_id_pedido.Text);
                    if (resp.Rows.Count > 0)
                    {
                        foreach (DataRow item in resp.Rows)
                        {
                            txt_id_pedido.Text = item["ID_PEDIDO"].ToString();
                            //   txt_id_prod_recep.Text = item["ID_PRODUCTO"].ToString();
                            cmb_estado_recep.SelectedValue = item["id_estado"].ToString();
                            cmb_empleado.SelectedValue     = item["id_empleado"].ToString();
                            cmb_proveedor.SelectedValue    = item["id_proveedor"].ToString();
                            txt_total_recep.Text           = item["id_proveedor"].ToString();
                            txt_total_recep.Text           = decimal.Parse(item["TOTAL_PEDIDO"].ToString()).ToString("n2");
                        }
                        if (cmb_estado_recep.Text == "Finalizado" || cmb_estado_recep.Text == "Anulado")
                        {
                            if (cmb_estado_recep.Text == "Finalizado")
                            {
                                detalle = RecepN.ListarDetallePedido(txt_id_pedido.Text);
                                DG_Recep.ItemsSource             = detalle;
                                this.Btn_Confirmar_Rec.IsEnabled = false;
                                this.DG_Recep.IsEnabled          = false;
                                MessageBox.Show("El pedido número : " + txt_id_pedido.Text + " ya fue recepcionado");
                            }
                            else
                            {
                                detalle = RecepN.ListarDetallePedido(txt_id_pedido.Text);
                                DG_Recep.ItemsSource             = detalle;
                                this.Btn_Confirmar_Rec.IsEnabled = false;
                                this.DG_Recep.IsEnabled          = false;
                                MessageBox.Show("El pedido número : " + txt_id_pedido.Text + " fue anulado");
                            }
                        }
                        else
                        {
                            detalle = RecepN.ListarDetallePedido(txt_id_pedido.Text);
                            DG_Recep.ItemsSource             = detalle;
                            this.Btn_Confirmar_Rec.IsEnabled = true;
                            this.DG_Recep.IsEnabled          = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show("ID invalido");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Busqueda no arrojó resultados");
                    throw ex;
                }
            }
            else
            {
                MessageBox.Show("Debe ingresar un ID Pedido para la busqueda");
            }
        }
Exemple #2
0
        private void Btn_Confirmar_Rec_Click(object sender, RoutedEventArgs e)
        {
            txt_id_recep.Text = "";
            bool                       SkuVacio     = false;
            string                     cabecera     = "";
            bool                       aumentar     = false;
            bool                       new_estado   = false;
            Producto_Negocio           producto_Neg = new Producto_Negocio();
            Recepcionar_Pedido_Negocio Recepnegocio = new Recepcionar_Pedido_Negocio();

            var    SelectProd     = DG_Recep.ItemsSource;
            var    JsonItemSelect = JsonConvert.SerializeObject(SelectProd);
            JArray jsonPreservar  = JArray.Parse(JsonItemSelect.ToString());

            foreach (JObject item in jsonPreservar.Children <JObject>())
            {
                if (item["SKU"].ToString() == "" && SkuVacio == false)
                {
                    MessageBox.Show(" El Producto : " + item["Descripción"].ToString() + " se encuentra sin su SKU");
                    SkuVacio = true;
                }
            }
            if (cmb_estado_recep.Text != "Generado")
            {
                if (SkuVacio == false)
                {
                    // var total = Math.Round(decimal.Parse(item["TOTAL"].ToString()), 0).ToString().Replace(".", "");
                    cabecera   = Recepnegocio.CrearRecepcionHDR(txt_fecha_recep.Text, cmb_estado_recep.SelectedValue.ToString(), txt_id_pedido.Text, cmb_empleado.SelectedValue.ToString(), cmb_proveedor.SelectedValue.ToString(), txt_total_recep.Text);
                    new_estado = Recepnegocio.Cambiar_Estado_Pedido(txt_id_pedido.Text, cmb_estado_recep.SelectedValue.ToString());
                    foreach (JObject item in jsonPreservar.Children <JObject>())
                    {
                        try
                        {
                            var precio = Math.Round(decimal.Parse(item["Precio"].ToString()), 0).ToString().Replace(".", "");
                            var total  = Math.Round(decimal.Parse(item["Total"].ToString()), 0).ToString().Replace(".", "");

                            Recepnegocio.CrearRecepcionDet(item["Recibido"].ToString(),
                                                           precio,
                                                           item["SKU"].ToString(),
                                                           cabecera,
                                                           item["IDProducto"].ToString(),
                                                           total);
                            aumentar = producto_Neg.Aumentar_cant_prod(item["IDProducto"].ToString(),
                                                                       item["Recibido"].ToString());
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    // aumentar = producto_Neg.Aumentar_cant_prod();
                    txt_id_recep.Text = cabecera;
                    this.Btn_Confirmar_Rec.IsEnabled = false;
                    MessageBox.Show("Recepción realizada con éxito");
                }
            }
            else
            {
                MessageBox.Show("Debe Cambiar el estado del pedido");
            }
        }