Initial commit
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
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 CompanyListsData : Form
|
||||
{
|
||||
private MySqlDataAdapter sqlDataAdapter = null;
|
||||
private MySqlCommandBuilder sqlCommandBuilder = null;
|
||||
private DataTable dataTable = null;
|
||||
private BindingSource bindingSource = null;
|
||||
|
||||
public CompanyListsData()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LoadCurrentKontrah()
|
||||
{
|
||||
sqlDataAdapter = new MySqlDataAdapter("select PRT_ID,PRT_NAME,PRT_DESCRIPTION from sys_participants order by PRT_ID", mySqlFunctions.connection);
|
||||
sqlCommandBuilder = new MySqlCommandBuilder(sqlDataAdapter);
|
||||
dataTable = new DataTable();
|
||||
sqlDataAdapter.Fill(dataTable);
|
||||
bindingSource = new BindingSource();
|
||||
bindingSource.DataSource = dataTable;
|
||||
dataGridViewKontrahList.DataSource = bindingSource;
|
||||
|
||||
dataGridViewKontrahList.Columns["PRT_ID"].HeaderText = "Id";
|
||||
dataGridViewKontrahList.Columns["PRT_ID"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||
|
||||
dataGridViewKontrahList.Columns["PRT_NAME"].HeaderText = "Nazwa skrócona";
|
||||
dataGridViewKontrahList.Columns["PRT_NAME"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
dataGridViewKontrahList.Columns["PRT_DESCRIPTION"].HeaderText = "Nazwa pełna";
|
||||
dataGridViewKontrahList.Columns["PRT_DESCRIPTION"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void CompanyListsData_Load(object sender, EventArgs e)
|
||||
{
|
||||
//Dla RAMBu
|
||||
buttonDodajKonrtah.Visible = false;
|
||||
|
||||
buttonSave.Visible = false;
|
||||
buttonClose.Visible = true;
|
||||
|
||||
mySqlFunctions.initConnection();
|
||||
if (mySqlFunctions.OpenConnection())
|
||||
{
|
||||
|
||||
LoadCurrentKontrah();
|
||||
mySqlFunctions.CloseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridViewKontrahList_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 buttonDodajKonrtah_Click(object sender, EventArgs e)
|
||||
{
|
||||
CompanyListsDataAdd newAddForm = new CompanyListsDataAdd();
|
||||
newAddForm.FormClosed += new FormClosedEventHandler(buttonDodajKonrtah_FormClosed);
|
||||
newAddForm.ShowDialog();
|
||||
}
|
||||
|
||||
void buttonDodajKonrtah_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
buttonSave.Visible = false;
|
||||
buttonClose.Visible = true;
|
||||
|
||||
mySqlFunctions.initConnection();
|
||||
if (mySqlFunctions.OpenConnection())
|
||||
{
|
||||
|
||||
LoadCurrentKontrah();
|
||||
mySqlFunctions.CloseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user