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=32zvekic_b3;" + "UID=32zvekic; 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 glumac where GlumacID=" + textBox1.Text;
- }
- komanda.CommandText = "SELECT * FROM glumac ORDER BY GlumacID ASC";
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- if (textBox1.Text != "")
- {
- try
- {
- int x = Convert.ToInt32(textBox1.Text);
- }
- catch (FormatException)
- {
- MessageBox.Show("Ukucaj broj");
- textBox1.Clear();
- }
- 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();
- }
- }
- 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