public string mapNetworkDrives(string softwareLocation, string backupLocation, string username, string password) { NetworkDrive NDT = new aejw.Network.NetworkDrive(); NetworkDrive NDS = new aejw.Network.NetworkDrive(); try { NDT.LocalDrive = "t:"; NDT.ShareName = backupLocation; NDT.Persistent = true; NDT.SaveCredentials = true; NDT.MapDrive(username, password); NDS.LocalDrive = "s:"; NDS.ShareName = softwareLocation; NDS.Persistent = true; NDS.SaveCredentials = true; NDS.MapDrive(username, password); return("...Success"); } catch (Exception e) { Console.WriteLine(e); return("...Failed. Check your paths, username, and password."); } }
/// <summary> /// Mappings the net drive. /// </summary> public static void MappingNetDrive(string netDrive, string shareFolder, string userName, string password) { NetworkDrive oNetDrive = new NetworkDrive(); try { //set propertys oNetDrive.Force = false; oNetDrive.Persistent = true;//要永久的,不然下次開機會不見 oNetDrive.LocalDrive = netDrive; oNetDrive.PromptForCredentials = false; oNetDrive.ShareName = shareFolder; oNetDrive.SaveCredentials = false; //match call to options provided if (password == "" && userName == "") { oNetDrive.MapDrive(); } else if (userName == "") { oNetDrive.MapDrive(userName); } else { oNetDrive.MapDrive(userName, password); } //update status //System.Threading.Thread.Sleep(1000); // Process.Start("explorer.exe", netDrive + @":\"); //ExecuteAsAdmin("explorer.exe", netDrive + @":\"); //顯示不出來 //Process.Start("explorer.exe"); } catch (Exception err) { //report error TRMessageBox.Show("Cannot map drive!\nError: " + err.Message); } oNetDrive = null; }
public static string[] getFileOnServer() { string line; string[] words = null; string[] arrFile = null; try { StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\app.conf"); while ((line = sr.ReadLine()) != null) { words = Regex.Split(line, ","); } } catch (Exception) { } if (words != null) { LocalDirver = words[0]; pathShare = words[1]; UserName = words[2]; Password = words[3]; fileTemplate = words[4]; localSave = words[5]; NetworkDrive oNetDrive = new aejw.Network.NetworkDrive(); try { oNetDrive.LocalDrive = LocalDirver; oNetDrive.ShareName = pathShare; oNetDrive.MapDrive(UserName, Password); } catch (Exception) { } oNetDrive = null; arrFile = Directory.GetFiles(LocalDirver); } return(arrFile); }
public bool MapNetworkDrive(string networkPath, string username, string password, string letter, string app) { //----drugi način mapiranja diska-----------------3. parametar je persistnat connection opcija //IWshNetwork_Class network = new IWshNetwork_Class(); //network.MapNetworkDrive("k:", @"\\server\share", true, username, password); //network.RemoveNetworkDrive(networkPath); NetworkDrive mapit = new aejw.Network.NetworkDrive(); try { mapit.LocalDrive = letter; mapit.ShareName = networkPath; mapit.MapDrive(username, password); return(true); } catch (Exception err) { //File.AppendAllText(@"C:\Temp\sss.txt", err.Message + "!!!"); return(false); } }
protected void GuardarBackUp() { string RUTASERVER = ""; string USERSERVER = ""; string CLAVESERVER = ""; try { //Veo si existen la infomracion correcta dpara el conection server RUTASERVER = ConfigurationManager.AppSettings["RUTASERVER"]; USERSERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["USERSERVER"]); CLAVESERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["CLAVESERVER"]); } catch { MessageBox.Show("Informacion de configuracion con el server file, necesaria"); return; } if (RUTASERVER == "" || USERSERVER == "" || CLAVESERVER == "") { MessageBox.Show("Es necesario configurar la conexion con el servidor para los archivos"); return; } NetworkDrive oNetDrive = new aejw.Network.NetworkDrive(); try { oNetDrive.LocalDrive = "Y:"; oNetDrive.ShareName = @RUTASERVER; try { try { oNetDrive.UnMapDrive(); } catch { } oNetDrive.MapDrive(USERSERVER, CLAVESERVER); } catch { } } catch { MessageBox.Show("No se pudo conectar con el servidor de archivos"); return; } CreateFolder(RUTASERVER + "\\BackUp"); button_Guardar.Enabled = false; string FechAc = DateTime.Now.Date.ToString().Substring(0, 10); string[] val2 = FechAc.Split('/'); string fecha = val2[2] + val2[1] + val2[0]; string NombreBackup = RUTASERVER + "\\BackUp\\" + fecha + "-" + textBox_Nombre.Text + ".bak"; string sql = " BACKUP DATABASE [FLEXCIM] TO DISK = N'" + NombreBackup + "'" + " WITH NOFORMAT, NOINIT, NAME = N'FLEXCIM-Completa Base de datos Copia de seguridad', " + " SKIP, NOREWIND, NOUNLOAD, STATS = 10"; if (Conexion.InsertaSql(sql)) { string ruta = RUTASERVER + "\\BackUp"; string rutacompleta = ruta + "\\" + fecha + "-" + textBox_Nombre.Text + ".bak"; try { DataTable dtInfo = new DataTable(); dtInfo.Columns.Add("idUsuario", System.Type.GetType("System.String")); dtInfo.Columns.Add("idEmpresa", System.Type.GetType("System.String")); dtInfo.Columns.Add("Nombre", System.Type.GetType("System.String")); dtInfo.Columns.Add("Ruta", System.Type.GetType("System.String")); DataRow Drw; Drw = dtInfo.NewRow(); Drw["idUsuario"] = Classes.Class_Session.Idusuario; Drw["idEmpresa"] = Classes.Class_Session.IDEMPRESA; Drw["Nombre"] = fecha + "-" + textBox_Nombre.Text + ".bak"; Drw["Ruta"] = ruta; dtInfo.Rows.Add(Drw); if (ClsBac.GuardarRegistroBackup(dtInfo)) { MessageBox.Show("Backup Generado Exsitosamente."); CargaListaBackup(); } else { MessageBox.Show("Problema al Guardar"); } } catch (Exception exp) { MessageBox.Show("El backup se genero correctamente pero el registro tuvo algun problema.\n\r" + exp.ToString()); } } else { MessageBox.Show("Problemas al generar el backup."); } oNetDrive.LocalDrive = "Y:"; oNetDrive.ShareName = @RUTASERVER; try { oNetDrive.UnMapDrive(); } catch { } button_Guardar.Enabled = true; }
private void button1_Click(object sender, EventArgs e) { string RUTASERVER = ""; string USERSERVER = ""; string CLAVESERVER = ""; try { //Veo si existen la infomracion correcta dpara el conection server RUTASERVER = ConfigurationManager.AppSettings["RUTASERVER"]; USERSERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["USERSERVER"]); CLAVESERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["CLAVESERVER"]); } catch { MessageBox.Show("Informacion de configuracion con el server file, necesaria"); return; } if (RUTASERVER == "" || USERSERVER == "" || CLAVESERVER == "") { MessageBox.Show("Es necesario configurar la conexion con el servidor para los archivos"); return; } //Valida que haya mas de un registro seleccionado int contador = 0; //Finaliza modo de edicion dataGridView1.EndEdit(); foreach (DataGridViewRow registro in dataGridView1.Rows) { try { if ((Boolean)registro.Cells["Seleccionar"].Value == true) { contador++; } } catch { } } if (contador != 1) { MessageBox.Show("Debe seleccionar al un Backup."); return; } DialogResult resultado; resultado = MessageBox.Show(@"Desea descargar estos Backup´s", "Confirmar!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (DialogResult.OK == resultado) { dataGridView1.EndEdit(); foreach (DataGridViewRow registro in dataGridView1.Rows) { try { if ((Boolean)registro.Cells["Seleccionar"].Value == true) { try { string backup = registro.Cells["Nombre"].Value.ToString(); string origen = registro.Cells["Ruta"].Value.ToString(); string destino = ""; if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { destino = folderBrowserDialog1.SelectedPath; } else { return; } string origFil = System.IO.Path.Combine(origen, backup); string destArch = System.IO.Path.Combine(destino, backup); if (!System.IO.Directory.Exists(destino)) { System.IO.Directory.CreateDirectory(destino); } NetworkDrive oNetDrive = new aejw.Network.NetworkDrive(); oNetDrive.LocalDrive = "Y:"; oNetDrive.ShareName = @RUTASERVER; try { try { oNetDrive.UnMapDrive(); } catch { } oNetDrive.MapDrive(USERSERVER, CLAVESERVER); } catch { } try { System.IO.File.Copy(origFil, destArch, true); } catch { MessageBox.Show("El archivo no se encuentra disponible"); } oNetDrive.LocalDrive = "Y:"; oNetDrive.ShareName = @RUTASERVER; oNetDrive.UnMapDrive(); MessageBox.Show("Descargados con exito"); } catch { MessageBox.Show("Problema al descargar el archivo"); } } } catch { } } } }
private void login_clicked() { firstclick = true; //NetworkDrive oNetDrive = new NetworkDrive(); //############### Parameter aus CONFIG.XML auslesen ################ try { XmlNode xnHome = doc.SelectSingleNode("/settings/eintrag/home"); XmlNode xnShareds = doc.SelectSingleNode("/settings/eintrag/shareds"); XmlNode xnPrinters = doc.SelectSingleNode("/settings/eintrag/printers"); XmlNode xnScanners = doc.SelectSingleNode("/settings/eintrag/scanners"); if (xnHome != null) home = xnHome.Attributes["param"].InnerText; if (xnShareds != null) shareds = xnShareds.Attributes["param"].InnerText; if (xnPrinters.FirstChild != null) printers = true; if (xnScanners.FirstChild != null) scanners = true; } catch (Exception e) { MessageBox.Show(e.Message, "Fehler: ", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(0); } // Stehen überhaupt Login und Password drin? if (textBox1.Text.Equals("") || maskedTextBox1.Text.Equals("")) { try { maskedTextBox1.Focus(); } catch { } return; } NetworkDrive oNetDrive = new NetworkDrive(); //######## Starte das script zum installieren der Drucker ######### if (printers == true) { try { XmlNode xnPrinters2 = doc.SelectSingleNode("/settings/eintrag/printers"); System.Diagnostics.ProcessStartInfo sendInfo; foreach (XmlNode printer in xnPrinters2.ChildNodes) { sendInfo = new System.Diagnostics.ProcessStartInfo("cscript"); sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + printer.Attributes["path"].InnerText; System.Diagnostics.Process.Start(sendInfo);//.WaitForExit(); sendInfo = null; //System.Diagnostics.Process.Start("cscript", "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + printer.Attributes["path"].InnerText); } } catch (Exception err) { MessageBox.Show(this, "Fehler: " + err.Message, "Installieren des Druckers nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error); } //################################################################# // Drucker verbinden... //NetworkDrive oNetDrive = new NetworkDrive(); try { oNetDrive.LocalDrive = ""; oNetDrive.ShareName = "\\\\pub-ps01.public.ads.uni-freiburg.de"; oNetDrive.MapDrive("PUBLIC\\" + textBox1.Text, maskedTextBox1.Text); //Warte bis das Netz da ist System.Threading.Thread.Sleep(500 * 1); } catch { MessageBox.Show(this, "Fehler: CONFIG.XML", "Verbindung zum \"Drucker\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error); //maskedTextBox1.Text = ""; //try //{ // maskedTextBox1.Focus(); //} //catch { } //return; } } /* * Wenn kein Druckereintrag in CONFIG.XML vorhanden ist, * installiere Drucker des RZ und der UB2 */ else { try { System.Diagnostics.ProcessStartInfo sendInfo; sendInfo = new System.Diagnostics.ProcessStartInfo("cscript"); sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + "\\\\pub-ps01.public.ads.uni-freiburg.de\\rzps1"; System.Diagnostics.Process.Start(sendInfo); sendInfo = null; sendInfo = new System.Diagnostics.ProcessStartInfo("cscript"); sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + "\\\\pub-ps01.public.ads.uni-freiburg.de\\rzps2"; System.Diagnostics.Process.Start(sendInfo); sendInfo = null; sendInfo = new System.Diagnostics.ProcessStartInfo("cscript"); sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + "\\\\pub-ps01.public.ads.uni-freiburg.de\\ubps1"; System.Diagnostics.Process.Start(sendInfo); sendInfo = null; sendInfo = new System.Diagnostics.ProcessStartInfo("cscript"); sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + "\\\\pub-ps01.public.ads.uni-freiburg.de\\ubps2"; System.Diagnostics.Process.Start(sendInfo); sendInfo = null; } catch { MessageBox.Show(this, "Fehler: CONFIG.XML", "Installieren der Drucker nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error); } //################################################################# // Drucker verbinden... //NetworkDrive oNetDrive = new NetworkDrive(); try { oNetDrive.LocalDrive = ""; oNetDrive.ShareName = "\\\\pub-ps01.public.ads.uni-freiburg.de"; oNetDrive.MapDrive("PUBLIC\\" + textBox1.Text, maskedTextBox1.Text); //Warte bis das Netz da ist System.Threading.Thread.Sleep(500 * 1); } catch { MessageBox.Show(this, "Fehler: CONFIG.XML", "Verbindung zum \"Drucker\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error); //maskedTextBox1.Text = ""; //try //{ // maskedTextBox1.Focus(); //} //catch { } //return; } } //Ender der Druckerinstallation ################################### //################################################################# //################################################################# // Homedirectory mounten... if (home == "true") { try { oNetDrive.LocalDrive = "k:"; try { oNetDrive.UnMapDrive(); } catch { } oNetDrive.ShareName = "\\\\" + textBox1.Text + ".files.uni-freiburg.de\\" + textBox1.Text; oNetDrive.MapDrive("PUBLIC\\" + textBox1.Text, maskedTextBox1.Text); } catch (Exception err) { MessageBox.Show(this, "Fehler: " + err.Message, "Verbindung zum \"Homedirectory\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error); maskedTextBox1.Text = ""; try { maskedTextBox1.Focus(); } catch { } return; } //################################################################# createDesktopLinks("Homeverzeichnis K", "k:\\"); } //################################################################# // Shared Directory mounten... if (shareds == "true") { try { XmlNode xnShareds2 = doc.SelectSingleNode("/settings/eintrag/shareds"); foreach (XmlNode shared in xnShareds2.ChildNodes) { oNetDrive.LocalDrive = dl + ":"; try { oNetDrive.UnMapDrive(); } catch { } oNetDrive.ShareName = shared.Attributes["path"].InnerText; oNetDrive.MapDrive(shared.Attributes["name"].InnerText, shared.Attributes["pass"].InnerText); createDesktopLinks("Gemeinsames Laufwerk " + dl, dl + ":\\"); dl = Convert.ToChar(Convert.ToInt16(dl) - 1); } /* * Installiere auch das gemeinsame Laufwerk der Lehrpools */ try { oNetDrive.LocalDrive = "l:"; try { oNetDrive.UnMapDrive(); } catch { } oNetDrive.ShareName = "\\\\lehrpool.files.uni-freiburg.de\\lehrpool"; oNetDrive.MapDrive("PUBLIC\\lehrpool", "(atom)9"); } catch (Exception err) { MessageBox.Show(this, "Fehler: " + err.Message, "Verbindung zum \"Gemeinsamen Laufwerk L\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error); maskedTextBox1.Text = ""; try { maskedTextBox1.Focus(); } catch { } return; } createDesktopLinks("Gemeinsames Laufwerk L", "l:\\"); } catch (Exception err) { MessageBox.Show(this, "Fehler: " + err.Message, "Verbindung zum \"Gemeinsamen Laufwerk \" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error); maskedTextBox1.Text = ""; try { maskedTextBox1.Focus(); } catch { } return; } //################################################################# //createDesktopLinks("Gemeinsames Laufwerk L", "l:\\"); } /* * Bei default oder wenn in CONFIG.XML kein Eintrag shareds existiert, * wird standardes gemeinsames Laufwerk L verbunden */ else { try { oNetDrive.LocalDrive = "l:"; try { oNetDrive.UnMapDrive(); } catch { } oNetDrive.ShareName = "\\\\lehrpool.files.uni-freiburg.de\\lehrpool"; oNetDrive.MapDrive("PUBLIC\\lehrpool", "(atom)9"); } catch (Exception err) { MessageBox.Show(this, "Fehler: " + err.Message, "Verbindung zum \"Gemeinsamen Laufwerk L\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error); maskedTextBox1.Text = ""; try { maskedTextBox1.Focus(); } catch { } return; } //################################################################# createDesktopLinks("Gemeinsames Laufwerk L", "l:\\"); } //################################################################# // Drucker-Kontostand getAccountInformation(); //##################################################################################### //#### Fuege die IP-Adresse des Scanners in C:\sane\etc\sane.d\net.conf ############### if (scanners == true) { string path = @"c:\sane\etc\sane.d\net.conf"; try { using (StreamWriter sw = System.IO.File.CreateText(path)) { } string path2 = path + "temp"; // Ensure that the target does not exist. System.IO.File.Delete(path2); // Copy the file. System.IO.File.Copy(path, path2); // Delete the newly created file. System.IO.File.Delete(path2); } catch { } try { XmlNode xnScanner = doc.SelectSingleNode("/settings/eintrag/scanners/scanner"); using (StreamWriter sw = System.IO.File.CreateText(path)) { sw.WriteLine(xnScanner.Attributes["ip"].InnerText); } } catch { } } MessageBox.Show("Bitte speichern Sie Ihre Dateien im Homeverzeichnis K: oder unter \"Eigenen Dateien\"!\nAlles, was in anderen Ordner gespeichert wird, wird nach dem Logout verschwinden!", "Wichtige Information!"); }
private void MapNetworkDrive() { NetworkDrive drive = new aejw.Network.NetworkDrive(); string letter = System.Configuration.ConfigurationManager.AppSettings["letter"]; string mappath = System.Configuration.ConfigurationManager.AppSettings["map_path"]; string user = System.Configuration.ConfigurationManager.AppSettings["user"]; string password = System.Configuration.ConfigurationManager.AppSettings["password"]; try { drive.LocalDrive = letter; drive.ShareName = mappath; drive.MapDrive(user, password); drive.Persistent = true; drive.SaveCredentials = true; } catch (Exception mapexception) { errordiv.InnerHtml = "<div class=\"alert alert-danger\" role=\"alert\">" + mapexception.ToString() + "</div>"; } drive = null; }
public string mapNetworkDrives(string softwareLocation, string backupLocation, string username, string password) { NetworkDrive NDT = new aejw.Network.NetworkDrive(); NetworkDrive NDS = new aejw.Network.NetworkDrive(); try { NDT.LocalDrive = "t:"; NDT.ShareName = backupLocation; NDT.Persistent = true; NDT.SaveCredentials = true; NDT.MapDrive(username, password); NDS.LocalDrive = "s:"; NDS.ShareName = softwareLocation; NDS.Persistent = true; NDS.SaveCredentials = true; NDS.MapDrive(username, password); return "...Success"; } catch (Exception e) { Console.WriteLine(e); return "...Failed. Check your paths, username, and password."; } }
/*-------------------------------------------------------------------------- * ------------------------------- Mesas -------------------------------------*/ private void showMesas(string accion, string NombreArea, int id, string idMesa) { panel1.Visible = true; if (fnAreas.tieneAreaImagen(id)) { string pathServer = ConfigurationManager.AppSettings["RUTASERVER"]; if (pathServer == "") { MessageBox.Show("La carpeta del servidor esta inaccesible o mal configurada"); return; } string RUTASERVER = ""; string USERSERVER = ""; string CLAVESERVER = ""; try { //Veo si existen la infomracion correcta dpara el conection server RUTASERVER = ConfigurationManager.AppSettings["RUTASERVER"]; USERSERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["USERSERVER"]); CLAVESERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["CLAVESERVER"]); } catch { MessageBox.Show("Información de configuracion con el server file, necesaria"); return; } if (RUTASERVER == "" || USERSERVER == "" || CLAVESERVER == "") { MessageBox.Show("Es necesario configurar la conexión con el servidor para los archivos"); return; } NetworkDrive oNetDrive = new aejw.Network.NetworkDrive(); try { oNetDrive.LocalDrive = "Y:"; oNetDrive.ShareName = @RUTASERVER; try { oNetDrive.UnMapDrive(); } catch { } try { oNetDrive.MapDrive(USERSERVER, CLAVESERVER); } catch (Exception exp) { MessageBox.Show("MAP - Problema encontrado con: " + exp.ToString()); return; } } catch { MessageBox.Show("II. No se pudo conectar con el servidor de archivos"); return; } string imagen = ""; try { imagen = fnAreas.getImagenArea(id); } catch { } if (imagen != "") { try { panel_Mesas.BackgroundImage = Image.FromFile(@imagen); panel_Mesas.BackgroundImageLayout = ImageLayout.Center; } catch { panel_Mesas.BackgroundImage = null; } } oNetDrive.LocalDrive = "Y:"; oNetDrive.ShareName = @RUTASERVER; try { oNetDrive.UnMapDrive(); } catch { } } if (accion == "Mas") { panel_Areas.Visible = false; panel_Mesas.Visible = true; ///Label Titulo Label lb = new Label(); lb.Font = new Font("Arial", 15); lb.Location = new Point(290, 10); lb.Text = "Area: " + NombreArea; lb.BackColor = Color.Transparent; lb.ForeColor = Color.Red; buttonAdelante(id.ToString()); panel_Controles.Controls.Clear(); panel_Mesas.Controls.Clear(); CargaMesasPorCategoria(id, idMesa); panel_Mesas.Controls.Add(lb); buttonAtras(id.ToString()); } else if (accion == "Menos") { panel_Areas.Visible = false; panel_Mesas.Visible = true; ///Label Titulo Label lb = new Label(); lb.Font = new Font("Arial", 15); lb.Location = new Point(290, 10); lb.Text = "Area: " + NombreArea; lb.BackColor = Color.Transparent; lb.ForeColor = Color.Red; idMesa = "0"; buttonAtras(id.ToString()); buttonAdelante(id.ToString()); panel_Controles.Controls.Clear(); panel_Mesas.Controls.Clear(); CargaMesasPorCategoria(id, idMesa); panel_Mesas.Controls.Add(lb); } else { panel_Areas.Visible = false; panel_Mesas.Visible = true; ///Label Titulo Label lb = new Label(); lb.Font = new Font("Arial", 15); lb.Location = new Point(290, 10); lb.Text = "Area: " + NombreArea; lb.BackColor = Color.Transparent; lb.AutoSize = true; lb.ForeColor = Color.Red; panel_Controles.Controls.Clear(); panel_Mesas.Controls.Clear(); CargaMesasPorCategoria(id, idMesa); panel_Mesas.Controls.Add(lb); } }