private void label_CargaCFDI_Click(object sender, EventArgs e) { DialogResult Reps = MessageBox.Show(@"Esta seguro de cargar comprobante Fiscal, solo se cargaran productos con codigos existentes en el sistema?", "Confirmar", MessageBoxButtons.YesNo); if (Reps == DialogResult.Yes) { OpenFileDialog theDialog = new OpenFileDialog(); theDialog.Title = "CFDI "; theDialog.Filter = "XML files|*.xml"; if (theDialog.ShowDialog() == DialogResult.OK) { try { string filename = theDialog.FileName; string XmlString = File.ReadAllText(filename); Classes.XML.Class_LectorXML ClsXML = new Classes.XML.Class_LectorXML(); ClsXML.ExtraXML(XmlString); if (ClsXML.dtProductos == null) { MessageBox.Show("Error: No se encontraron productos "); return; } string NoExisten = ""; if (ClsXML.dtProductos.Rows.Count > 0) { foreach (DataRow Row in ClsXML.dtProductos.Rows) { string Codigo = Row["codigo"].ToString(); string Descripcion = Row["descripcion"].ToString(); double Precio = Convert.ToDouble(Row["precio"].ToString()); double Cantidad = Convert.ToDouble(Row["cantidad"].ToString()); string MedidaSat = Row["MedidaSAT"].ToString(); string CodigoSat = Row["CodigoSAT"].ToString(); DataTable dtMatPrima = ClsMatPrim.getLista(" AND M.vchCodigo = '" + Codigo + "' AND M.iidEstatus = 1 "); if (dtMatPrima.Rows.Count > 0) { string IdProd = dtMatPrima.Rows[0]["iidMateriPrima"].ToString(); string Medida = dtMatPrima.Rows[0]["vchNombre"].ToString(); int contenido = Convert.ToInt32(dtMatPrima.Rows[0]["fContenido"].ToString()); AgregaProducto(IdProd, Medida, Cantidad, Codigo, Descripcion, Precio, contenido); } else { NoExisten += Codigo + " - " + Descripcion + "\n\r"; } //AgregaProducto(string IdProd, string Medida, double fCantidad, string Codigo, string Producto, double Precio) } } if (NoExisten != "") { MessageBox.Show("Existen algunos productos que no estan registrados y no se pueden mostrar:\n\r" + NoExisten); } MessageBox.Show("Proceso Terminado"); } catch (Exception ex) { MessageBox.Show("Error: Problema al Leer el archivo: " + ex.Message); } } } }