private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { //UPDATE updatedQuan = int.Parse(quantityTextBlock.Text); using (SqlConnection myConnection = new SqlConnection(Globals.SQL_DATA_CONNECTION)) { SqlCommand cmd = new SqlCommand("updateQuan", myConnection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new SqlParameter("@upcInput", ean)); cmd.Parameters.Add(new SqlParameter("@userID", Globals.uid)); cmd.Parameters.Add(new SqlParameter("@theQuan", updatedQuan)); myConnection.Open(); int rowAffected = cmd.ExecuteNonQuery(); if (rowAffected == 1) { myConnection.Close(); } else { myConnection.Close(); } } Globals.SHOPPING_LIST_ITEM_COUNT = GenerateDashboard.GetShoppingListCount(Globals.uid); Globals.UNIQUE_INVENTORY_ITEM_COUNT = GenerateDashboard.GetUniqueItemCount(Globals.uid); Globals.INVENTORY_ITEM_COUNT = GenerateDashboard.GetInventoryListCount(Globals.uid); }
private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { //DELETE if (Globals.MOVE_TO_SHOPPING_LIST_ON_DELETE) { using (SqlConnection myConnection = new SqlConnection(Globals.SQL_DATA_CONNECTION)) { SqlCommand cmd = new SqlCommand("sendToShoppingList", myConnection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new SqlParameter("@userID", Globals.uid)); cmd.Parameters.Add(new SqlParameter("@ean", itemCopy.ean)); cmd.Parameters.Add(new SqlParameter("@title", itemCopy.title)); cmd.Parameters.Add(new SqlParameter("@upc", itemCopy.upc)); cmd.Parameters.Add(new SqlParameter("@brand", itemCopy.brand)); cmd.Parameters.Add(new SqlParameter("@model", itemCopy.model)); cmd.Parameters.Add(new SqlParameter("@category", itemCopy.category)); cmd.Parameters.Add(new SqlParameter("@imageurl", itemCopy.imageurl)); myConnection.Open(); int rowAffected = cmd.ExecuteNonQuery(); if (rowAffected == 1) { myConnection.Close(); } else { myConnection.Close(); } } Globals.SHOPPING_LIST_ITEM_COUNT = GenerateDashboard.GetShoppingListCount(Globals.uid); Globals.UNIQUE_INVENTORY_ITEM_COUNT = GenerateDashboard.GetUniqueItemCount(Globals.uid); Globals.INVENTORY_ITEM_COUNT = GenerateDashboard.GetInventoryListCount(Globals.uid); } else { using (SqlConnection myConnection = new SqlConnection(Globals.SQL_DATA_CONNECTION)) { SqlCommand cmd = new SqlCommand("deleteItem", myConnection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new SqlParameter("@upcInput", ean)); cmd.Parameters.Add(new SqlParameter("@userID", Globals.uid)); myConnection.Open(); int rowAffected = cmd.ExecuteNonQuery(); if (rowAffected == 1) { myConnection.Close(); } else { myConnection.Close(); } } Globals.UNIQUE_INVENTORY_ITEM_COUNT = GenerateDashboard.GetUniqueItemCount(Globals.uid); Globals.SHOPPING_LIST_ITEM_COUNT = GenerateDashboard.GetShoppingListCount(Globals.uid); Globals.INVENTORY_ITEM_COUNT = GenerateDashboard.GetInventoryListCount(Globals.uid); } }
private void SignInButton_Click(object sender, RoutedEventArgs e) { if (emailTextField.Text == "" || passwordTextField.Password == "") { Msgbox.Show("Please enter email, and password"); } else { using (SqlConnection myConnection = new SqlConnection(Globals.SQL_DATA_CONNECTION)) { string oString = $"SELECT (SELECT UserID FROM Users WHERE email = '{emailTextField.Text}' AND password='******')"; SqlCommand oCmd = new SqlCommand(oString, myConnection); myConnection.Open(); using (SqlDataReader oReader = oCmd.ExecuteReader()) { while (oReader.Read()) { try { Globals.uid = (string)oReader.GetValue(0); //emailTextField.Text = Globals.uid; emailTextField.Text = ""; passwordTextField.Password = ""; Globals.UNIQUE_INVENTORY_ITEM_COUNT = GenerateDashboard.GetUniqueItemCount(Globals.uid); Globals.SHOPPING_LIST_ITEM_COUNT = GenerateDashboard.GetShoppingListCount(Globals.uid); Globals.INVENTORY_ITEM_COUNT = GenerateDashboard.GetInventoryListCount(Globals.uid); Frame.Navigate(typeof(WelcomePage)); } catch (InvalidCastException) { Msgbox.Show("Login credentials invalid. Please try again."); emailTextField.Text = string.Empty; passwordTextField.Password = string.Empty; //throw theException; } } } } } }