Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.91 KB | None | 0 0
  1. If IsNothing(cmbProd.SelectedItem) Then
  2. MessageBox.Show("Select Product Name of Raw Material", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  3. cmbProd.BackColor = Color.PapayaWhip
  4. cmbProd.Focus()
  5. ElseIf IsNothing(txtaddProductName.SelectedItem) Then
  6. MessageBox.Show("Select Raw Material", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  7. txtaddProductName.BackColor = Color.PapayaWhip
  8. txtaddProductName.Focus()
  9. ElseIf (txtConSolo.Text <> "") And (IsNothing(cmbUnitSolo.SelectedItem)) Then
  10. MessageBox.Show("Select Unit", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  11. cmbUnitSolo.BackColor = Color.PapayaWhip
  12. cmbUnitSolo.Focus()
  13. txtConSolo.BackColor = Color.White
  14. ElseIf (txtConSolo.Text = "") And (cmbUnitSolo.Text <> "") Then
  15. MessageBox.Show("Enter Consume per Product", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  16. txtConSolo.BackColor = Color.PapayaWhip
  17. txtConSolo.Focus()
  18. cmbUnitSolo.BackColor = Color.White
  19. ElseIf (txtConReg.Text <> "") And (IsNothing(cmbUnitReg.SelectedItem)) Then
  20. MessageBox.Show("Select Unit", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  21. cmbUnitReg.BackColor = Color.PapayaWhip
  22. cmbUnitReg.Focus()
  23. txtConReg.BackColor = Color.White
  24. ElseIf (txtConReg.Text = "") And (cmbUnitReg.Text <> "") Then
  25. MessageBox.Show("Enter Consume per Product", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  26. txtConReg.BackColor = Color.PapayaWhip
  27. txtConReg.Focus()
  28. cmbUnitReg.BackColor = Color.White
  29. ElseIf (txtConFam.Text <> "") And (IsNothing(cmbUnitFam.SelectedItem)) Then
  30. MessageBox.Show("Select Unit", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  31. cmbUnitFam.BackColor = Color.PapayaWhip
  32. cmbUnitFam.Focus()
  33. txtConFam.BackColor = Color.White
  34. ElseIf (txtConFam.Text = "") And (cmbUnitFam.Text <> "") Then
  35. MessageBox.Show("Enter Consume per Product", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  36. txtConFam.BackColor = Color.PapayaWhip
  37. txtConFam.Focus()
  38. cmbUnitFam.BackColor = Color.White
  39. ElseIf (txtConSolo.Text <> "") And (cmbUnitSolo.Text <> "") And ((txtConReg.Text = "") And (IsNothing(cmbUnitReg.SelectedItem))) And ((txtConFam.Text = "") And IsNothing(cmbUnitFam.SelectedItem)) Then
  40. MessageBox.Show("solo may laman", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  41. txtDisplaySolo.Text = "Solo"
  42. rawtxt = CStr(txtaddProductName.Text)
  43. prodtxt = CStr(cmbProd.Text)
  44. txtsolsize = Val(txtConSolo.Text)
  45. sizesoltxt = CStr(cmbUnitSolo.Text)
  46. Try
  47. objconn.Open()
  48. objcmd.Connection = objconn
  49. objcmd.CommandType = CommandType.Text
  50. objcmd.CommandText = "select * from material_every_product where Product_ID IN (Select Product_ID from product_table where Product_Name ='" & prodtxt & "') " _
  51. & "AND Raw_ID IN (Select Raw_ID from raw_material_table where Raw_Name ='" & rawtxt & "') " _
  52. & "AND Unit_ID IN (Select Unit_ID from unit_table where unit_table.Unit_Name IS NOT NULL) " _
  53. & "AND Size_ID IN (Select Size_ID from product_size where Size_Name ='" & CStr(txtDisplayReg.Text) & "') "
  54. objdr = objcmd.ExecuteReader
  55. If objdr.HasRows Then
  56. MessageBox.Show("The Product Raw Material Already Exists at Solo Size but You Can add Raw Materials at Regular or Family Size if it is considered as a Raw Materials in our Product .You can select also another Raw Materials or a Product.", "Red Cheese Pizza Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
  57. cmbUnitSolo.BackColor = Color.PapayaWhip
  58. cmbUnitSolo.Focus()
  59. txtConSolo.BackColor = Color.PapayaWhip
  60. txtConSolo.Focus()
  61. Label3.ForeColor = Color.Red
  62. Else
  63. Dim hungaonka As MsgBoxResult
  64. hungaonka = MsgBox("Your Adding an " & rawtxt & " to " & prodtxt & " Consume every materials " & Environment.NewLine & "" & txtsolsize & " " & sizesoltxt & " at " & txtDisplaySolo.Text & " size, " & Environment.NewLine & "" _
  65. & ", Do You Want To Continue ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirmation")
  66. If hungaonka = MsgBoxResult.Yes Then
  67. objconn = New MySqlConnection
  68. objconn.ConnectionString = "server=localhost; username=root; password=; database=red_cheese_pizza_database"
  69. Try
  70. objconn.Open()
  71. With objcmd
  72. .Connection = objconn
  73. .CommandText = "Insert into material_every_product (Product_ID,Minus_Material_Every_Product,Raw_ID,unit_ID,Size_ID) values " _
  74. & " ((SELECT Product_ID FROM product_table WHERE Product_Name ='" & CStr(prodtxt) & "')," & CInt(txtsolsize) & ", " _
  75. & " (Select Raw_ID from raw_material_table where Raw_Name ='" & CStr(rawtxt) & "'),(Select Unit_ID from unit_table where " _
  76. & " Unit_Name = '" & CStr(sizesoltxt) & "'),(Select Size_ID from product_size where Size_Name = '" & CStr(txtDisplaySolo.Text) & "')); "
  77. .ExecuteNonQuery()
  78. End With
  79. txtDisplaySolo.Text = ""
  80. objconn.Close()
  81. 'Main.FillMainDbase()
  82. 'Main.fillProdukto()
  83. txtDisplaySolo.Text = ""
  84. Clearform3()
  85. MsgBox("Data Added!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "SUCCESS")
  86. Catch ex As Exception
  87. MsgBox(ex.Message, MsgBoxStyle.Critical, "Red Cheese Pizza Error Program, Contact Programmer about this. Thank You.")
  88. End Try
  89. ElseIf hungaonka = MsgBoxResult.No Then
  90. ' objconn.Close()
  91. Exit Sub
  92. End If
  93. End If
  94. objconn.Close()
  95. Catch ex As Exception
  96. MessageBox.Show(ex.Message)
  97. End Try
  98. ElseIf (txtConReg.Text <> "") And (cmbUnitReg.Text <> "") And ((txtConSolo.Text = "") And IsNothing(cmbUnitSolo.SelectedItem)) And ((txtConFam.Text = "" And IsNothing(cmbUnitFam.SelectedItem))) Then
  99. MessageBox.Show("reg may laman", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  100. txtDisplayReg.Text = "Regular"
  101. rawtxt = CStr(txtaddProductName.Text)
  102. prodtxt = CStr(cmbProd.Text)
  103. txtregsize = Val(txtConReg.Text)
  104. sizeregtxt = CStr(cmbUnitReg.Text)
  105. Try
  106. objconn.Open()
  107. objcmd.Connection = objconn
  108. objcmd.CommandType = CommandType.Text
  109. objcmd.CommandText = "select * from material_every_product where Product_ID IN (Select Product_ID from product_table where Product_Name ='" & prodtxt & "') " _
  110. & "AND Raw_ID IN (Select Raw_ID from raw_material_table where Raw_Name ='" & rawtxt & "') " _
  111. & "AND Unit_ID IN (Select Unit_ID from unit_table where unit_table.Unit_Name IS NOT NULL) " _
  112. & "AND Size_ID IN (Select Size_ID from product_size where Size_Name ='" & CStr(txtDisplayReg.Text) & "') "
  113. objdr = objcmd.ExecuteReader
  114. If objdr.HasRows Then
  115. MessageBox.Show("The Product Raw Material Already Exists at Regular Size but You Can add Raw Materials at Solo or Family Size if it is considered as a Raw Materials in our Product .You can select also another Raw Materials or a Product.", "Red Cheese Pizza Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
  116. cmbUnitReg.BackColor = Color.PapayaWhip
  117. cmbUnitReg.Focus()
  118. txtConReg.BackColor = Color.PapayaWhip
  119. txtConReg.Focus()
  120. Label2.ForeColor = Color.Red
  121. Else
  122. Dim hungaonka As MsgBoxResult
  123. hungaonka = MsgBox("Your Adding an " & rawtxt & " to " & prodtxt & " Consume every materials " & Environment.NewLine & "" & txtregsize & " " & sizeregtxt & " at " & txtDisplayReg.Text & " size, " & Environment.NewLine & "" _
  124. & ", Do You Want To Continue ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirmation")
  125. If hungaonka = MsgBoxResult.Yes Then
  126. objconn = New MySqlConnection
  127. objconn.ConnectionString = "server=localhost; username=root; password=; database=red_cheese_pizza_database"
  128. Try
  129. objconn.Open()
  130. With objcmd
  131. .Connection = objconn
  132. .CommandText = "Insert into material_every_product (Product_ID,Minus_Material_Every_Product,Raw_ID,unit_ID,Size_ID) values " _
  133. & " ((SELECT Product_ID FROM product_table WHERE Product_Name ='" & CStr(prodtxt) & "')," & CInt(txtregsize) & ", " _
  134. & " (Select Raw_ID from raw_material_table where Raw_Name ='" & CStr(rawtxt) & "'),(Select Unit_ID from unit_table where " _
  135. & " Unit_Name = '" & CStr(sizeregtxt) & "'),(Select Size_ID from product_size where Size_Name = '" & CStr(txtDisplayReg.Text) & "')); "
  136. .ExecuteNonQuery()
  137. End With
  138. txtDisplayReg.Text = ""
  139. objconn.Close()
  140. 'Main.FillMainDbase()
  141. 'Main.fillProdukto()
  142. txtDisplayReg.Text = ""
  143. Clearform3()
  144. MsgBox("Data Added!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "SUCCESS")
  145. Catch ex As Exception
  146. MsgBox(ex.Message, MsgBoxStyle.Critical, "Red Cheese Pizza Error Program, Contact Programmer about this. Thank You.")
  147. End Try
  148. ElseIf hungaonka = MsgBoxResult.No Then
  149. ' objconn.Close()
  150. Exit Sub
  151. End If
  152. End If
  153. objconn.Close()
  154. Catch ex As Exception
  155. MessageBox.Show(ex.Message)
  156. End Try
  157. ElseIf (txtConFam.Text <> "" And cmbUnitFam.Text <> "") And (txtConSolo.Text = "" And IsNothing(cmbUnitSolo.SelectedItem)) And (txtConReg.Text = "" And IsNothing(cmbUnitReg.SelectedItem)) Then
  158. MessageBox.Show("fam may laman", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  159. txtDisplayFam.Text = "Family"
  160.  
  161. rawtxt = CStr(txtaddProductName.Text)
  162. prodtxt = CStr(cmbProd.Text)
  163. txtfamsize = Val(txtConFam.Text)
  164. sizefamtxt = CStr(cmbUnitFam.Text)
  165. Try
  166. objconn.Open()
  167. objcmd.Connection = objconn
  168. objcmd.CommandType = CommandType.Text
  169. objcmd.CommandText = "select * from material_every_product where Product_ID IN (Select Product_ID from product_table where Product_Name ='" & prodtxt & "') " _
  170. & "AND Raw_ID IN (Select Raw_ID from raw_material_table where Raw_Name ='" & rawtxt & "') " _
  171. & "AND Unit_ID IN (Select Unit_ID from unit_table where unit_table.Unit_Name IS NOT NULL) " _
  172. & "AND Size_ID IN (Select Size_ID from product_size where Size_Name ='" & CStr(txtDisplayFam.Text) & "') "
  173. objdr = objcmd.ExecuteReader
  174. If objdr.HasRows Then
  175. MessageBox.Show("The Product Raw Material Already Exists at Family Size but You Can add Raw Materials at Solo or Regular Size if it is considered as a Raw Materials in our Product .You can select also another Raw Materials or a Product.", "Red Cheese Pizza Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
  176. cmbUnitFam.BackColor = Color.PapayaWhip
  177. cmbUnitFam.Focus()
  178. txtConFam.BackColor = Color.PapayaWhip
  179. txtConFam.Focus()
  180. Label4.ForeColor = Color.Red
  181. Else
  182. Dim hungaonka As MsgBoxResult
  183. hungaonka = MsgBox("Your Adding an " & rawtxt & " to " & prodtxt & " Consume every materials " & Environment.NewLine & "" & txtfamsize & " " & sizefamtxt & " at " & txtDisplayFam.Text & " size, " & Environment.NewLine & "" _
  184. & ", Do You Want To Continue ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirmation")
  185. If hungaonka = MsgBoxResult.Yes Then
  186. objconn = New MySqlConnection
  187. objconn.ConnectionString = "server=localhost; username=root; password=; database=red_cheese_pizza_database"
  188. Try
  189. objconn.Open()
  190. With objcmd
  191. .Connection = objconn
  192. .CommandText = "Insert into material_every_product (Product_ID,Minus_Material_Every_Product,Raw_ID,unit_ID,Size_ID) values " _
  193. & " ((SELECT Product_ID FROM product_table WHERE Product_Name ='" & CStr(prodtxt) & "')," & CInt(txtfamsize) & ", " _
  194. & " (Select Raw_ID from raw_material_table where Raw_Name ='" & CStr(rawtxt) & "'),(Select Unit_ID from unit_table where " _
  195. & " Unit_Name = '" & CStr(sizefamtxt) & "'),(Select Size_ID from product_size where Size_Name = '" & CStr(txtDisplayFam.Text) & "')); "
  196. .ExecuteNonQuery()
  197. End With
  198. txtDisplayFam.Text = ""
  199. objconn.Close()
  200. 'Main.FillMainDbase()
  201. 'Main.fillProdukto()
  202. txtDisplayFam.Text = ""
  203. Clearform3()
  204. MsgBox("Data Added!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "SUCCESS")
  205. Catch ex As Exception
  206. MsgBox(ex.Message, MsgBoxStyle.Critical, "Red Cheese Pizza Error Program, Contact Programmer about this. Thank You.")
  207. End Try
  208. ElseIf hungaonka = MsgBoxResult.No Then
  209. ' objconn.Close()
  210. Exit Sub
  211. End If
  212. End If
  213. objconn.Close()
  214. Catch ex As Exception
  215. MessageBox.Show(ex.Message)
  216. End Try
  217. ElseIf txtConSolo.Text <> "" And cmbUnitSolo.Text <> "" And txtConReg.Text <> "" And cmbUnitReg.Text <> "" And txtConFam.Text = "" And IsNothing(cmbUnitFam.SelectedItem) Then
  218. MessageBox.Show("solo and reg may laman", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  219. txtDisplaySolo.Text = "Solo"
  220. txtDisplayReg.Text = "Regular"
  221. ElseIf txtConSolo.Text <> "" And cmbUnitSolo.Text <> "" And txtConReg.Text <> "" And cmbUnitReg.Text <> "" And txtConFam.Text <> "" And cmbUnitFam.Text <> "" Then
  222. MessageBox.Show("solo and reg and fam may laman", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  223. txtDisplaySolo.Text = "Solo"
  224. txtDisplayReg.Text = "Regular"
  225. txtDisplayFam.Text = "Family"
  226.  
  227. rawtxt = CStr(txtaddProductName.Text)
  228. prodtxt = CStr(cmbProd.Text)
  229. txtsolsize = Val(txtConSolo.Text)
  230. sizesoltxt = CStr(cmbUnitSolo.Text)
  231. txtregsize = Val(txtConReg.Text)
  232. sizeregtxt = CStr(cmbUnitReg.Text)
  233. txtfamsize = Val(txtConFam.Text)
  234. sizefamtxt = CStr(cmbUnitFam.Text)
  235. Try
  236. objconn.Open()
  237. objcmd.Connection = objconn
  238. objcmd.CommandType = CommandType.Text
  239. objcmd.CommandText = "select * from material_every_product where Product_ID IN (Select Product_ID from product_table where Product_Name ='" & prodtxt & "') " _
  240. & "AND Raw_ID IN (Select Raw_ID from raw_material_table where Raw_Name ='" & rawtxt & "') " _
  241. & "AND Unit_ID IN (Select Unit_ID from unit_table where unit_table.Unit_Name IS NOT NULL) " _
  242. & "AND Size_ID IN (Select Size_ID from product_size where Size_Name ='" & CStr(txtDisplaySolo.Text) & "' OR Size_Name ='" & CStr(txtDisplayReg.Text) & "' OR Size_Name ='" & CStr(txtDisplayFam.Text) & "') "
  243. objdr = objcmd.ExecuteReader
  244. If objdr.HasRows Then
  245. MessageBox.Show("The Product Raw Material Already Exists at Regular or,Solo,or FamilySize but You Can add Raw Materials at Solo or Family Size if it is considered as a Raw Materials in our Product .You can select also another Raw Materials or a Product.", "Red Cheese Pizza Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
  246. cmbUnitSolo.BackColor = Color.PapayaWhip
  247. cmbUnitSolo.Focus()
  248. txtConSolo.BackColor = Color.PapayaWhip
  249. txtConSolo.Focus()
  250. Label3.ForeColor = Color.Red
  251.  
  252. cmbUnitReg.BackColor = Color.PapayaWhip
  253. cmbUnitReg.Focus()
  254. txtConReg.BackColor = Color.PapayaWhip
  255. txtConReg.Focus()
  256. Label2.ForeColor = Color.Red
  257.  
  258. cmbUnitFam.BackColor = Color.PapayaWhip
  259. cmbUnitFam.Focus()
  260. txtConFam.BackColor = Color.PapayaWhip
  261. txtConFam.Focus()
  262. Label4.ForeColor = Color.Red
  263. Else
  264. Dim hungaonka As MsgBoxResult
  265. hungaonka = MsgBox("Your Adding an " & rawtxt & " to " & prodtxt & " Consume every materials " & Environment.NewLine & "" & txtsolsize & " " & sizesoltxt & " at " & txtDisplaySolo.Text & " size, " & Environment.NewLine & "" _
  266. & " " & txtregsize & " " & sizeregtxt & " at " & txtDisplayReg.Text & " size, " & Environment.NewLine & "" _
  267. & " " & txtfamsize & " " & sizefamtxt & " at " & txtDisplayFam.Text & " size, " & Environment.NewLine & "" _
  268. & ", Do You Want To Continue ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirmation")
  269. If hungaonka = MsgBoxResult.Yes Then
  270. objconn = New MySqlConnection
  271. objconn.ConnectionString = "server=localhost; username=root; password=; database=red_cheese_pizza_database"
  272. Try
  273. objconn.Open()
  274. With objcmd
  275. .Connection = objconn
  276. .CommandText = "Insert into material_every_product (Product_ID,Minus_Material_Every_Product,Raw_ID,unit_ID,Size_ID) values((SELECT Product_ID FROM product_table WHERE Product_Name ='" & CStr(prodtxt) & "')," & CInt(txtsolsize) & ",(Select Raw_ID from raw_material_table where Raw_Name ='" & CStr(rawtxt) & "'),(Select Unit_ID from unit_table where Unit_Name = '" & CStr(sizesoltxt) & "'),(Select Size_ID from product_size where Size_Name = '" & CStr(txtDisplaySolo.Text) & "')); " _
  277. & "Insert into material_every_product (Product_ID,Minus_Material_Every_Product,Raw_ID,unit_ID,Size_ID) values((SELECT Product_ID FROM product_table WHERE Product_Name ='" & CStr(prodtxt) & "')," & CInt(txtregsize) & ",(Select Raw_ID from raw_material_table where Raw_Name ='" & CStr(rawtxt) & "'),(Select Unit_ID from unit_table where Unit_Name = '" & CStr(sizeregtxt) & "'),(Select Size_ID from product_size where Size_Name = '" & CStr(txtDisplayReg.Text) & "')); " _
  278. & "Insert into material_every_product (Product_ID,Minus_Material_Every_Product,Raw_ID,unit_ID,Size_ID) values((SELECT Product_ID FROM product_table WHERE Product_Name ='" & CStr(prodtxt) & "')," & CInt(txtfamsize) & ",(Select Raw_ID from raw_material_table where Raw_Name ='" & CStr(rawtxt) & "'),(Select Unit_ID from unit_table where Unit_Name = '" & CStr(sizefamtxt) & "'),(Select Size_ID from product_size where Size_Name = '" & CStr(txtDisplayFam.Text) & "')); "
  279. .ExecuteNonQuery()
  280. End With
  281. txtDisplaySolo.Text = ""
  282. txtDisplayReg.Text = ""
  283. txtDisplayFam.Text = ""
  284. objconn.Close()
  285. 'Main.FillMainDbase()
  286. 'Main.fillProdukto()
  287. txtDisplaySolo.Text = ""
  288. txtDisplayReg.Text = ""
  289. txtDisplayFam.Text = ""
  290. Clearform3()
  291. MsgBox("Data Added!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "SUCCESS")
  292. Catch ex As Exception
  293. MsgBox(ex.Message, MsgBoxStyle.Critical, "Red Cheese Pizza Error Program, Contact Programmer about this. Thank You.")
  294. End Try
  295. ElseIf hungaonka = MsgBoxResult.No Then
  296. ' objconn.Close()
  297. Exit Sub
  298. End If
  299. End If
  300. objconn.Close()
  301. Catch ex As Exception
  302. MessageBox.Show(ex.Message)
  303. End Try
  304. ElseIf txtConSolo.Text = "" And IsNothing(cmbUnitSolo.SelectedItem) And txtConReg.Text = "" And IsNothing(cmbUnitReg.SelectedItem) And txtConFam.Text = "" And IsNothing(cmbUnitFam.SelectedItem) Then
  305. MessageBox.Show("Please Input at least 1 Item", "Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
  306. cmbUnitSolo.BackColor = Color.PapayaWhip
  307. txtConSolo.BackColor = Color.PapayaWhip
  308. cmbUnitReg.BackColor = Color.PapayaWhip
  309. txtConReg.BackColor = Color.PapayaWhip
  310. cmbUnitFam.BackColor = Color.PapayaWhip
  311. txtConFam.BackColor = Color.PapayaWhip
  312. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement