Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.81 KB | None | 0 0
  1. private void menustart_Load(object sender, EventArgs e)
  2. {
  3. // TODO: This line of code loads data into the 'cmsDataSet.menulist' table. You can move, or remove it, as needed.
  4.  
  5.  
  6.  
  7. String con = "datasource = localhost; port=3306;username=root;password=brianfdes93";
  8. MySqlConnection mycon = new MySqlConnection(con);
  9.  
  10. //wine
  11. string qw = "select wine from cms.menulist";
  12. MySqlDataAdapter da = new MySqlDataAdapter(qw, mycon);
  13. DataTable dt1 = new DataTable();
  14. da.Fill(dt1);
  15. foreach (DataRow row in dt1.Rows)
  16. {
  17. string wine = string.Format("{0}", row.ItemArray[0]);
  18. comboBox1.Items.Add(wine);
  19. }
  20.  
  21. //nvstarter
  22. string qsnv = "select st_nonveg from cms.menulist";
  23. MySqlDataAdapter da1 = new MySqlDataAdapter(qsnv, mycon);
  24. DataTable dt2 = new DataTable();
  25. da1.Fill(dt2);
  26. foreach (DataRow row in dt2.Rows)
  27. {
  28. string nvs = string.Format("{0}", row.ItemArray[0]);
  29. comboBox2.Items.Add(nvs);
  30. }
  31.  
  32. //vstarter
  33. string qsv = "select st_veg from cms.menulist";
  34. MySqlDataAdapter da3 = new MySqlDataAdapter(qsv, mycon);
  35. DataTable dt3 = new DataTable();
  36. da3.Fill(dt3);
  37. foreach (DataRow row in dt3.Rows)
  38. {
  39. string vs = string.Format("{0}", row.ItemArray[0]);
  40. comboBox3.Items.Add(vs);
  41. }
  42.  
  43. //rice n v
  44. string qrnv = "select rice_nonveg from cms.menulist";
  45. MySqlDataAdapter da4 = new MySqlDataAdapter(qrnv, mycon);
  46. DataTable dtrnv = new DataTable();
  47. da4.Fill(dtrnv);
  48. foreach (DataRow row in dtrnv.Rows)
  49. {
  50. string rnv = string.Format("{0}", row.ItemArray[0]);
  51. comboBox4.Items.Add(rnv);
  52. }
  53.  
  54. // rice v
  55. string qrv = "select rice_veg from cms.menulist";
  56. MySqlDataAdapter da4i = new MySqlDataAdapter(qrv, mycon);
  57. DataTable dtrv = new DataTable();
  58. da4i.Fill(dtrv);
  59. foreach (DataRow row in dtrv.Rows)
  60. {
  61. string rv = string.Format("{0}", row.ItemArray[0]);
  62. comboBox4i.Items.Add(rv);
  63. }
  64.  
  65.  
  66.  
  67. //nvgravy
  68. string qgnv = "select g_nonveg from cms.menulist";
  69. MySqlDataAdapter da5 = new MySqlDataAdapter(qgnv, mycon);
  70. DataTable dtgnv = new DataTable();
  71. da5.Fill(dtgnv);
  72. foreach (DataRow row in dtgnv.Rows)
  73. {
  74. string gnv = string.Format("{0}", row.ItemArray[0]);
  75. comboBox5.Items.Add(gnv);
  76. }
  77.  
  78. //vgravy
  79. string qgv = "select g_veg from cms.menulist";
  80. MySqlDataAdapter da6 = new MySqlDataAdapter(qgv, mycon);
  81. DataTable dtgv = new DataTable();
  82. da6.Fill(dtgv);
  83. foreach (DataRow row in dtgv.Rows)
  84. {
  85. string gv = string.Format("{0}", row.ItemArray[0]);
  86. comboBox6.Items.Add(gv);
  87. }
  88.  
  89. //sanv
  90. string qsanv = "select s_nonveg from cms.menulist";
  91. MySqlDataAdapter da7 = new MySqlDataAdapter(qsanv, mycon);
  92. DataTable dtsanv = new DataTable();
  93. da7.Fill(dtsanv);
  94. foreach (DataRow row in dtsanv.Rows)
  95. {
  96. string sanv = string.Format("{0}", row.ItemArray[0]);
  97. comboBox7.Items.Add(sanv);
  98. }
  99.  
  100. //sav
  101. string qsav = "select s_veg from cms.menulist";
  102. MySqlDataAdapter da8 = new MySqlDataAdapter(qsav, mycon);
  103. DataTable dtsav = new DataTable();
  104. da8.Fill(dtsav);
  105. foreach (DataRow row in dtsav.Rows)
  106. {
  107. string sav = string.Format("{0}", row.ItemArray[0]);
  108. comboBox8.Items.Add(sav);
  109. }
  110. //dessert
  111. string qd = "select dessert from cms.menulist";
  112. MySqlDataAdapter da9 = new MySqlDataAdapter(qd, mycon);
  113. DataTable dtd = new DataTable();
  114. da9.Fill(dtd);
  115. foreach (DataRow row in dtd.Rows)
  116. {
  117. string sav = string.Format("{0}", row.ItemArray[0]);
  118. comboBox9.Items.Add(sav);
  119. }
  120.  
  121.  
  122.  
  123. mycon.Close();
  124.  
  125. // to populate iod
  126.  
  127. int nxtorder;
  128.  
  129. String coni = "datasource = localhost; port=3306;username=root;password=brianfdes93";
  130. MySqlConnection myconi = new MySqlConnection(coni);
  131. string query = "select MAX(o_id) from cms.order";
  132. MySqlCommand o = new MySqlCommand(query, myconi);
  133. myconi.Open();
  134.  
  135. MySqlDataReader reader = o.ExecuteReader();
  136. while (reader.Read())
  137. {
  138. if (reader.IsDBNull(reader.GetOrdinal("max(o_id)")))
  139. {
  140. nxtorder = 1;
  141. tid.Text = Convert.ToString(nxtorder);
  142. }
  143. else
  144. {
  145. nxtorder = Convert.ToInt32(reader["max(o_id)"]);
  146. tid.Text = Convert.ToString(nxtorder);
  147. }
  148.  
  149.  
  150.  
  151. }
  152.  
  153.  
  154.  
  155.  
  156.  
  157. //to fill guest txtbox
  158.  
  159.  
  160.  
  161.  
  162. }
  163.  
  164. private void button1_Click(object sender, EventArgs e)
  165. {
  166. starting s = new starting();
  167. s.Show();
  168. this.Close();
  169. }
  170.  
  171.  
  172.  
  173.  
  174.  
  175. private void button2_Click(object sender, EventArgs e)
  176. {
  177.  
  178. tabControl1.SelectedTab = tabPage3;
  179. t1.Text = t11.Text;
  180. t2.Text = t12.Text;
  181. t3.Text = t13.Text;
  182. t4.Text = t14.Text;
  183. t4i.Text = t14i.Text;
  184. t5.Text = t15.Text;
  185. t6.Text = t16.Text;
  186. t7.Text = t17.Text;
  187. t8.Text = t18.Text;
  188. t9.Text = t19.Text;
  189. textBox1.Text = label49.Text;
  190.  
  191. }
  192.  
  193. private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
  194. {
  195.  
  196. string c1 = comboBox1.SelectedItem.ToString();
  197. t1.Text = t1.Text +c1+",";
  198. }
  199.  
  200. private void comboBox2_SelectionChangeCommitted_1(object sender, EventArgs e)
  201. {
  202. string c2 = comboBox2.SelectedItem.ToString();
  203. t2.Text = t2.Text + c2 + ",";
  204. }
  205.  
  206. private void comboBox3_SelectionChangeCommitted_1(object sender, EventArgs e)
  207. {
  208. string c3 = comboBox3.SelectedItem.ToString();
  209. t3.Text = t3.Text + c3 + ",";
  210. }
  211.  
  212. private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
  213. {
  214. string c4 = comboBox4.SelectedItem.ToString();
  215. t4.Text = t4.Text + c4 + ",";
  216. }
  217. private void comboBox4i_SelectedIndexChanged(object sender, EventArgs e)
  218. {
  219. string c4i = comboBox4.SelectedItem.ToString();
  220. t4i.Text = t4i.Text + c4i + ",";
  221. }
  222. private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
  223. {
  224. string c5 = comboBox5.SelectedItem.ToString();
  225. t5.Text = t5.Text + c5 + ",";
  226. }
  227.  
  228. private void comboBox6_SelectedIndexChanged(object sender, EventArgs e)
  229. {
  230. string c6 = comboBox6.SelectedItem.ToString();
  231. t6.Text = t6.Text + c6 + ",";
  232. }
  233.  
  234. private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
  235. {
  236. string c7 = comboBox7.SelectedItem.ToString();
  237. t7.Text = t7.Text + c7 + ",";
  238. }
  239.  
  240. private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
  241. {
  242. string c8 = comboBox8.SelectedItem.ToString();
  243. t8.Text = t8.Text + c8 + ",";
  244. }
  245.  
  246. private void comboBox9_SelectionChangeCommitted_1(object sender, EventArgs e)
  247. {
  248. string c9 = comboBox9.SelectedItem.ToString();
  249. t9.Text = t9.Text + c9 + ",";
  250. }
  251.  
  252. private void button1_Click_1(object sender, EventArgs e)
  253. {
  254. tabControl1.SelectedTab = tabPage3;
  255. t1.Text = t21.Text;
  256. t2.Text = t22.Text;
  257. t3.Text = t23.Text;
  258. t4.Text = t24.Text;
  259. t4i.Text = t24i.Text;
  260. t5.Text = t25.Text;
  261. t6.Text = t26.Text;
  262. t7.Text = t27.Text;
  263. t8.Text = t28.Text;
  264. t9.Text = t29.Text;
  265. textBox1.Text = label47.Text;
  266. }
  267.  
  268.  
  269.  
  270. private void button3_Click(object sender, EventArgs e)
  271. {
  272.  
  273. if (t1.Text != "" && t2.Text != "" && t3.Text != "" && t4.Text != "" && t5.Text != "" && t6.Text != "" && t7.Text != "" && t8.Text != "" && t9.Text != "")
  274. {
  275. try
  276. {
  277. String con = "datasource = localhost; port=3306;username=root;password=brianfdes93";
  278. MySqlConnection mycon = new MySqlConnection(con);
  279. string query = "insert into cms.menu(o_id,wine,st_nonveg,st_veg,rice_nonveg,rice_veg,g_nonveg,g_veg,s_veg,s_nonveg,dessert) values('" + this.tid.Text + "','" + this.t1.Text + "','" + this.t2.Text + "','" + this.t3.Text + "','" + this.t4.Text + "','" + this.t4i.Text + "','" + this.t5.Text + "','" + this.t6.Text + "','" + this.t7.Text + "','" + this.t8.Text + "','" + this.t9.Text + "')";
  280. MySqlCommand orderinsert = new MySqlCommand(query, mycon);
  281. MySqlDataReader reader;
  282. mycon.Open();
  283. reader = orderinsert.ExecuteReader();
  284. while (reader.Read())
  285. {
  286. }
  287.  
  288. }
  289. catch (Exception ex)
  290. {
  291. MessageBox.Show(ex.Message);
  292. }
  293.  
  294.  
  295. try
  296. {
  297. String con1 = "datasource = localhost; port=3306;username=root;password=brianfdes93";
  298. MySqlConnection mycon1 = new MySqlConnection(con1);
  299. string query1 = "insert into cms.order(price_per_plate,total_amount) values('" + this.textBox1.Text + "','" + this.textBox2.Text+ "')";
  300. MySqlCommand orderinsert1 = new MySqlCommand(query1, mycon1);
  301. MySqlDataReader reader;
  302. mycon1.Open();
  303. reader = orderinsert1.ExecuteReader();
  304. while (reader.Read())
  305. {
  306. }
  307. MessageBox.Show("MENU PREFERENCE SAVED");
  308. }
  309. catch (Exception ex)
  310. {
  311. MessageBox.Show(ex.Message);
  312. }
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320. }
  321. else
  322. {
  323. MessageBox.Show("please complete the form before submitting");
  324. }
  325.  
  326. payment p = new payment();
  327. this.Hide();
  328. p.Show();
  329. }
  330.  
  331. private void tabPage3_Enter(object sender, EventArgs e)
  332. {
  333. String con2 = "datasource = localhost; port=3306;username=root;password=brianfdes93";
  334. MySqlConnection mycon2 = new MySqlConnection(con2);
  335. string query2 = "select guest from cms.order where o_id='" + tid.Text + "'";
  336. MySqlCommand orderinsert = new MySqlCommand(query2, mycon2);
  337. string a = "1";
  338. mycon2.Open();
  339. // a = orderinsert.ExecuteScalar().ToString();
  340. MySqlDataReader dr = orderinsert.ExecuteReader();
  341. while (dr.Read())
  342. {
  343. a = dr.GetString(0);
  344.  
  345. }
  346. string s = textBox1.Text;
  347. int a1 = Convert.ToInt16(a);
  348. int a2 = Convert.ToInt32(string.IsNullOrEmpty(textBox1.Text));
  349. textBox2.Text = Convert.ToString(a1 * a2);
  350. mycon2.Close();
  351. }
  352. }
  353.  
  354. int a2 = Convert.ToInt32(textBox1.Text);
  355.  
  356. int a2 = Convert.ToInt32(string.IsNullOrEmpty(textBox1.Text));
  357.  
  358. try
  359. {
  360. int a2 = Int.Parse(textBox1.Text);
  361. }
  362. catch (Exception ex)
  363. {
  364. Console.WriteLine("Failed to parse to int! " + ex.Message);
  365. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement