예제 #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;
                }
            }
        }
예제 #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));
                            }
                        }
                    }
                }
            }
        }