private void dGV1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string gIdent = this.GetType().FullName + " " + System.Reflection.MethodBase.GetCurrentMethod().Name; GloblaVar.gUTIL.ATraza(gIdent + " Entrada a " + sender.ToString()); string Albaran = dGV1.CurrentRow.Cells["Albaran"].Value.ToString(); string Fecha = dGV1.CurrentRow.Cells["Fecha"].Value.ToString(); string Año = dGV1.CurrentRow.Cells["Anyo"].Value.ToString(); //string Det = dGV1.CurrentRow.Cells["C_Det"].Value.ToString(); //string BI = dGV1.CurrentRow.Cells["BI1"].Value.ToString(); //string IVA = dGV1.CurrentRow.Cells["IVA1"].Value.ToString(); //string RE = dGV1.CurrentRow.Cells["RE1"].Value.ToString(); //string Total = dGV1.CurrentRow.Cells["Total"].Value.ToString(); //string Vendedor = dGV1.CurrentRow.Cells["C_Vend"].Value.ToString(); //Cobrar_Albaran(Albaran, Fecha, Año, Det, BI, IVA, RE, Total, Vendedor); int a = 2; if (a == 1) { MessageBox.Show("Fase de PRUEBAS. Todavia no facture abonos."); this.Close(); } else { clase_ABONG_CABE AlbAbono = new clase_ABONG_CABE(); ArrayList Lista_Lineas_Abono = new ArrayList(); clase_linea_factura linea_abono = null; string idFactura = ""; if (AlbAbono.CargaAlbaran(Albaran, Año)) { string error = Comprobaciones(AlbAbono); if (error == "") { //idFactura = Funciones.FacturarAbono1(AlbAbono, "AB", "Albaran de Abono de " + Funciones.DameNomDet(AlbAbono.DetCod.ToString())); idFactura = Funciones.FacturarAbono1(AlbAbono, "AB", "La presente FACTURA RECTIFICATIVA modifica la factura NÚMERO: " + AlbAbono.RectificaFact + " AÑO: " + AlbAbono.RectificaAnyoFact + " SERIE: " + AlbAbono.RectificaSerieFact); } else { MessageBox.Show(error); } } //if (AlbAbono.CargaAlbaran(Albaran,Año)) if (idFactura != "") { AlbAbono = null; MessageBox.Show("La FACTURA RECTIFICATIVA se ha generado correctamente. \n \n Numero de FACTURA: " + idFactura); CargarGrid(); } } } //private void dGV1_CellContentClick(object sender, DataGridViewCellEventArgs e)
public void ComponAlbaran1() { string gIdent = this.GetType().FullName + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " "; clase_ABONG_CABE Albaran = new clase_ABONG_CABE(); if (Albaran.CargaAlbaran(numalbaran, año)) { GloblaVar.gIMAGEN_FONDO_TICKET = Image.FromFile(GloblaVar.gPATH_IMAGES_REMOTO + "\\plantilla_ticket_impreso.bmp"); Graphics g = Graphics.FromImage(GloblaVar.gIMAGEN_FONDO_TICKET); // ******************** INICIO GRABAR Texto sobre la Imagen impresa ************************** g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; formatoCentrado.Alignment = StringAlignment.Center; formatoDerecha.Alignment = StringAlignment.Far; try { ImprimeTituloColumnas(g); g.DrawString(numalbaran, albaranFont, Brushes.Black, (float)(1270 * F), (float)(18 * F)); //g.DrawString("NºPEDIDO", articulos4Font, Brushes.Black,(float) ( 1150 * F),(float) ( 53 * F)); //g.DrawString(frmPrincipal.TxtNPedidoC.Text.ToString, articulos3Font, Brushes.Black,(float) ( 1270 * F),(float) ( 52 * F)); // g.DrawString("NºPEDIDO:", articulos3Font, Brushes.Black, 730 * F, 547 * F) // g.DrawString(frmPrincipal.TxtNPedidoC.Text.ToString, articulos2Font, Brushes.Black, 838 * F, 541 * F) g.DrawString(Albaran.Fecha.ToShortDateString(), FechaFont, Brushes.Black, (float)(1270 * F), (float)(70 * F)); g.DrawString(DateTime.Now.ToShortTimeString(), HoraFont, Brushes.Black, (float)(1270 * F), (float)(120 * F)); g.DrawString(Albaran.IdVendedor.ToString(), latinFaoFont, Brushes.Black, (float)(1270 * F), (float)(160 * F)); g.DrawString(Albaran.DetCod.ToString(), detallistaFont, Brushes.Black, (float)(890 * F), (float)(70 * F)); g.DrawString(Albaran.DetNom, nombreFont, Brushes.Black, (float)(390 * F), (float)(20 * F)); g.DrawString(Albaran.DetNif, articulosFont, Brushes.Black, 390 * F, 50 * F); g.DrawString(Albaran.DetDireccion, articulosFont, Brushes.Black, 390 * F, 80 * F); g.DrawString(Albaran.DetMun, articulosFont, Brushes.Black, 390 * F, 110 * F); string cajas = ""; for (int i = 1; i < Albaran.NumLineas; i++) { if (Albaran.line[i].Cajas > 0) { cajas = Albaran.line[i].Cajas.ToString(); } else { cajas = ""; } g.DrawString(cajas, cantidadesFont, Brushes.Black, 429 * F, (230 + ((i - 1) * 52)) * F, formatoDerecha); g.DrawString(Albaran.line[i].Kilos.ToString(), cantidadesFont, Brushes.Black, 569 * F, (230 + ((i - 1) * 52)) * F, formatoDerecha); g.DrawString(Albaran.line[i].Artdes, articulos2Font, Brushes.Black, 635 * F, (230 + ((i - 1) * 52)) * F); g.DrawString(Albaran.line[i].NomCie, latinFaoFont, Brushes.Black, 650 * F, (260 + ((i - 1) * 52)) * F); //g.DrawString(frmPrincipal.TTraza_1.Text, articulos3Font, Brushes.Black, 1084 * F, 240 * F) g.DrawString(Albaran.line[i].Precio.ToString("##,##0.00"), cantidadesFont, Brushes.Black, 1320 * F, (230 + ((i - 1) * 52)) * F, formatoDerecha); g.DrawString(Albaran.line[i].Importe.ToString("##,##0.00"), cantidadesFont, Brushes.Black, 1464 * F, (230 + ((i - 1) * 52)) * F, formatoDerecha); } // for . fin de recorrido de las lineas //decimal a = Albaran.IVA1 ; g.DrawString(Albaran.BI1.ToString("##,##0.00"), subtotFont, Brushes.Black, 1464 * F, 450 * F, formatoDerecha); g.DrawString(Albaran.IVA1.ToString("##,##0.00"), subtotFont, Brushes.Black, 1464 * F, 480 * F, formatoDerecha); g.DrawString(Albaran.RE1.ToString("##,##0.00"), subtotFont, Brushes.Black, 1464 * F, 510 * F, formatoDerecha); g.DrawString(Albaran.Total.ToString("##,##0.00"), totalFont, Brushes.Black, 1464 * F, 537 * F, formatoDerecha); g.DrawString("ABONO SIN GEN.", detallistaFont, Brushes.Black, 680 * F, 460 * F); string pathImagenTicket = GloblaVar.gPATH_IMAGES_REMOTO + "\\ABONOS\\" + DateTime.Today.ToString("yyyyMMdd") + "_" + Albaran.Albaran.ToString("000000#") + ".gif"; GloblaVar.gIMAGEN_FONDO_TICKET.Save(pathImagenTicket, System.Drawing.Imaging.ImageFormat.Gif); GloblaVar.gUTIL.ATraza(gIdent + "Generado el albarán " + pathImagenTicket); } catch (Exception ex) { GloblaVar.gUTIL.ATraza(gIdent + ex.ToString()); } } } //private void ComponAlbaran1
} //private void dGV1_CellContentClick(object sender, DataGridViewCellEventArgs e) private string Comprobaciones(clase_ABONG_CABE albAbono) { string mensaje = ""; //int? rectificaAlb1 = albAbono.RectificaAlb; string rectificaAlb = albAbono.RectificaAlb.ToString(); string rectificaAnyoAlb = albAbono.RectificaAnyoAlb.ToString();; string rectificaFact = albAbono.RectificaFact.ToString(); string rectificaAnyoFact = albAbono.RectificaAnyoFact.ToString(); string rectificaSerieFact = albAbono.RectificaSerieFact.ToString(); string venNfp = ""; string anyoFra = ""; string serieFra = ""; //El abono tiene albarán de origen if (!string.IsNullOrEmpty(rectificaAlb) && !string.IsNullOrEmpty(rectificaAnyoAlb)) { //El abono no tiene referencia a factura porque el albarán no estaba facturado todavía en el momento de la creación del abono //Deberemos comprobar si ahora el albarán ya está facturado if (string.IsNullOrEmpty(rectificaFact) && string.IsNullOrEmpty(rectificaAnyoFact) && string.IsNullOrEmpty(rectificaSerieFact)) { string sql = @"SELECT VenAlb, Anyo, VenNfp, AnyoFra, SerieFra FROM VENALB_CABE WHERE VenAlb=@Albaran and Anyo=@Anyo"; using (SqlCommand cmd = new SqlCommand(sql, GloblaVar.gConRem)) { cmd.Parameters.AddWithValue("@Albaran", rectificaAlb); cmd.Parameters.AddWithValue("@Anyo", rectificaAnyoAlb); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { venNfp = reader["VenNfp"].ToString(); anyoFra = reader["AnyoFra"].ToString(); serieFra = reader["SerieFra"].ToString(); } } reader.Close(); } //Ahora está facturado el albarán if (!string.IsNullOrEmpty(venNfp) && !string.IsNullOrEmpty(anyoFra) && !string.IsNullOrEmpty(serieFra)) { albAbono.RectificaFact = int.Parse(venNfp); albAbono.RectificaAnyoFact = int.Parse(anyoFra); albAbono.RectificaSerieFact = serieFra; //Modificamos el abono y le añadimos los datos de la factura sql = @"UPDATE ABONG_CABE SET RectificaFact=" + albAbono.RectificaFact + ",RectificaAnyoFact=" + albAbono.RectificaAnyoFact + ",RectificaSerieFact='" + albAbono.RectificaSerieFact + "'"; sql += " WHERE Albaran=" + albAbono.Albaran + " AND Anyo=" + albAbono.Anyo; int resUpdateAlbNG = Funciones.EjecutaNonQuery(sql, GloblaVar.gConRem); } else { //El albarán de origen no está facturado por el mayorista pero puede haberlo facturado OREMAPE if (MessageBox.Show("El albarán de origen no está facturado, \n¿desea introducir los datos de la factura de OREMAPE?", "", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { frmDatosFactOremape DatosFactOremape = new frmDatosFactOremape(); if (DatosFactOremape.ShowDialog() == System.Windows.Forms.DialogResult.OK) { albAbono.RectificaFact = int.Parse(DatosFactOremape.OremapeFactura); albAbono.RectificaAnyoFact = int.Parse(DatosFactOremape.OremapeAñoFact); albAbono.RectificaSerieFact = DatosFactOremape.OremapeSerieFact; //Modificamos el abono y le añadimos los datos de la factura de OREMAPE sql = @"UPDATE ABONG_CABE SET RectificaFact=" + albAbono.RectificaFact + ",RectificaAnyoFact=" + albAbono.RectificaAnyoFact + ",RectificaSerieFact='" + albAbono.RectificaSerieFact + "'"; sql += " WHERE Albaran=" + albAbono.Albaran + " AND Anyo=" + albAbono.Anyo; int resUpdateAlbNG = Funciones.EjecutaNonQuery(sql, GloblaVar.gConRem); } else { mensaje = "El albarán de origen no está facturado"; } } else { mensaje = "El albarán de origen no está facturado"; } } } } else { mensaje = "El abono no tiene albarán de origen"; } return(mensaje); }