Exemplo n.º 1
0
        private void cbTipo_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                if (cbTipo.SelectedItem is null)
                {
                    cbTipo.SelectedIndex = 0;
                }
                Models.Product productos = new Models.Product();
                switch (cbTipo.SelectedItem.ToString())
                {
                case "Ticket":
                    Ticket_a_factura tic_a_fact = new Ticket_a_factura();
                    tic_a_fact.Owner = this;
                    tic_a_fact.ShowDialog();
                    show_det_ticket();
                    break;

                case "Traspasos":
                    Traspasos_a_facturas traspasos = new Traspasos_a_facturas();
                    traspasos.Owner = this;
                    traspasos.ShowDialog();
                    foreach (DataGridViewRow row in dtdocumentos.Rows)
                    {
                        Models.Det_transfers detalles = new Models.Det_transfers();
                        using (detalles)
                        {
                            List <Models.Det_transfers> detalle = detalles.getDet_trans(Convert.ToInt16(row.Cells["folio"].Value.ToString()));
                            foreach (Models.Det_transfers item in detalle)
                            {
                                using (productos)
                                {
                                    List <Models.Product> producto = productos.getProductById(item.Id_producto);
                                    dtProductos.Rows.Add(item.Id_producto, item.Cantidad, producto[0].Code1, producto[0].Description, item.Precio, (item.Precio * item.Cantidad));
                                }
                            }
                        }
                    }
                    Calcula();
                    break;

                default:
                    txtCliente.Focus();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void form_transfer_Load(object sender, EventArgs e)
        {
            lbFecha.Visible                    = false;
            this.txtFolios.AutoSize            = true;
            txtCodigo.AutoCompleteCustomSource = cargadatos();
            txtCodigo.AutoCompleteMode         = AutoCompleteMode.Suggest;
            txtCodigo.AutoCompleteSource       = AutoCompleteSource.CustomSource;

            DataTable table = new DataTable();
            DataRow   row;

            table.Columns.Add("Text", typeof(string));
            table.Columns.Add("Value", typeof(string));
            row          = table.NewRow();
            row["Text"]  = "";
            row["Value"] = "";
            table.Rows.Add(row);

            Models.Offices oficinas = new Models.Offices();
            using (oficinas)
            {
                List <Models.Offices> oficina = oficinas.GetOffices();
                foreach (Models.Offices ofi in oficina)
                {
                    row          = table.NewRow();
                    row["Text"]  = ofi.Name;
                    row["Value"] = ofi.Id;
                    table.Rows.Add(row);
                }
            }

            cbOficinas.BindingContext = new BindingContext();
            cbOficinas.DataSource     = table;
            cbOficinas.DisplayMember  = "Text";
            cbOficinas.ValueMember    = "Value";
            cbOficinas.BindingContext = new BindingContext();
            if (id_transfer == 0)
            {
                get_folio();
            }
            else
            {
                recuperado = true;
                Models.Transfers traspasos = new Models.Transfers();
                using (traspasos)
                {
                    List <Models.Transfers> traspaso = traspasos.getTransferbyid(id_transfer);
                    if (traspaso.Count > 0)
                    {
                        lbFecha.Text             = traspaso[0].Fecha.ToString();
                        cbOficinas.SelectedValue = traspaso[0].Sucursal;
                        txtFolios.Text           = traspaso[0].Folio.ToString();
                    }
                }
                Models.Det_transfers det       = new Models.Det_transfers();
                Models.Product       productos = new Models.Product();
                using (det)
                {
                    using (productos)
                    {
                        List <Models.Det_transfers> detallado = det.getDet_trans(Convert.ToInt32(txtFolios.Text));
                        if (detallado.Count > 0)
                        {
                            foreach (Models.Det_transfers item in detallado)
                            {
                                List <Models.Product> producto = productos.getProductById(item.Id_producto);
                                dtProductos.Rows.Insert(0, item.Id_producto, item.Cantidad, producto[0].Code1, producto[0].Description, item.Precio, (item.Precio * item.Cantidad));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (cbOficinas.Text == "")
            {
                MessageBox.Show("Seleccione una sucursal", "Sucursal", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cbOficinas.Focus();
            }
            else
            {
                if (recuperado == false)
                {
                    Models.Transfers transferencia = new Models.Transfers();
                    using (transferencia)
                    {
                        transferencia.Folio        = Convert.ToInt16(txtFolios.Text);
                        transferencia.Tipo_trapaso = "E";
                        transferencia.Sucursal     = cbOficinas.SelectedValue.ToString();
                        transferencia.Subtotal     = Convert.ToDouble(txtSubtotal.Text);
                        transferencia.Iva          = 0;
                        transferencia.Total        = 0;
                        transferencia.Facturado    = Convert.ToInt16(false);
                        transferencia.CreateTransfer();
                        List <Models.Transfers> ultimo = transferencia.getTransferbyfolio(Convert.ToInt16(txtFolios.Text), "E");

                        Models.Det_transfers detalles = new Models.Det_transfers();
                        using (detalles)
                        {
                            detalles.Folio = Convert.ToInt16(txtFolios.Text);
                            detalles.Tipo  = "E";

                            Models.Product poductos = new Models.Product();
                            foreach (DataGridViewRow row in dtProductos.Rows)
                            {
                                detalles.Cantidad    = Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                                detalles.Id_producto = Convert.ToInt16(row.Cells["id"].Value.ToString());
                                detalles.Precio      = Convert.ToDouble(row.Cells["p_u"].Value.ToString());
                                detalles.CreateDet();
                                using (poductos)
                                {
                                    List <Models.Product> producto = poductos.getProductById(Convert.ToInt16(row.Cells["id"].Value.ToString()));
                                    Models.Kardex         kardex   = new Models.Kardex();
                                    using (kardex)
                                    {
                                        kardex.Id_producto  = Convert.ToInt16(row.Cells["id"].Value.ToString());
                                        kardex.Tipo         = "T";
                                        kardex.Id_documento = ultimo[0].Id;
                                        kardex.Cantidad     = Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                                        kardex.Antes        = producto[0].Existencia;
                                        kardex.CreateKardex();

                                        List <Models.Kardex> ultimo_kardez = kardex.getidKardex(Convert.ToInt16(row.Cells["id"].Value.ToString()), ultimo[0].Id, "T");
                                        Models.Afecta_inv    afecta        = new Models.Afecta_inv();
                                        using (afecta)
                                        {
                                            afecta.Disminuye(ultimo_kardez[0].Id);
                                        }
                                    }
                                }
                            }
                        }
                    }


                    Models.Folios folio = new Models.Folios();
                    using (folio)
                    {
                        folio.Transferencia = (Convert.ToInt16(txtFolios.Text) + 1);
                        folio.savenewTransfer();
                    }
                }
                else
                {
                    Models.Transfers transferencia = new Models.Transfers();
                    using (transferencia)
                    {
                        transferencia.Folio        = Convert.ToInt32(txtFolios.Text);
                        transferencia.Tipo_trapaso = "E";
                        transferencia.Sucursal     = cbOficinas.SelectedValue.ToString();
                        transferencia.Subtotal     = Convert.ToDouble(txtSubtotal.Text);
                        transferencia.Iva          = 0;
                        transferencia.Total        = 0;
                        transferencia.Facturado    = Convert.ToInt16(false);
                        transferencia.updateTrasfer();
                    }
                    Models.Det_transfers detalles = new Models.Det_transfers();
                    using (detalles)
                    {
                        detalles.Folio = Convert.ToInt32(txtFolios.Text);
                        detalles.delete_det();

                        detalles.Folio = Convert.ToInt16(txtFolios.Text);
                        detalles.Tipo  = "E";

                        Models.Product poductos = new Models.Product();
                        foreach (DataGridViewRow row in dtProductos.Rows)
                        {
                            detalles.Cantidad    = Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                            detalles.Id_producto = Convert.ToInt16(row.Cells["id"].Value.ToString());
                            detalles.Precio      = Convert.ToDouble(row.Cells["p_u"].Value.ToString());
                            detalles.CreateDet();
                            using (poductos)
                            {
                                List <Models.Product> producto = poductos.getProductById(Convert.ToInt16(row.Cells["id"].Value.ToString()));
                                Models.Kardex         kardex   = new Models.Kardex();
                                using (kardex)
                                {
                                    kardex.Id_producto  = Convert.ToInt16(row.Cells["id"].Value.ToString());
                                    kardex.Tipo         = "T";
                                    kardex.Id_documento = id_transfer;
                                    kardex.Cantidad     = Convert.ToDouble(row.Cells["cantidad"].Value.ToString());
                                    kardex.Antes        = producto[0].Existencia;
                                    kardex.CreateKardex();

                                    List <Models.Kardex> ultimo_kardez = kardex.getidKardex(Convert.ToInt16(row.Cells["id"].Value.ToString()), id_transfer, "T");
                                    Models.Afecta_inv    afecta        = new Models.Afecta_inv();
                                    using (afecta)
                                    {
                                        afecta.Disminuye(ultimo_kardez[0].Id);
                                    }
                                }
                            }
                        }
                    }
                }


                Models.Configuration configuracion = new Models.Configuration();
                int cuantos   = dtProductos.RowCount;
                int faltantes = 0;
                int valor;


                using (configuracion)
                {
                    faltantes = cuantos - 1;

                    valor = 110 * faltantes;

                    valor = valor + 1150;
                    PaperSize ps = new PaperSize("Custom", 300, valor);
                    List <Models.Configuration> config = configuracion.getConfiguration();

                    printDocument1.DefaultPageSettings.PaperSize = ps;
                    printDocument1.PrinterSettings.PrinterName   = config[0].Impresora;
                    printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);

                    printDocument1.Print();
                }


                this.Close();
            }
        }