public static void Add_New_Database(String displayName, String connectionString, String serverName, ComboBox combobox) { if (!Check_Database_Exist_Or_Not(serverName, displayName)) { String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(file_path); String x = "//Servers//Server[@displayName='" + serverName + "']"; XmlNode root = xmlDoc.SelectSingleNode(x); XmlElement xmlEle = xmlDoc.CreateElement("databasename"); XmlAttribute newAttr1 = xmlDoc.CreateAttribute("displayName"); XmlAttribute newAttr2 = xmlDoc.CreateAttribute("connectionString"); newAttr1.Value = displayName; newAttr2.Value = connectionString; xmlEle.Attributes.Append(newAttr1); xmlEle.Attributes.Append(newAttr2); root.InsertAfter(xmlEle, root.SelectSingleNode("/Server")); xmlDoc.Save(file_path); combobox.IsEnabled = true; combobox.Items.Add(displayName); MessageBox.Show("Database Added Successfully"); return; } MessageBox.Show("Sorry Already Exist Database with this name"); return; }
public static void Add_New_Server(String serverName, String value, ComboBox combobox) { if (!Check_Server_Exist_Or_Not(serverName)) { combobox.IsEnabled = true; combobox.Items.Add(serverName); String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(file_path); XmlNode root = xmlDoc.DocumentElement; XmlElement xmlEle = xmlDoc.CreateElement("Server"); XmlAttribute newAttr1 = xmlDoc.CreateAttribute("displayName"); XmlAttribute newAttr2 = xmlDoc.CreateAttribute("value"); newAttr1.Value = serverName; newAttr2.Value = value; xmlEle.Attributes.Append(newAttr1); xmlEle.Attributes.Append(newAttr2); root.InsertAfter(xmlEle, root.SelectSingleNode("/Server")); xmlDoc.Save(file_path); MessageBox.Show("Successfully Added New Server"); return; } MessageBox.Show("Already Exist With This Name"); return; }
public ManagerMainWindow() { InitializeComponent(); // DatabaseComboBox.SelectedIndex = 0; const int snugContentWidth = 380; const int snugContentHeight = 550; var horizontalBorderHeight = SystemParameters.ResizeFrameHorizontalBorderHeight; var verticalBorderWidth = SystemParameters.ResizeFrameVerticalBorderWidth; var captionHeight = SystemParameters.CaptionHeight; Width = snugContentWidth + 2 * verticalBorderWidth; Height = snugContentHeight + captionHeight + 2 * horizontalBorderHeight; ServerOperations.initializeServerInComboBox(ServerComboBox); Show_Project_Path.Content = CommanOperations.project_path(); var countitem = ServerComboBox.Items.Count; if (countitem == 0) { ServerComboBox.IsEnabled = false; } DatabaseComboBox.IsEnabled = false; //m_tab_control.TabPages["rohit"] }
private void Delete_database_btn_Click(object sender, RoutedEventArgs e) { String dbName = Show_Database_Path.Content.ToString(); String serverName = Show_Server_Path.Content.ToString(); if (serverName.Equals("")) { MessageBox.Show("Please Select Server From Drop Down to Delete"); return; } if (dbName.Equals("")) { MessageBox.Show("Please Select Database From Drop Down to Delete"); return; } int selectedIndex = DatabaseComboBox.SelectedIndex; DatabaseComboBox.Items.RemoveAt(selectedIndex); DatabaseOperations.Delete_Database(serverName, dbName); var countitem = DatabaseComboBox.Items.Count; if (countitem == 0) { DatabaseComboBox.IsEnabled = false; } Show_Database_Path.Content = ""; connectionStringLabel.Text = CommanOperations.DisplayValueChange(connectionStringLabel.Text.ToString(), "", 2); //DatabaseNameLabel.Content = "Database Name : "; MessageBox.Show("Delete Database Successfully"); return; }
private void userTextboxChange(object sender, TextChangedEventArgs args) { string before = CommanOperations.stringBefore_Nth_equal(connectionStringLabel.Text.ToString(), 3); string after = CommanOperations.stringAfter_Nth_equal(connectionStringLabel.Text.ToString(), 3); connectionStringLabel.Text = before + usernametextbox.Text + after; return; }
private void PasswordChangedHandler(Object sender, RoutedEventArgs args) { int len = passwordtextbox.Password.Length; String temp = ""; for (int i = 0; i < len; i++) { temp += "*"; } connectionStringLabel.Text = CommanOperations.DisplayValueChange(connectionStringLabel.Text.ToString(), temp, 4); return; }
public static List <String> List_of_All_Server() { List <String> serverList = new List <String>(); String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument document = new XmlDocument(); document.Load(@file_path); var nodes1 = document.SelectNodes("//Server"); foreach (XmlNode node in nodes1) { serverList.Add(node.Attributes[0].Value); } return(serverList); }
private void Replace_btn_Click(object sender, RoutedEventArgs e) { String folderPath = Show_Project_Path.Content.ToString(); if (folderPath.Equals("")) { MessageBox.Show("Please Select The Project"); return; } List <String> file_list = File_Names_To_replace_connectionString(folderPath); if (file_list.Count == 0) { MessageBox.Show("Please Select Atleast one File Extension"); return; } String serverName = Show_Server_Path.Content.ToString(); String databasename = Show_Database_Path.Content.ToString(); if ((serverName.Equals("")) || (databasename.Equals(""))) { MessageBox.Show("Please Select Both Server And Database"); return; } String Username = usernametextbox.Text.Trim(); String Password = passwordtextbox.Password; String serverValue = ServerOperations.Get_server_value(Show_Server_Path.Content.ToString()); String databaseName = DatabaseOperations.Get_connection_string(serverName, databasename); String replaceBy = serverValue + "\\" + databaseName + "\\" + Username + "\\" + Password; foreach (String file_path in file_list) { CommanOperations.replace_connectingStrInXmlConfig_file(file_path, replaceBy); } String message = "Replace Successfully" + "\n"; message = message + "connection string value : " + "\n"; message = message + replaceBy; MessageBox.Show(message); return; }
public static bool Check_Server_Exist_Or_Not(String serverName) { String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument document = new XmlDocument(); document.Load(@file_path); var nodes1 = document.SelectNodes("//Server"); foreach (XmlNode node in nodes1) { if (node.Attributes[0].Value.Equals(serverName)) { return(true); } } return(false); }
private void ServerComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { //int selectedIndex = DatabaseComboBox.SelectedIndex; ComboBox cbx = (ComboBox)sender; string serverName = String.Empty; if (cbx.SelectedValue == null) { serverName = cbx.SelectionBoxItem.ToString(); } else { serverName = cboParser(cbx.SelectedValue.ToString()); } Show_Server_Path.Content = serverName; string serverValue = ServerOperations.Get_server_value(Show_Server_Path.Content.ToString()); //connectionStringLabel connectionStringLabel.Text = CommanOperations.DisplayValueChange(connectionStringLabel.Text.ToString(), serverValue, 1); DatabaseComboBox.Items.Clear(); Show_Database_Path.Content = ""; connectionStringLabel.Text = CommanOperations.DisplayValueChange(connectionStringLabel.Text.ToString(), "", 2); //DatabaseNameLabel.Content = "Database Name : ";// + DatabaseOperations.Get_connection_string(Show_Server_Path.Content.ToString(), Show_Database_Path.Content.ToString()); DatabaseOperations.initializeDatabaseInComboBox(serverName, DatabaseComboBox); var countitem = DatabaseComboBox.Items.Count; if (countitem == 0) { DatabaseComboBox.IsEnabled = false; } else { DatabaseComboBox.IsEnabled = true; } return; }
public static List <String> List_All_Database_For_SelectedServer(String ServerName) { String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument doc = new XmlDocument(); doc.Load(file_path); String x = "/Servers/Server[@displayName = '" + ServerName + "']"; x = x + "/databasename"; var node1 = doc.SelectNodes(x); List <String> dblist = new List <String>(); foreach (XmlNode node in node1) { dblist.Add(node.Attributes[0].Value); } return(dblist); }
public static void Delete_Database(String serverName, String databasename) { String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument doc = new XmlDocument(); doc.Load(file_path); String x = "/Servers/Server[@displayName = '" + serverName + "']"; x = x + "/databasename[@displayName = '" + databasename + "']"; XmlNode node = doc.SelectSingleNode(x); if (node != null) { XmlNode parent = node.ParentNode; parent.RemoveChild(node); doc.Save(@file_path); } }
public static void Delete_Server(String serverName) { String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument doc = new XmlDocument(); doc.Load(file_path); String x = "/Servers/Server[@displayName = '" + serverName + "']"; XmlNode node = doc.SelectSingleNode(x); if (node != null) { XmlNode parent = node.ParentNode; parent.RemoveChild(node); //string newXML = doc.OuterXml; doc.Save(@file_path); } return; }
public static string Get_server_value(String serverName) { String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument doc = new XmlDocument(); doc.Load(file_path); String x = "/Servers/Server[@displayName = '" + serverName + "']"; //x = x + "/databasename[@displayName = '" + databasename + "']"; XmlNode node = doc.SelectSingleNode(x); if (node != null) { String connectionString = node.Attributes["value"].Value; return(connectionString); } return("-1"); }
public static bool Check_Database_Exist_Or_Not(String serverName, String databasename) { String file_path = CommanOperations.Path_of_StoreDB_XML_file(); XmlDocument doc = new XmlDocument(); doc.Load(file_path); String x = "/Servers/Server[@displayName = '" + serverName + "']"; x = x + "/databasename"; var nodes = doc.SelectNodes(x); foreach (XmlNode node in nodes) { if (node.Attributes[0].Value.Equals(databasename)) { return(true); } } return(false); }
//public ComboBox DatabaseComboBox; /* * private void Select_Project_btn_Click(object sender, RoutedEventArgs e) * { * * System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog(); * System.Windows.Forms.DialogResult result = folderDialog.ShowDialog(); * * if (result == System.Windows.Forms.DialogResult.OK) * { * Show_Project_Path.Content = folderDialog.SelectedPath; //project_path * } * return; * * } */ private void DatabaseComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { //int selectedIndex = DatabaseComboBox.SelectedIndex; ComboBox cbx = (ComboBox)sender; string dbname = String.Empty; if (cbx.SelectedValue == null) { dbname = cbx.SelectionBoxItem.ToString(); } else { dbname = cboParser(cbx.SelectedValue.ToString()); } Show_Database_Path.Content = dbname; string dbvalue = DatabaseOperations.Get_connection_string(Show_Server_Path.Content.ToString(), Show_Database_Path.Content.ToString()); connectionStringLabel.Text = CommanOperations.DisplayValueChange(connectionStringLabel.Text.ToString(), dbvalue, 2); //DatabaseNameLabel.Content = "Database Name : " + DatabaseOperations.Get_connection_string(Show_Server_Path.Content.ToString(), Show_Database_Path.Content.ToString()); ; return; }