private void miAdd_Click(object sender, EventArgs e) { string LCorrelativo = ""; string LIDProyecto = ""; string LArchivo = ""; Element el = GGCPersLiq.TableControl.Table.CurrentElement; if (el != null) { if (el is GridRecord) { DataRowView drv = (el as Record).GetData() as DataRowView; LCorrelativo = drv[1].ToString(); LIDProyecto = drv[23].ToString(); LArchivo = drv[25].ToString(); } } if (LCorrelativo == "") { MessageBoxAdv.Show("Debe de seleccionar la factura a la que desea agregar el archivo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string NombreArchivo = string.Concat("FactCor_" + LCorrelativo.ToString()); NombreArchivo = NombreArchivo.Replace(" ", ""); string extension = ""; /************************* * Subiendo foto *************************/ var dlg = new OpenFileDialog { Filter = @"PDF files (*.pdf)|*.pdf|JPEG files (*.jpg)|*.jpg|BMP files (*.BMP)|*.BMP|GIF files (*.gif)|*.gif", CheckFileExists = true, Title = @"Seleccione el archivo", Multiselect = false }; ; if (dlg.ShowDialog() == DialogResult.OK) // Test result. { FileInfo fi = new FileInfo(dlg.FileName); if (fi.Exists) { extension = fi.Extension.ToString(); fi.CopyTo(dlg.FileName.Replace(dlg.SafeFileName, "") + NombreArchivo + extension); } //aqui me quedo /*if (LArchivo != "") * DeleteFile(LArchivo);*/ Upload(dlg.FileName.Replace(dlg.SafeFileName, "") + NombreArchivo + extension, ""); File.Delete(dlg.FileName.Replace(dlg.SafeFileName, "") + NombreArchivo + extension); } else { MessageBoxAdv.Show("Se cancelo el registro", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } /************************************ * Registrando experiencia en BD ************************************/ Int32 intResultado = 0; String strResultado = ""; DataSet DSDevuelveID = new DataSet(); DataTable DTDevuelveID = new DataTable(); WSAdministracion.WSAdministracion WSAdm = new WSAdministracion.WSAdministracion(); WSAdm.Url = mdlGenerales.DireccionWS + "FazServices/WSAdministracion.asmx"; DSDevuelveID = WSAdm.AddFacturaCostos(mdlGenerales.Conexion, LCorrelativo, NombreArchivo + extension, mdlGenerales.STRUsuario); DTDevuelveID = DSDevuelveID.Tables[0]; foreach (DataRow Row in DTDevuelveID.Rows) { intResultado = Convert.ToInt32(Row[0].ToString()); strResultado = Row[1].ToString(); } if (intResultado != 0) { MessageBoxAdv.Show(strResultado, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); CargaGrid(LIDProyecto, lblIDPartida.Text.ToString(), lblEmpresa.Text.ToString(), lblProyecto.Text.ToString(), lblPartida.Text.ToString(), lblIDMaestroPartida.Text.ToString(), lblRuc.Text.ToString()); } else { MessageBoxAdv.Show(strResultado, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }