// private async void Button_Search_Click(object sender, RoutedEventArgs e) // { // string query; // DataSet ds; // DataRow drow; // database_connection dc = new database_connection(); // try // { // query = $@"select Id, //ItemDescription //,Quantity //,Unit //,CONVERT(VARCHAR(12), DateAcquired, 107) AS [Mon DD, YYYY] //,Price //,TotalCost //,Remarks //from ItemDetailss //where Id like '%{TextBox_Search.Text}%' or ItemDescription like '%{TextBox_Search.Text}%' or Unit like '%{TextBox_Search.Text}%' or DateAcquired like '%{TextBox_Search.Text}%'"; // Loading_User.Visibility = Visibility.Visible; // ds = await dc.Connection1Async(query); // Loading_User.Visibility = Visibility.Collapsed; // int count; // count = ds.Tables[0].Rows.Count; // if (count == 0) // { // Loading_User.Visibility = Visibility.Visible; // Icon.Kind = MahApps.Metro.IconPacks.PackIconMaterialKind.AlertCircleOutline; // TextBlock_Message.Text = "Search does not exists".ToUpper(); // TextBox_TransactionId.Clear(); // TextBox_ItemDescription.Clear(); // TextBox_Quantity.Clear(); // TextBox_Unit.Clear(); // TextBox_Price.Clear(); // TextBox_TotalCost.Clear(); // refresh(); // } // else // { // drow = ds.Tables[0].Rows[0]; // TextBox_TransactionId.Text = drow.ItemArray.GetValue(0).ToString(); // TextBox_ItemDescription.Text = drow.ItemArray.GetValue(1).ToString(); // TextBox_Quantity.Text = drow.ItemArray.GetValue(2).ToString(); // TextBox_Unit.Text = drow.ItemArray.GetValue(3).ToString(); // date = drow.ItemArray.GetValue(4).ToString(); // TextBox_Price.Text = drow.ItemArray.GetValue(5).ToString(); // TextBox_TotalCost.Text = drow.ItemArray.GetValue(6).ToString(); // } // int ctr, total; // total = ds.Tables[0].Rows.Count; // itemdetailss.Clear(); // for (ctr = 0; ctr < total; ctr++) // { // drow = ds.Tables[0].Rows[ctr]; // itemdetailss.Add(new ItemDetailss // { // TransactionId = drow.ItemArray.GetValue(0).ToString() // , // ItemDescription = drow.ItemArray.GetValue(1).ToString() // , // ItemQuantity = int.Parse(drow.ItemArray.GetValue(2).ToString()) // , // ItemUnit = drow.ItemArray.GetValue(3).ToString() // , // DateAcquired = drow.ItemArray.GetValue(4).ToString() // , // Price = double.Parse(drow.ItemArray.GetValue(5).ToString()) // , // TotalCost = double.Parse(drow.ItemArray.GetValue(6).ToString()) // , // Remarks = drow.ItemArray.GetValue(7).ToString() // }); // } // } // catch (Exception ex) // { // Loading_User.Visibility = Visibility.Visible; // Icon.Kind = MahApps.Metro.IconPacks.PackIconMaterialKind.MessageAlert; // TextBlock_Message.Text = ex.Message.ToUpper(); // } // } private void Button_Add_Click(object sender, RoutedEventArgs e) { TextBox_TransactionId.Clear(); TextBox_ItemDescription.Clear(); TextBox_Price.Clear(); TextBox_Quantity.Clear(); TextBox_Search.Clear(); TextBox_Unit.Clear(); TextBox_TotalCost.Clear(); status = statusAdminContent.Add; }
private void Button_Delete_Click(object sender, RoutedEventArgs e) { dc = new database_connection(); if (status == statusAdminContent.select) { string query; try { query = $@"Delete from ItemDetailss Where Id='{ TextBox_TransactionId.Text} ' "; dc.Connection2(query); query = $@"Delete from RemarksMessage where Id='{TextBox_TransactionId.Text}'"; dc.Connection2(query); TextBox_TransactionId.Clear(); TextBox_ItemDescription.Clear(); TextBox_Price.Clear(); TextBox_Quantity.Clear(); TextBox_Search.Clear(); TextBox_Unit.Clear(); TextBox_TotalCost.Clear(); status = statusAdminContent.delete; Loading_User.Visibility = Visibility.Visible; Icon.Kind = MahApps.Metro.IconPacks.PackIconMaterialKind.DeleteRestore; TextBlock_Message.Text = "deleted Records".ToUpper(); } catch (Exception ex) { Loading_User.Visibility = Visibility.Visible; Icon.Kind = MahApps.Metro.IconPacks.PackIconMaterialKind.MessageAlert; TextBlock_Message.Text = ex.Message.ToUpper(); } } else { Loading_User.Visibility = Visibility.Visible; Icon.Kind = MahApps.Metro.IconPacks.PackIconMaterialKind.MessageAlert; TextBlock_Message.Text = "Please Click the Records you want to delete".ToUpper(); } }