Beispiel #1
0
 void DeleteItem(string AdminName, string tableName, string connectionString, Itemz isDeleteitem)
 {
     if (ListItem.Count != 0)
     {
         using (var command = new MySqlCommand())
         {
             command.Connection = new MySqlConnection(connectionString);
             command.Connection.Open();
             command.CommandText = $"delete from {tableName} where id=@id and userAdmin=@userAdmin";
             command.Parameters.AddWithValue("@id", isDeleteitem.id);
             command.Parameters.AddWithValue("@userAdmin", AdminName);
             command.ExecuteNonQuery();
             command.Connection.Close();
             ListItem.Clear();
         }
         UpdateListItem(AdminName, tableName, connectionString);
         if (ListItem.Count != 0)
         {
             HistoryData(AdminName, tableName, TypeDIU.Delete, connectionString, isDeleteitem);
             DefaultDisplayItems();
         }
         else
         {
             HistoryData(AdminName, tableName, TypeDIU.Delete, connectionString, isDeleteitem);
             DefaultDisplayItems();
         }
     }
     else
     {
         MessageBox.Show("Không có dữ liệu để xóa");
     }
 }
Beispiel #2
0
 public void UpdateList(int id)
 {
     SelectedCategoryId = id;
     ListItem.Clear();
     foreach (var el in Model.Spends.Where(o => o.idClass == id))
     {
         ListItem.Add(el);
     }
 }
Beispiel #3
0
 void UpdateListItem(string AdminName, string tableName, string connectionString)
 {
     ListItem.Clear();
     using (var command = new MySqlCommand())
     {
         var connection = new MySqlConnection(connectionString);
         connection.Open();
         command.Connection  = connection;
         command.CommandText = $@"select * from {tableName} where userAdmin=@userAdmin";
         command.Parameters.AddWithValue("@userAdmin", AdminName);
         var result = command.ExecuteReader();
         if (result.HasRows)
         {
             while (result.Read())
             {
                 ListItem.Add(new Itemz(result));
             }
             result.Close();
         }
         connection.Close();
     }
 }
 public bool EmptyCart()
 {
     ListItem.Clear();
     return(true);
 }