Initial commit
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
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;
|
||||
|
||||
namespace StacjaProb
|
||||
{
|
||||
public partial class manufacturersFormAdd : Form
|
||||
{
|
||||
public int prodID;
|
||||
|
||||
public manufacturersFormAdd()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void manufacturersFormAdd_Load(object sender, EventArgs e)
|
||||
{
|
||||
//DLa RAMBu
|
||||
buttonSave.Visible = false;
|
||||
|
||||
if (prodID>0)
|
||||
{
|
||||
//wczytuje dane do formularza
|
||||
mySqlFunctions.initConnection();
|
||||
if (mySqlFunctions.OpenConnection())
|
||||
{
|
||||
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("SELECT MCF_NAME,MCF_CATEGORY,MCF_ADDRESS,MCF_POST,MCF_CITY,MCF_MAIL,MCF_PHONE,MCF_CONT_PERSON,MCF_DESCTRIPTION from seg_manufacturers where MCF_ID=" + prodID.ToString(), mySqlFunctions.connection);
|
||||
MySql.Data.MySqlClient.MySqlDataReader dataReader = cmd.ExecuteReader();
|
||||
while (dataReader.Read())
|
||||
{
|
||||
//comboBoxStanowisko.Items.Insert(Convert.ToInt32(dataReader["TPL_ID"]), dataReader["TPL_NAME"].ToString());
|
||||
textBoxNazwa.Text = dataReader["MCF_NAME"].ToString();
|
||||
textBoxKategoria.Text = dataReader["MCF_CATEGORY"].ToString();
|
||||
textBoxAdres.Text = dataReader["MCF_ADDRESS"].ToString();
|
||||
textBoxKodPocztowy.Text = dataReader["MCF_POST"].ToString();
|
||||
textBoxMiasto.Text = dataReader["MCF_CITY"].ToString();
|
||||
textBoxMail.Text = dataReader["MCF_MAIL"].ToString();
|
||||
textBoxTel.Text = dataReader["MCF_PHONE"].ToString();
|
||||
textBoxOsoba.Text = dataReader["MCF_CONT_PERSON"].ToString();
|
||||
richTextBoxOpis.Text = dataReader["MCF_DESCTRIPTION"].ToString();
|
||||
}
|
||||
mySqlFunctions.CloseConnection();
|
||||
//comboBoxStanowisko.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
buttonSave.Enabled = false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
string query_insert;
|
||||
mySqlFunctions.initConnection();
|
||||
if (mySqlFunctions.OpenConnection())
|
||||
{
|
||||
if (prodID>0)
|
||||
query_insert = "update seg_manufacturers SET MCF_NAME='" + textBoxNazwa.Text
|
||||
+ "',MCF_CATEGORY='" + textBoxKategoria.Text
|
||||
+ "',MCF_ADDRESS='" + textBoxAdres.Text
|
||||
+ "',MCF_POST='" + textBoxKodPocztowy.Text
|
||||
+ "',MCF_CITY='" + textBoxMiasto.Text
|
||||
+ "',MCF_MAIL='" + textBoxMail.Text
|
||||
+ "',MCF_PHONE='" + textBoxTel.Text
|
||||
+ "',MCF_CONT_PERSON='" + textBoxOsoba.Text
|
||||
+ "',MCF_DESCTRIPTION='" + richTextBoxOpis.Text + "' where MCF_ID="+prodID.ToString();
|
||||
else
|
||||
query_insert = "INSERT INTO seg_manufacturers SET MCF_NAME='" + textBoxNazwa.Text
|
||||
+ "',MCF_CATEGORY='" + textBoxKategoria.Text
|
||||
+ "',MCF_ADDRESS='" + textBoxAdres.Text
|
||||
+ "',MCF_POST='" + textBoxKodPocztowy.Text
|
||||
+ "',MCF_CITY='" + textBoxMiasto.Text
|
||||
+ "',MCF_MAIL='" + textBoxMail.Text
|
||||
+ "',MCF_PHONE='" + textBoxTel.Text
|
||||
+ "',MCF_CONT_PERSON='" + textBoxOsoba.Text
|
||||
+ "',MCF_DESCTRIPTION='" + richTextBoxOpis.Text + "'";
|
||||
|
||||
|
||||
MySql.Data.MySqlClient.MySqlCommand cmd_01 = new MySql.Data.MySqlClient.MySqlCommand(query_insert, mySqlFunctions.connection);
|
||||
cmd_01.ExecuteNonQuery();
|
||||
|
||||
mySqlFunctions.CloseConnection();
|
||||
}
|
||||
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void textBoxNazwa_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(textBoxNazwa.Text)) buttonSave.Enabled = true;
|
||||
}
|
||||
|
||||
private void buttonClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user