Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 WindowsFormsApplication1
- {
- public partial class Glumci : Form
- {
- MySqlConnection konekcija = new MySqlConnection();
- MySqlCommand komanda = new MySqlCommand();
- MySqlDataAdapter da = new MySqlDataAdapter();
- DataTable glumac = new DataTable();
- DataTable pom = new DataTable();
- public Glumci()
- {
- InitializeComponent();
- }
- private void Form2_Load(object sender, EventArgs e)
- {
- konekcija.ConnectionString = "Server=192.168.10.21; DATABASE=32golubs_b3;" + "UID=32golubs; PASSWORD=123";
- komanda.Connection = konekcija;
- da.SelectCommand = komanda;
- if (!konekcija.Ping())
- konekcija.Open();
- komanda.CommandText = "SELECT * FROM glumac ORDER BY GlumacID ASC";
- da.Fill(glumac);
- dataGridView1.DataSource = glumac;
- }
- private void button4_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (!konekcija.Ping())
- konekcija.Open();
- if (textBox1.Text != "")
- {
- komanda.CommandText = "DELETE FROM uloga where GlumacID=" + textBox1.Text + ";";
- komanda.CommandText += "DELETE FROM glumac where GlumacID=" + textBox1.Text;
- if (komanda.ExecuteNonQuery() == 1)
- {
- MessageBox.Show("Uspesno obrisano");
- }
- }
- komanda.CommandText = "SELECT * FROM glumac ORDER BY GLumacID ASC";
- glumac.Clear();
- da.Fill(glumac);
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- try
- {
- if (!konekcija.Ping())
- konekcija.Open();
- //komanda.CommandText = "INSERT INTO glumac(GlumacID, Ime,Prezime,DatumRodjenja,MestoRodjenja) values(" + textBox1.Text + ",'" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text+ "')";
- //komanda.ExecuteNonQuery();
- komanda.CommandText = "SELECT * FROM glumac where GlumacID='"+textBox1.Text+"'";
- glumac.Clear();
- da.Fill(glumac);
- textBox2.Text = glumac.Rows[0][1].ToString();
- textBox3.Text = glumac.Rows[0][2].ToString();
- textBox4.Text = glumac.Rows[0][3].ToString();
- textBox5.Text = glumac.Rows[0][4].ToString();
- }
- catch
- {
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (!konekcija.Ping())
- konekcija.Open();
- if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "")
- {
- DateTime d = Convert.ToDateTime(textBox4.Text);
- komanda.CommandText = "INSERT INTO glumac values(" + textBox1.Text + ",'" + textBox2.Text + "','" + textBox3.Text + "','" + d.ToString("yyyy-MM-dd") + "','" + textBox5.Text + "')";
- komanda.ExecuteNonQuery();
- }
- }
- catch (FormatException)
- {
- MessageBox.Show("Molimo upisite u pravilnom formatu");
- textBox4.Clear();
- }
- catch { }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- try
- {
- if (!konekcija.Ping())
- konekcija.Open();
- if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "")
- {
- DateTime d = Convert.ToDateTime(textBox4.Text);
- komanda.CommandText = "UPDATE glumac SET ime = '" + textBox2.Text + "', prezime = '" + textBox3.Text + "', DatumRodjenja='" + d.ToString("yyyy-MM-dd") + "', MestoRodjenja='" + textBox5.Text + "' where GlumacID=" + textBox1.Text + " ";
- komanda.ExecuteNonQuery();
- }
- komanda.CommandText = "SELECT * FROM glumac ORDER BY GlumacID ASC";
- glumac.Clear();
- da.Fill(glumac);
- }
- catch (FormatException)
- {
- MessageBox.Show("Molimo upisite u pravilnom formatu");
- textBox4.Clear();
- }
- catch { }
- }
- private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement