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 System.Data.SqlClient;
- namespace PrvaAplikacijaOfc
- {
- public partial class Pregled_na_izdadeni_karticki : Form
- {
- private String connString = "Data Source=WIN-3QUAK81995Q;Initial Catalog=lt-2;Persist Security Info=True;User ID=lt-2;Password=lt-2P@ssw0rd";
- public Pregled_na_izdadeni_karticki()
- {
- InitializeComponent();
- }
- private void btnnovakarticka_Click(object sender, EventArgs e)
- {
- panelnovakarticka.Visible = true;
- }
- private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void Pregled_na_izdadeni_karticki_Load(object sender, EventArgs e)
- {
- var select = "select cardnumber,[status],cp.name_series,print_name,print_surname,embg_user from cards_issued c join card_products cp on c.idproduct=cp.idproduct";
- var c = new SqlConnection("Data Source=WIN-3QUAK81995Q;Initial Catalog=lt-2;Persist Security Info=True;User ID=lt-2;Password=lt-2P@ssw0rd"); // Your Connection String here
- var dataAdapter = new SqlDataAdapter(select, c);
- var commandBuilder = new SqlCommandBuilder(dataAdapter);
- var ds = new DataSet();
- dataAdapter.Fill(ds);
- dataGridView1.ReadOnly = true;
- dataGridView1.DataSource = ds.Tables[0];
- }
- private void btnfilter_Click(object sender, EventArgs e)
- {
- if (txtembg.Text != "")
- {
- var select = "select cardnumber,[status],cp.name_series,print_name,print_surname,embg_user from cards_issued c join card_products cp on c.idproduct=cp.idproduct where embg_user='" + txtembg.Text + "'";
- var c = new SqlConnection("Data Source=WIN-3QUAK81995Q;Initial Catalog=lt-2;Persist Security Info=True;User ID=lt-2;Password=lt-2P@ssw0rd"); // Your Connection String here
- var dataAdapter = new SqlDataAdapter(select, c);
- var commandBuilder = new SqlCommandBuilder(dataAdapter);
- var ds = new DataSet();
- dataAdapter.Fill(ds);
- dataGridView1.ReadOnly = true;
- dataGridView1.DataSource = ds.Tables[0];
- }
- else
- {
- var select = "select cardnumber,[status],cp.name_series,print_name,print_surname,embg_user from cards_issued c join card_products cp on c.idproduct=cp.idproduct";
- var c = new SqlConnection("Data Source=WIN-3QUAK81995Q;Initial Catalog=lt-2;Persist Security Info=True;User ID=lt-2;Password=lt-2P@ssw0rd"); // Your Connection String here
- var dataAdapter = new SqlDataAdapter(select, c);
- var commandBuilder = new SqlCommandBuilder(dataAdapter);
- var ds = new DataSet();
- dataAdapter.Fill(ds);
- dataGridView1.ReadOnly = true;
- dataGridView1.DataSource = ds.Tables[0];
- }
- }
- private void label5_Click(object sender, EventArgs e)
- {
- }
- private void panelnovakarticka_Enter(object sender, EventArgs e)
- {
- // Random random = new Random();
- // txtcvc.Text = Convert.ToString(random.Next(100, 999));
- }
- private void panelnovakarticka_Layout(object sender, LayoutEventArgs e)
- {
- Random random = new Random();
- txtcvc.Text = Convert.ToString(random.Next(100, 999));
- txtdatum.Text = DateTime.Now.Month.ToString("00") + "." + DateTime.Now.AddYears(3).Year.ToString();
- }
- private void ddltip_SelectedIndexChanged(object sender, EventArgs e)
- {
- Random random = new Random();
- string str = ddltip.SelectedItem.ToString();
- char[] split = new char[] { ' ' };
- string firstWord = str.Split(split)[0];
- if (firstWord == "Master")
- {
- string number1 = Convert.ToString(random.Next(10000, 99999));
- string number2 = Convert.ToString(random.Next(100000, 999999));
- long sum = 0;
- long r;
- string sample = "5214"+number1 +number2;
- long num = Convert.ToInt64(sample);
- while (num != 0)
- {
- r = num % 10;
- num = num / 10;
- sum = sum + r;
- }
- sum = sum % 10;
- txtbroj.Text = "5214" + number1.ToString() + number2.ToString() + sum.ToString();
- }
- else
- {
- string number1 = Convert.ToString(random.Next(10000, 99999));
- string number2 = Convert.ToString(random.Next(100000, 999999));
- long sum = 0;
- long r;
- string sample = "4324"+number1 + number2;
- long num = Convert.ToInt64(sample);
- while (num != 0)
- {
- r = num % 10;
- num = num / 10;
- sum = sum + r;
- }
- sum = sum % 10;
- txtbroj.Text = "4324" + number1 + number2 + sum.ToString();
- }
- }
- private void embg_TextChanged(object sender, EventArgs e)
- {
- if (embg.Text.Length == 13)
- {
- //MessageBox.Show("sa");
- using (SqlConnection connection = new SqlConnection(connString))
- {
- connection.Open();
- string query = "select ime from adresar where embg='" + embg.Text + "'";
- using (SqlCommand command = new SqlCommand(query, connection))
- {
- using (SqlDataReader reader = command.ExecuteReader())
- {
- while (reader.Read())
- {
- txtname.Text = reader.GetString(0);
- }
- }
- }
- }
- using (SqlConnection connection = new SqlConnection(connString))
- {
- connection.Open();
- string query = "select prezime from adresar where embg='" + embg.Text + "'";
- using (SqlCommand command = new SqlCommand(query, connection))
- {
- using (SqlDataReader reader = command.ExecuteReader())
- {
- while (reader.Read())
- {
- txtsurname.Text = reader.GetString(0);
- }
- }
- }
- }
- }
- }
- private void embg_Leave(object sender, EventArgs e)
- {
- }
- private void btnvnesi_Click(object sender, EventArgs e)
- {
- string id;
- using (SqlConnection connection = new SqlConnection(connString))
- {
- connection.Open();
- string query1 = "insert into cards_issued values('" + txtbroj.Text + "', '" + txtdatum.Text + "', '" + txtcvc.Text + "', '" + txtname.Text + "', '" + txtsurname.Text + "', '" + ddltip.SelectedIndex.ToString() + "', 1, '" + embg.Text+"')";
- SqlCommand command1 = new SqlCommand(query1, connection);
- command1.ExecuteNonQuery();
- }
- dataGridView1.Refresh();
- }
- private void btnizberi_Click(object sender, EventArgs e)
- {
- string broj = dataGridView1.SelectedCells[0].Value.ToString();
- this.Hide();
- Pregled_na_transakcii pregled = new Pregled_na_transakcii();
- pregled.MyProperty = broj;
- pregled.Show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement