Advertisement
Guest User

Untitled

a guest
Apr 17th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11.  
  12. namespace PrvaAplikacijaOfc
  13. {
  14. public partial class Pregled_na_izdadeni_karticki : Form
  15. {
  16. private String connString = "Data Source=WIN-3QUAK81995Q;Initial Catalog=lt-2;Persist Security Info=True;User ID=lt-2;Password=lt-2P@ssw0rd";
  17. public Pregled_na_izdadeni_karticki()
  18. {
  19. InitializeComponent();
  20.  
  21. }
  22.  
  23. private void btnnovakarticka_Click(object sender, EventArgs e)
  24. {
  25. panelnovakarticka.Visible = true;
  26. }
  27.  
  28. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  29. {
  30.  
  31. }
  32.  
  33. private void Pregled_na_izdadeni_karticki_Load(object sender, EventArgs e)
  34. {
  35. 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";
  36. 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
  37. var dataAdapter = new SqlDataAdapter(select, c);
  38.  
  39. var commandBuilder = new SqlCommandBuilder(dataAdapter);
  40. var ds = new DataSet();
  41. dataAdapter.Fill(ds);
  42. dataGridView1.ReadOnly = true;
  43. dataGridView1.DataSource = ds.Tables[0];
  44.  
  45. }
  46.  
  47. private void btnfilter_Click(object sender, EventArgs e)
  48. {
  49. if (txtembg.Text != "")
  50. {
  51. 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 + "'";
  52. 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
  53. var dataAdapter = new SqlDataAdapter(select, c);
  54.  
  55. var commandBuilder = new SqlCommandBuilder(dataAdapter);
  56. var ds = new DataSet();
  57. dataAdapter.Fill(ds);
  58. dataGridView1.ReadOnly = true;
  59. dataGridView1.DataSource = ds.Tables[0];
  60. }
  61. else
  62. {
  63. 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";
  64. 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
  65. var dataAdapter = new SqlDataAdapter(select, c);
  66.  
  67. var commandBuilder = new SqlCommandBuilder(dataAdapter);
  68. var ds = new DataSet();
  69. dataAdapter.Fill(ds);
  70. dataGridView1.ReadOnly = true;
  71. dataGridView1.DataSource = ds.Tables[0];
  72.  
  73. }
  74. }
  75.  
  76. private void label5_Click(object sender, EventArgs e)
  77. {
  78.  
  79. }
  80.  
  81. private void panelnovakarticka_Enter(object sender, EventArgs e)
  82. {
  83. // Random random = new Random();
  84.  
  85. // txtcvc.Text = Convert.ToString(random.Next(100, 999));
  86.  
  87. }
  88.  
  89. private void panelnovakarticka_Layout(object sender, LayoutEventArgs e)
  90. {
  91. Random random = new Random();
  92.  
  93. txtcvc.Text = Convert.ToString(random.Next(100, 999));
  94.  
  95. txtdatum.Text = DateTime.Now.Month.ToString("00") + "." + DateTime.Now.AddYears(3).Year.ToString();
  96.  
  97.  
  98.  
  99. }
  100.  
  101. private void ddltip_SelectedIndexChanged(object sender, EventArgs e)
  102. {
  103. Random random = new Random();
  104.  
  105. string str = ddltip.SelectedItem.ToString();
  106. char[] split = new char[] { ' ' };
  107. string firstWord = str.Split(split)[0];
  108.  
  109. if (firstWord == "Master")
  110. {
  111. string number1 = Convert.ToString(random.Next(10000, 99999));
  112. string number2 = Convert.ToString(random.Next(100000, 999999));
  113.  
  114. long sum = 0;
  115. long r;
  116. string sample = "5214"+number1 +number2;
  117. long num = Convert.ToInt64(sample);
  118.  
  119.  
  120.  
  121. while (num != 0)
  122. {
  123. r = num % 10;
  124.  
  125. num = num / 10;
  126.  
  127. sum = sum + r;
  128.  
  129. }
  130.  
  131. sum = sum % 10;
  132.  
  133.  
  134.  
  135. txtbroj.Text = "5214" + number1.ToString() + number2.ToString() + sum.ToString();
  136.  
  137. }
  138. else
  139. {
  140. string number1 = Convert.ToString(random.Next(10000, 99999));
  141. string number2 = Convert.ToString(random.Next(100000, 999999));
  142.  
  143. long sum = 0;
  144. long r;
  145. string sample = "4324"+number1 + number2;
  146. long num = Convert.ToInt64(sample);
  147.  
  148.  
  149.  
  150. while (num != 0)
  151. {
  152. r = num % 10;
  153.  
  154. num = num / 10;
  155.  
  156. sum = sum + r;
  157.  
  158. }
  159.  
  160. sum = sum % 10;
  161.  
  162. txtbroj.Text = "4324" + number1 + number2 + sum.ToString();
  163. }
  164.  
  165.  
  166. }
  167.  
  168. private void embg_TextChanged(object sender, EventArgs e)
  169. {
  170. if (embg.Text.Length == 13)
  171. {
  172. //MessageBox.Show("sa");
  173. using (SqlConnection connection = new SqlConnection(connString))
  174. {
  175. connection.Open();
  176. string query = "select ime from adresar where embg='" + embg.Text + "'";
  177. using (SqlCommand command = new SqlCommand(query, connection))
  178. {
  179. using (SqlDataReader reader = command.ExecuteReader())
  180. {
  181. while (reader.Read())
  182. {
  183. txtname.Text = reader.GetString(0);
  184. }
  185.  
  186. }
  187. }
  188. }
  189.  
  190.  
  191. using (SqlConnection connection = new SqlConnection(connString))
  192. {
  193. connection.Open();
  194. string query = "select prezime from adresar where embg='" + embg.Text + "'";
  195. using (SqlCommand command = new SqlCommand(query, connection))
  196. {
  197. using (SqlDataReader reader = command.ExecuteReader())
  198. {
  199. while (reader.Read())
  200. {
  201. txtsurname.Text = reader.GetString(0);
  202. }
  203.  
  204. }
  205. }
  206. }
  207. }
  208. }
  209.  
  210. private void embg_Leave(object sender, EventArgs e)
  211. {
  212.  
  213. }
  214.  
  215. private void btnvnesi_Click(object sender, EventArgs e)
  216. {
  217. string id;
  218. using (SqlConnection connection = new SqlConnection(connString))
  219. {
  220. connection.Open();
  221.  
  222. string query1 = "insert into cards_issued values('" + txtbroj.Text + "', '" + txtdatum.Text + "', '" + txtcvc.Text + "', '" + txtname.Text + "', '" + txtsurname.Text + "', '" + ddltip.SelectedIndex.ToString() + "', 1, '" + embg.Text+"')";
  223. SqlCommand command1 = new SqlCommand(query1, connection);
  224. command1.ExecuteNonQuery();
  225. }
  226. dataGridView1.Refresh();
  227. }
  228.  
  229. private void btnizberi_Click(object sender, EventArgs e)
  230. {
  231. string broj = dataGridView1.SelectedCells[0].Value.ToString();
  232. this.Hide();
  233. Pregled_na_transakcii pregled = new Pregled_na_transakcii();
  234. pregled.MyProperty = broj;
  235. pregled.Show();
  236.  
  237.  
  238. }
  239. }
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement