Initial commit
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
|
||||
namespace StacjaProb
|
||||
{
|
||||
public partial class dictionariesForm : Form
|
||||
{
|
||||
|
||||
private MySqlDataAdapter sqlDataAdapter = null;
|
||||
private MySqlCommandBuilder sqlCommandBuilder = null;
|
||||
private DataTable dataTable = null;
|
||||
private BindingSource bindingSource = null;
|
||||
|
||||
|
||||
public dictionariesForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private void LoadCurrentDictionaries()
|
||||
{
|
||||
//dataGridViewDicList.Rows.Clear();
|
||||
|
||||
|
||||
sqlDataAdapter = new MySqlDataAdapter("select DIC_ID,DIC_POL_LANG from sys_dictionaries where DIC_TYPE_ID=1 order by DIC_POL_LANG", mySqlFunctions.connection);
|
||||
sqlCommandBuilder = new MySqlCommandBuilder(sqlDataAdapter);
|
||||
dataTable = new DataTable();
|
||||
sqlDataAdapter.Fill(dataTable);
|
||||
bindingSource = new BindingSource();
|
||||
bindingSource.DataSource = dataTable;
|
||||
dataGridViewDicList.DataSource = bindingSource;
|
||||
|
||||
dataGridViewDicList.Columns["DIC_ID"].HeaderText = "Id";
|
||||
dataGridViewDicList.Columns["DIC_ID"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||
dataGridViewDicList.Columns["DIC_POL_LANG"].HeaderText = "Nazwa";
|
||||
dataGridViewDicList.Columns["DIC_POL_LANG"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void dictionariesForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
//Dla RAMBu
|
||||
buttonDodajSlownik.Visible = false;
|
||||
|
||||
buttonSave.Visible = false;
|
||||
buttonClose.Visible = true;
|
||||
|
||||
mySqlFunctions.initConnection();
|
||||
if (mySqlFunctions.OpenConnection())
|
||||
{
|
||||
|
||||
LoadCurrentDictionaries();
|
||||
mySqlFunctions.CloseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridViewDicList_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
buttonClose.Visible = false;
|
||||
buttonSave.Visible = true;
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
mySqlFunctions.initConnection();
|
||||
if (mySqlFunctions.OpenConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
sqlDataAdapter.Update(dataTable);
|
||||
}
|
||||
catch (Exception exceptionObj)
|
||||
{
|
||||
MessageBox.Show(exceptionObj.Message.ToString());
|
||||
}
|
||||
mySqlFunctions.CloseConnection();
|
||||
}
|
||||
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void buttonDodajSlownik_Click(object sender, EventArgs e)
|
||||
{
|
||||
dictionariesAddForm dicform = new dictionariesAddForm();
|
||||
dicform.FormClosed += new FormClosedEventHandler(buttonDodajSlownik_FormClosed);
|
||||
dicform.ShowDialog();
|
||||
}
|
||||
|
||||
void buttonDodajSlownik_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
buttonSave.Visible = false;
|
||||
buttonClose.Visible = true;
|
||||
|
||||
mySqlFunctions.initConnection();
|
||||
if (mySqlFunctions.OpenConnection())
|
||||
{
|
||||
|
||||
LoadCurrentDictionaries();
|
||||
mySqlFunctions.CloseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user