private void button_save_Click(object sender, EventArgs e) { save = true; if (!this._userStyle) { loadNewLabelStyleIntoBase(); } SyncController.ReloadStyle(_idT); if (_firstUsedLabelStyle && (tLayer != null)) { classesOfMetods.reloadLayer(_idT); } else { for (int i = 0; i < Program.tables_info.Count; i++) { if (Program.tables_info[i].idTable == _idT) { Program.tables_info[i] = _ti; i = Program.tables_info.Count; } } if (tLayer != null) { Program.mainFrm1.layersManager1.SetLabelStyle(_idT); } } Close(); }
private void button2_Click(object sender, EventArgs e) { String result = parseResult(textBox1.Text); if (result.Replace(" ", "") == "" && check_showLabel.Checked) { MessageBox.Show(Rekod.Properties.Resources.LabelControl_NotEmpty, Properties.Resources.AWT_EditLabel, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (result.Contains("SELECT") || result.Contains("DROP") || result.Contains("INSERT") || result.Contains("UPDATE") || result.Contains("DELETE")) { MessageBox.Show(Rekod.Properties.Resources.LabelControl_InvalidExpression, Properties.Resources.AWT_EditLabel, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SqlWork sqlCmd = new SqlWork(true); if (result.Replace(" ", "") != "") { tablesInfo ti = classesOfMetods.getTableInfo(_idT); sqlCmd.sql = string.Format("SELECT {0} FROM \"{1}\".\"{2}\" LIMIT 1", result, ti.nameSheme, ti.nameDB); try { sqlCmd.ExecuteNonQuery(null); } catch { MessageBox.Show(Rekod.Properties.Resources.LabelControl_InvalidExpression, Properties.Resources.AWT_EditLabel, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { sqlCmd.Close(); } } _rezult = result; if (!userStyle) { Params par = new Params(); par.paramName = "@labelexpr"; par.typeData = NpgsqlDbType.Varchar; par.value = (!String.IsNullOrEmpty(result.Replace(" ", ""))) ? result : null; sqlCmd = new SqlWork(); if (!Program.WorkSets.CurrentWorkSet.IsDefault) { sqlCmd.sql = String.Format("UPDATE sys_scheme.table_info_sets SET lablefiled=@labelexpr, label_showlabel={1} WHERE id_table={0} AND id_set = {2}", _idT, check_showLabel.Checked, Program.WorkSets.CurrentWorkSet.Id); } else { sqlCmd.sql = String.Format("UPDATE sys_scheme.table_info SET lablefiled=@labelexpr, label_showlabel={1} WHERE id={0}", _idT, check_showLabel.Checked); } sqlCmd.ExecuteNonQuery(new IParams[] { par }); sqlCmd.Close(); sqlCmd = new SqlWork(); sqlCmd.sql = String.Format("SELECT sys_scheme.create_view_for_table({0})", _idT); sqlCmd.ExecuteNonQuery(); sqlCmd.Close(); classesOfMetods.reloadLayer(_idT); SyncController.ReloadStyle(_idT); } if (_parent != null) { _parent.CloseElemsAfter(this, true); } Program.mainFrm1.axMapLIb1.mapRepaint(); }