private void dgvRepartidor_CellContentClick(object sender, DataGridViewCellEventArgs e)//Detalles Repartidor { DataGridView dgv = (DataGridView)sender; if (dgv.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { _flag = true; gbRepartidor.Visible = true; _repartidor = new Repartidor(); _repartidor.Id_Repartidor = dgv[0, e.RowIndex].Value.ToString(); string _res = ""; _co.Abrir(); _co.AtraparRepartidor(_repartidor.Id_Repartidor, ref _repartidor, ref _res); _co.Cerrar(); txtNombreRepartidor.Text = _repartidor.Nombre; txtApellidoRepartidor.Text = _repartidor.Apellido; txtDireccionRepartidor.Text = _repartidor.Direccion; txtFechaAlta.Text = _repartidor.Fecha_Alta.ToShortDateString(); txtTelefonoRepartidor.Text = _repartidor.Telefono; txtUsuarioRepartidor.Text = _repartidor.Id_User; txtIDRepartidor.Text = _repartidor.Id_Repartidor.ToString(); _co.Abrir(); _co.MostrarPedidosRepartidor(dgvPedidosRepartidor, _repartidor, ref _res); _co.Cerrar(); this.Width = 1000; } }
private void button8_Click(object sender, EventArgs e)//Agregar Repartidor { if (MessageBox.Show("¿Seguro que desea agregar repartidor?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (txtApellidoRe.Text != "" && txtNombreRe.Text != "") { Repartidor _aux = new Repartidor(); try { _aux.Nombre = txtNombreRe.Text; _aux.Apellido = txtApellidoRe.Text; _aux.Direccion = txtDireccionRe.Text; _aux.Telefono = txtTelefonoRe.Text; _aux.Id_User = _user.Login; } catch (Exception ex) { MessageBox.Show(ex.Message + " Datos erroneos", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string _res = ""; _co.Abrir(); _co.AgregarRepartidor(_aux, ref _res); _co.Cerrar(); txtNombreRe.Clear(); txtDireccionRe.Clear(); txtApellidoRe.Clear(); txtTelefonoRe.Clear(); MessageBox.Show(_res, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Ingrese al menos nombre y apellido del cliente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
static public void GenerarListaPedidos(ArrayList _pedidos, Repartidor _repartidor)//Imprimir pedidos de un repartidor { string _nombreSalida = @".\Repartidores\" + _repartidor.Id_Repartidor + _repartidor.Nombre + _repartidor.Apellido + DateTime.Now.ToString("mm-dd-yy-hh-mm") + ".docx"; Formatting _formatoTitulo = new Formatting(); DocX _doc = DocX.Create(_nombreSalida); //Logo Paragraph _logo = _doc.InsertParagraph(""); Novacode.Image _img = _doc.AddImage(@".\logo.jpg"); Picture _pic = _img.CreatePicture(); _pic.Width = 100; _pic.Height = 50; _logo.Alignment = Alignment.right; _logo.InsertPicture(_pic, 0); // Titulo _formatoTitulo.Size = 20D; _formatoTitulo.FontColor = Color.DarkBlue; Paragraph _parrafotitulo = _doc.InsertParagraph("BOLSAS DESECHABLES EXPRESS", false, _formatoTitulo); _parrafotitulo.Alignment = Alignment.center; //Lema Formatting _formatoLema = new Formatting(); _formatoLema.Size = 14D; _formatoLema.FontColor = Color.Blue; _formatoLema.UnderlineStyle = UnderlineStyle.singleLine; Paragraph _lema = _doc.InsertParagraph("Llevamos tu pedido en un dos por tres..." + Environment.NewLine, false, _formatoLema); _lema.Alignment = Alignment.center; //Datos Repartidor string _textoRepartidor = "Nombre del Repartidor: " + _repartidor.Nombre + " " + _repartidor.Apellido + Environment.NewLine + " Repartidor ID: " + _repartidor.Id_Repartidor + Environment.NewLine + " Telefono: " + _repartidor.Telefono + Environment.NewLine; Formatting _formatoRepartidor = new Formatting(); _formatoRepartidor.FontColor = Color.Black; _formatoRepartidor.Size = 12D; Paragraph _parrafoRepartidor = _doc.InsertParagraph(_textoRepartidor, false, _formatoRepartidor); _parrafoRepartidor.Alignment = Alignment.left; //tabla pedidos Table _tabla = _doc.AddTable(_pedidos.Count + 1, 5); _tabla.Rows[0].Cells[0].Paragraphs.First().Append("Pedido id"); _tabla.Rows[0].Cells[1].Paragraphs.First().Append("Fecha Pedido"); _tabla.Rows[0].Cells[2].Paragraphs.First().Append("Fecha entrega"); _tabla.Rows[0].Cells[3].Paragraphs.First().Append("Precio Total"); _tabla.Rows[0].Cells[4].Paragraphs.First().Append("Contado"); double _precioTotal = 0; for (int i = 1; i < _pedidos.Count + 1; i++) { Pedido _aux = ((Pedido)_pedidos[i - 1]); _tabla.Rows[i].Cells[0].Paragraphs.First().Append(_aux.Id_Pedido.ToString()); _tabla.Rows[i].Cells[1].Paragraphs.First().Append(_aux.Fecha_Pedido.ToString()); _tabla.Rows[i].Cells[2].Paragraphs.First().Append(_aux.Fecha_Entrega.ToString()); _tabla.Rows[i].Cells[3].Paragraphs.First().Append(_aux.Precio_Total.ToString("n2")); _tabla.Rows[i].Cells[4].Paragraphs.First().Append(_aux.Contado == true?"NO":"SI"); _precioTotal += _aux.Precio_Total; } _tabla.Design = TableDesign.ColorfulGridAccent5; _tabla.Alignment = Alignment.left; _tabla.AutoFit = AutoFit.Contents; _doc.InsertTable(_tabla); Paragraph _total = _doc.InsertParagraph(Environment.NewLine + "Total de los pedidos: " + _precioTotal.ToString("n2")); _total.Alignment = Alignment.right; _formatoLema.FontColor = Color.Black; _formatoLema.Size = 10D; string _textCliente = "Firma de Recibido:" + Environment.NewLine + " __________________________"; Paragraph _parrafoCliente = _doc.InsertParagraph(_textCliente, false, _formatoLema); _parrafoCliente.Alignment = Alignment.right; //Proteccion y guardado _doc.AddProtection(EditRestrictions.readOnly); _doc.Save(); Process.Start(_nombreSalida); }