示例#1
0
        private void Form_entrada_Load(object sender, EventArgs e)
        {
            dtFecha.Format       = DateTimePickerFormat.Custom;
            dtFecha.CustomFormat = "yyyy-MM-dd";

            if (folio == "0")
            {
                txtCantidad.Text    = "";
                txtCodigo.Text      = "";
                txtDescripcion.Text = "";
                txtTotal.Text       = "";
                txtFolio.Text       = "";
                txtCosto.Text       = "";
                id = "0";
            }
            else
            {
                Inv_in inv_in = new Inv_in();
                using (inv_in)
                {
                    List <Inv_in> data = inv_in.getListabyId(folio);
                    foreach (Inv_in item in data)
                    {
                        txtFolio.Text = folio;
                        txtTotal.Text = item.Total.ToString();
                        dtFecha.Text  = item.Date.ToString();
                    }
                }



                Product      producto = new Product();
                Det_entradas detalles = new Det_entradas();
                using (detalles)
                {
                    List <Det_entradas> det = detalles.getDet_entradas(Convert.ToInt16(folio));
                    foreach (Det_entradas item in det)
                    {
                        using (producto)
                        {
                            List <Product> det_producto = producto.getProductById(item.Id_producto);
                            foreach (Product res in det_producto)
                            {
                                dtProductos.Rows.Add(item.Id_producto, res.Code1, item.Cantidad, res.Description, item.P_u, item.Total.ToString());
                            }
                        }
                    }
                }



                txtCantidad.Enabled    = false;
                txtCodigo.Enabled      = false;
                txtDescripcion.Enabled = false;
                button1.Enabled        = false;
                button2.Enabled        = false;
                dtFecha.Enabled        = false;
                dtProductos.Columns["cantidad"].ReadOnly = true;
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Inv_in entrada = new Inv_in(
                Convert.ToInt16(folio),
                dtFecha.Text + " 00:00:00",
                "",
                Convert.ToDouble(txtTotal.Text),
                "A"
                );

            Det_entradas det      = new Det_entradas();
            Kardex       kardex   = new Kardex();
            Product      producto = new Product();
            Afecta_inv   afecta   = new Afecta_inv();
            int          nuevo    = 0;

            det.Id = 0;

            if (folio == "0")
            {
                using (entrada)
                {
                    entrada.createInv_in();
                    List <Inv_in> result = entrada.getListabyAll(dtFecha.Text + " 00:00:00", Convert.ToDouble(txtTotal.Text));
                    folio = result[0].Id.ToString();

                    det.Id_entrada = Convert.ToInt16(folio);
                    foreach (DataGridViewRow row in dtProductos.Rows)
                    {
                        det.Cantidad    = Convert.ToInt16(row.Cells["cantidad"].Value.ToString());
                        det.Id_producto = Convert.ToInt16(row.Cells["id_producto"].Value.ToString());
                        det.P_u         = Convert.ToDouble(row.Cells["p_u"].Value.ToString());
                        det.Total       = Convert.ToDouble(row.Cells["total"].Value.ToString());
                        using (det)
                        {
                            det.craeteDet_entrada();
                            using (producto)
                            {
                                List <Product> prod = producto.getProductById(Convert.ToInt16(row.Cells["id_producto"].Value.ToString()));
                                nuevo = Convert.ToInt16(row.Cells["cantidad"].Value.ToString());
                                while (prod[0].Parent != "0")
                                {
                                    nuevo = nuevo * Convert.ToInt16(prod[0].C_unidad);
                                    prod  = producto.getProductById(Convert.ToInt16(prod[0].Parent));
                                }
                                kardex.Fecha        = Convert.ToDateTime(dtFecha.Text).ToString();
                                kardex.Id_producto  = prod[0].Id;
                                kardex.Tipo         = "E";
                                kardex.Cantidad     = nuevo;
                                kardex.Antes        = prod[0].Existencia;
                                kardex.Id           = 0;
                                kardex.Id_documento = Convert.ToInt16(folio);
                                using (kardex)
                                {
                                    kardex.CreateKardex();
                                    List <Kardex> numeracion = kardex.getidKardex(prod[0].Id, Convert.ToInt16(folio), "E");
                                    using (afecta)
                                    {
                                        afecta.Agrega(numeracion[0].Id);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (Entrada == "")
            {
                Entradas formInterface = this.Owner as Entradas;
                formInterface.carga();
            }

            this.Close();
        }