private void PlaceInfo_DBConnectTestButton_Click(object sender, EventArgs e) { bool flag = PlaceInfoHelper.TestConnection(PlaceInfo_GetConnectString()); MessageBox.Show((flag) ? "Подключение выполнено!" : "Подключение не выполнено!", "Тест подключения", MessageBoxButtons.OK, (flag) ? MessageBoxIcon.Information : MessageBoxIcon.Error); PlaceInfo_SaveUsedVals(); }
private void PlaceInfo_ApplyChangesButton_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Вы действительно хотите внести изменения в БД?", "Внимание", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } string data = ""; Control[] ctrls = new Control[] { PlaceInfo_NewData1Box, PlaceInfo_NewData2Box, PlaceInfo_NewData3Box, PlaceInfo_NewData4Box, PlaceInfo_NewData5Box }; int index = 0; foreach (Control ctrl in ctrls) { data += ctrl.Text + ((index >= ctrls.Length - 1) ? "" : "\r\n"); index++; } PlaceInfoHelper.SetPlaceData(PlaceInfo_GetConnectString(), data); MessageBox.Show("Изменения успешно внесены", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); PlaceInfo_PrintCurrentData(); PlaceInfo_SaveUsedVals(); } catch (Exception ex) { AppHelper.CreateMessage(ex.ToString(), Feodosiya.Lib.Logs.MessageType.Error, true); } }
private void PlaceInfo_UploadNewDataFileButton_Click(object sender, EventArgs e) { try { MainOpenFileDialog.Title = "Выбор файла с данными"; MainOpenFileDialog.FileName = ""; MainOpenFileDialog.Filter = "Текстовый файл|*.txt|Все файлы|*.*"; MainOpenFileDialog.CheckFileExists = true; MainOpenFileDialog.CheckPathExists = true; if (MainOpenFileDialog.ShowDialog() == DialogResult.OK) { string[] data = PlaceInfoHelper.UploadTextFile(MainOpenFileDialog.FileName); Control[] ctrls = new Control[] { PlaceInfo_NewData1Box, PlaceInfo_NewData2Box, PlaceInfo_NewData3Box, PlaceInfo_NewData4Box, PlaceInfo_NewData5Box }.Select(c => { c.Text = ""; return(c); }).ToArray(); for (int i = 0; i < data.Length; i++) { if (i >= ctrls.Length) { break; } ctrls[i].Text = data[i]; } } } catch (Exception ex) { AppHelper.CreateMessage(ex.ToString(), Feodosiya.Lib.Logs.MessageType.Error, true); } }
private void PlaceInfo_SaveCurrentDataButton_Click(object sender, EventArgs e) { try { MainSaveFileDialog.Title = "Сохранение файла с данными"; MainSaveFileDialog.FileName = ""; MainSaveFileDialog.Filter = "Текстовый файл|*.txt|Все файлы|*.*"; if (MainSaveFileDialog.ShowDialog() == DialogResult.OK) { PlaceInfoHelper.SaveTextFile(MainSaveFileDialog.FileName, PlaceInfo_CurrentDataBox.Text); } } catch (Exception ex) { AppHelper.CreateMessage(ex.ToString(), Feodosiya.Lib.Logs.MessageType.Error, true); } }
private void PlaceInfo_PrintCurrentData() { try { PlaceInfoHelper.PlaceInfo[] placeInfos = PlaceInfoHelper.GetPlaceData(PlaceInfo_GetConnectString()).ToArray(); string data = ""; int index = 0; foreach (PlaceInfoHelper.PlaceInfo info in placeInfos) { data += string.Format("[{0}]\r\n{1}\r\n{2}", info.Name, info.Data, ((index >= placeInfos.Length - 1) ? "" : "\r\n")); index++; } PlaceInfo_CurrentDataBox.Text = data; } catch (Exception ex) { AppHelper.CreateMessage(ex.ToString(), Feodosiya.Lib.Logs.MessageType.Error, true); } }